From: Bas Schouten Date: Mon, 22 Apr 2024 10:02:33 +0000 (+0000) Subject: Make WebUI look slightly less awful. X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=b9572f193043d7f4e45eabcba158c98e66e384d0;p=pithrottler.git Make WebUI look slightly less awful. --- diff --git a/html/index.html b/html/index.html index 3566a34..ff3a317 100644 --- a/html/index.html +++ b/html/index.html @@ -3,80 +3,11 @@ PiThrottler Configuration - + + +

PiThrottler Control

diff --git a/html/pithrottler.css b/html/pithrottler.css index e69de29..f62d675 100644 --- a/html/pithrottler.css +++ b/html/pithrottler.css @@ -0,0 +1,28 @@ +html { + background-color:#101010; +} + +body { + text-align:center; + color:#fff; + font-family:Arial; +} + +select, button { + width: 160px; + height: 30px; + border: 1px solid #444; + font-size: 18px; + background-color: #202020; + border-radius: 5px; + color: #1c87c9; +} + +select:hover, button:hover { + background-color:#303030; +} + +select { + box-shadow: 4px 4px #666; + margin-bottom:10px; +} diff --git a/html/pithrottler.js b/html/pithrottler.js new file mode 100644 index 0000000..fb1477f --- /dev/null +++ b/html/pithrottler.js @@ -0,0 +1,70 @@ +const presets = { + Unlimited: { + label: "Unlimited", + latency: 0, + ploss: 0, + throughput: 0 + }, + F4G: { + label: "4G Fast", + latency: 30, + ploss: 0, + throughput: 20000 + }, + S4G: { + label: "4G Slow", + latency: 150, + ploss: 1, + throughput: 10000 + }, + F3G: { + label: "3G Fast", + latency: 110, + ploss: 0, + throughput: 5000 + }, + S3G: { + label: "3G Slow", + latency: 200, + ploss: 3, + throughput: 1000 + } +}; +function saveSettings() { + fetch("/set?latency=" + document.getElementById("latencyRange").value + "&ploss=" + document.getElementById("plossRange").value + "&throughput=" + document.getElementById("tpRange").value); +} + +async function checkForUpdates() { + const updateAvailable = await fetch("/checkupdate"); + if (await updateAvailable.text() == "0") { + document.getElementById("updateStatus").innerHTML = "Up to date."; + } else { + document.getElementById("updateStatus").innerHTML = "An update is available."; + document.getElementById("updateButton").style.display = ""; + } +} + +async function runUpdate() { + document.getElementById("updateStatus").innerHTML = "Updating..."; + document.getElementById("updateButton").style.display = "none"; + const updateAvailable = await fetch("/runupdate"); + location.reload(); +} + +function loadPresets() { + let innerhtml = ""; + for (type in presets) { + innerhtml += ""; + } + document.getElementById("preset").innerHTML = innerhtml; +} + +function changePreset() { + var preset = document.getElementById("preset").value; + document.getElementById("latencyRange").value = presets[preset].latency; + document.getElementById("latency").innerHTML = presets[preset].latency; + document.getElementById("plossRange").value = presets[preset].ploss; + document.getElementById("ploss").innerHTML = presets[preset].ploss; + document.getElementById("tpRange").value = presets[preset].throughput; + document.getElementById("tp").innerHTML = presets[preset].throughput; +} \ No newline at end of file