-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
92 lines (87 loc) · 3.13 KB
/
script.js
File metadata and controls
92 lines (87 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const reveals = document.querySelectorAll(".reveal");
if ("IntersectionObserver" in window) {
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("is-visible");
observer.unobserve(entry.target);
}
});
},
{
threshold: 0.16,
rootMargin: "0px 0px -24px 0px",
}
);
reveals.forEach((section, index) => {
section.style.transitionDelay = `${Math.min(index * 60, 180)}ms`;
observer.observe(section);
});
} else {
reveals.forEach((section) => section.classList.add("is-visible"));
}
// Copy the .deb install command to clipboard with a brief "Copied!" flash.
function copyInstallCmd(event) {
event.preventDefault();
var box = event.currentTarget;
var code = box.querySelector("code");
var label = box.querySelector(".install-cmd-copy");
if (!code || !label) return;
var original = label.textContent;
var cmd = code.textContent.trim();
var done = function () {
box.classList.add("copied");
label.textContent = "Copied!";
setTimeout(function () {
box.classList.remove("copied");
label.textContent = original;
}, 1500);
};
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(cmd).then(done).catch(function () {
label.textContent = "Press Ctrl+C";
});
} else {
// Fallback for older browsers
var ta = document.createElement("textarea");
ta.value = cmd;
document.body.appendChild(ta);
ta.select();
try { document.execCommand("copy"); done(); } catch (_) { label.textContent = "Press Ctrl+C"; }
document.body.removeChild(ta);
}
}
// Direct download from GitHub releases
function downloadRelease(platform, event) {
event.preventDefault();
var link = event.currentTarget;
var originalText = link.textContent;
link.textContent = 'Fetching latest release…';
fetch('https://api.github.com/repos/codedev-david/termpolis/releases/latest')
.then(function (res) { return res.json(); })
.then(function (release) {
var asset = release.assets.find(function (a) {
var name = a.name.toLowerCase();
if (platform === 'windows') return name.endsWith('.exe');
if (platform === 'mac-arm64') return name.endsWith('.dmg') && name.includes('arm64');
if (platform === 'mac-x64') return name.endsWith('.dmg') && !name.includes('arm64');
if (platform === 'linux-deb') return name.endsWith('.deb');
if (platform === 'linux-appimage') return name.endsWith('.appimage');
// Back-compat: older links that passed 'linux' still resolve to AppImage.
if (platform === 'linux') return name.endsWith('.appimage');
return false;
});
if (asset) {
window.location.href = asset.browser_download_url;
} else {
window.location.href = 'https://github.com/codedev-david/termpolis/releases/latest';
}
})
.catch(function () {
window.location.href = 'https://github.com/codedev-david/termpolis/releases/latest';
})
.finally(function () {
link.textContent = originalText;
});
}