Skip to content

Commit

Permalink
initial index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
marler8997 committed May 5, 2024
1 parent dc92335 commit 9cad53b
Showing 1 changed file with 184 additions and 0 deletions.
184 changes: 184 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
<!DOCTYPE html>
<html><head>
<title>Zigup</title>
<style>

* { margin:0; padding:0; }
body {
margin-top:30px;
font-family: courier;
text-align:center;
background:#333;
color:#ccc;
}
h1 { color:#eee }
pre { font-family: courier new }

#InstallDiv {
margin:10px;
}

.CopyButton {
padding:5px;
}

.FilterButton {
display:inline-block;
width: 60px;
height: 15px;
line-height: 15px;
text-align:center;
padding: 10px;
border-radius: 2px;
border: 0;
background:#ccc;
font-size: 15px;
color: #000;
cursor:default;
user-select:none;
font-weight:bold;
}
.FilterButton:hover {
background:#aaa;
}
.FilterButtonEnabled {
background:#4287f5;
}
.FilterButtonEnabled:hover {
background:#3277e5;
}
</style>
<script>

const version = "v2024_05_05";
function get(id) { return document.getElementById(id); }


function copyToClipboard(text) {
navigator.clipboard.writeText(text)
.then(() => {
console.log('Text copied to clipboard');
})
.catch(err => {
console.error('Could not copy text: ', err);
});
}

function copyCommand(id) {
pre = get('command' + id);
copyToClipboard(pre.innerHTML)
}

function generateCommandHtml(ids, cmd) {
const id = ids.next_id;
ids.next_id++;
return (
'<div>' +
'<button class="CopyButton" onclick="copyCommand(' + id + ')">Copy</button> ' +
'<pre style="display:inline-block" id="command' + id + '">' + cmd + '</pre>' +
'</div>'
);
}

function updateButton(button, enable) {
if (enable) {
button.classList.add("FilterButtonEnabled");
} else {
button.classList.remove("FilterButtonEnabled");
}
}

function toggleOs(os) {
if (current_os == os) {
current_os = -1;
} else {
current_os = os;
}
updateButton(get("ButtonLinux"), current_os == OS_LINUX);
updateButton(get("ButtonMacos"), current_os == OS_MACOS);
updateButton(get("ButtonWindows"), current_os == OS_WINDOWS);
updateInstallDiv();
}
function toggleArch(arch) {
if (current_arch == arch) {
current_arch = -1;
} else {
current_arch = arch;
}
updateButton(get("ButtonX86_64"), current_arch == ARCH_X86_64);
updateButton(get("ButtonAArch64"), current_arch == ARCH_AARCH64);
updateInstallDiv();
}

const OS_LINUX = 0;
const OS_MACOS = 1;
const OS_WINDOWS = 2;
const ARCH_X86_64 = 0;
const ARCH_AARCH64 = 1;

var current_os = -1;
var current_arch = -1;
var include_curl = true;
var include_wget = true;

function updateInstallDiv() {
var arch_os_list = [];
if (current_os == OS_LINUX) {
if (current_arch == ARCH_X86_64) {
arch_os_list.push("x86_64-linux");
}
if (current_arch == ARCH_AARCH64) {
arch_os_list.push("aarch64-linux");
}
} else if (current_os == OS_MACOS) {
if (current_arch == ARCH_X86_64) {
arch_os_list.push("x86_64-macos");
}
if (current_arch == ARCH_AARCH64) {
arch_os_list.push("aarch64-macos");
}
} else if (current_os == OS_WINDOWS) {
if (current_arch == ARCH_X86_64) {
arch_os_list.push("x86_64-windows");
}
}

html = '';

var ids = { next_id: 0 };
if (include_curl) {
for (var i = 0; i < arch_os_list.length; i++) {
const arch_os = arch_os_list[i];
html += generateCommandHtml(ids, 'curl -L https://github.com/marler8997/zigup/releases/download/' + version + '/zigup-' + arch_os + '.tar.gz | tar xz');
}
}
if (include_wget) {
for (var i = 0; i < arch_os_list.length; i++) {
const arch_os = arch_os_list[i];
html += generateCommandHtml(ids, 'wget -O - https://github.com/marler8997/zigup/releases/download/' + version + '/zigup-' + arch_os + '.tar.gz | tar xz');
}
}
get('InstallDiv').innerHTML = html;
}

function bodyOnload() {
updateInstallDiv()
}

</script>
</head><body onload="bodyOnload()">

<h1>Install Zigup</h1>
<div style="margin:10px">
<span id="ButtonLinux" class="FilterButton" onclick="toggleOs(OS_LINUX)">Linux</span>
<span id="ButtonMacos" class="FilterButton" onclick="toggleOs(OS_MACOS)">Macos</span>
<span id="ButtonWindows" class="FilterButton" onclick="toggleOs(OS_WINDOWS)">Windows</span>
</div>
<div style="margin:10px">
<span id="ButtonX86_64" class="FilterButton" onclick="toggleArch(ARCH_X86_64)">x86_64</span>
<span id="ButtonAArch64" class="FilterButton" onclick="toggleArch(ARCH_AARCH64)">aarch64</span>
</div>
<div id="InstallDiv"></div>


</html>

0 comments on commit 9cad53b

Please sign in to comment.