]> git.basschouten.com Git - pithrottler.git/commitdiff
Make WebUI look slightly less awful.
authorBas Schouten <bschouten@mozilla.com>
Mon, 22 Apr 2024 10:02:33 +0000 (10:02 +0000)
committerBas Schouten <bschouten@mozilla.com>
Mon, 22 Apr 2024 10:02:33 +0000 (10:02 +0000)
html/index.html
html/pithrottler.css
html/pithrottler.js [new file with mode: 0644]

index 3566a3437fd3cc65e563baf8dcdcd4868e96d67b..ff3a31704e28be77756a9f663186e87b4ed6530f 100644 (file)
@@ -3,80 +3,11 @@
 
 <head>
   <title>PiThrottler Configuration</title>
-  <script>
-    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");\r
-      if (await updateAvailable.text() == "0") {\r
-        document.getElementById("updateStatus").innerHTML = "Up to date.";\r
-      } else {\r
-        document.getElementById("updateStatus").innerHTML = "An update is available.";\r
-        document.getElementById("updateButton").style.display = "";\r
-      }\r
-    }
-
-    async function runUpdate() {
-      document.getElementById("updateStatus").innerHTML = "Updating...";
-      document.getElementById("updateButton").style.display = "none";
-      const updateAvailable = await fetch("/runupdate");\r
-      location.reload();\r
-    }
-
-    function loadPresets() {
-      let innerhtml = "";
-      for (type in presets) {
-        innerhtml += "<option value='" + type + "'>" + presets[type].label + "</option>";
-      }
-      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;
-    }
-  </script>
+  <link rel="stylesheet" href="pithrottler.css">
+  <script src="pithrottler.js"></script>
 </head>
 <body onload="loadPresets();">
+  <h3>PiThrottler Control</h3>
   <select id="preset" onchange="changePreset();">
   </select>
   <div class="slidecontainer">
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f62d675eaac43d8ce2ef3a044ad4703caa33d153 100644 (file)
@@ -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 (file)
index 0000000..fb1477f
--- /dev/null
@@ -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 += "<option value='" + type + "'>" + presets[type].label + "</option>";
+  }
+  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