function escapeHTML(source) {
return source.replace(/&/g, "&").replace(//g, ">").replace(/[\r\n]/g, "
");
}
function decodeHTML(html) {
var txt = document.createElement("textarea");
txt.innerHTML = html;
return txt.value;
}
var tabs = [
{
name: "GNU/Linux",
command: "curl -fsSL https://downloads.svrjs.org/installer/svr.js.installer.linux.20240405.sh > /tmp/installer.sh && sudo bash /tmp/installer.sh",
uaRegex: /\b(?:GNU\/)?Linux\b/gi
}
];
if (tabs.length > 0) {
var otherTab = document.getElementById("command-tab-other");
var otherTabOuterHTML = otherTab.outerHTML;
var tabsHTML = "";
var tabToClick = tabs.length;
for (var i = 0; i <= tabs.length; i++) {
tabsHTML += "";
if (i == tabs.length) {
tabsHTML += "Manually";
} else {
tabsHTML += escapeHTML(tabs[i].name);
}
tabsHTML += "";
if (tabToClick == tabs.length && i != tabs.length && navigator.userAgent.match(tabs[i].uaRegex)) tabToClick = i;
}
otherTab.outerHTML = "
" + tabsHTML + "
";
var tabContainer = document.getElementById("command-tab-container");
for (var i = 0; i <= tabs.length; i++) {
document.getElementById("command-tab-" + i).onclick = createTabClickHandler(i);
}
function copyHandler() {
if (navigator.clipboard) {
navigator.clipboard.writeText(decodeHTML(document.getElementById("command-tab-command").innerHTML));
} else {
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById("command-tab-command"));
range.select();
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById("command-tab-command"));
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
}
document.execCommand("copy");
if (document.selection) {
document.selection.empty();
} else if (window.getSelection) {
window.getSelection().removeAllRanges();
}
}
document.getElementById("command-tab-copy").innerHTML = "Copied!";
}
function createTabClickHandler(i) {
return function () {
for (var j = 0; j <= tabs.length; j++) {
document.getElementById("command-tab-" + j).className = "command-tab";
}
document.getElementById("command-tab-" + i).className = "command-tab command-tab-selected";
var container = document.getElementById("command-tab-container");
if (i == tabs.length) {
container.innerHTML = otherTabOuterHTML;
} else {
container.innerHTML = "Install SVR.JS
Copy
" + escapeHTML(tabs[i].command) + "
";
document.getElementById("command-tab-copy").onclick = copyHandler;
}
}
}
document.getElementById("command-tab-" + tabToClick).click();
}