Spaces:
Running
Running
Download script.js from Noobjay/speedtest-robot: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/Noobjay/speedtest-robot/resolve/main/script.js
- Command line
-
hf download hf://spaces/Noobjay/speedtest-robot/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Noobjay/speedtest-robot/resolve/main/script.js
1.07 kB
| window.onload = () => { | |
| const s = new Speedtest(); | |
| document.getElementById("startBtn").addEventListener("click", () => { | |
| s.onupdate = data => { | |
| let dl = parseFloat(data.dlStatus || 0).toFixed(2); | |
| let ul = parseFloat(data.ulStatus || 0).toFixed(2); | |
| let ping = parseFloat(data.ping || 0).toFixed(2); | |
| document.getElementById("dl").textContent = dl; | |
| document.getElementById("ul").textContent = ul; | |
| document.getElementById("ping").textContent = ping; | |
| animateGauge(Number(dl)); | |
| }; | |
| s.onend = () => { | |
| console.log("Test completed."); | |
| saveToLocal(); | |
| }; | |
| s.start(); | |
| }); | |
| }; | |
| function saveToLocal() { | |
| const result = { | |
| dl: document.getElementById("dl").textContent, | |
| ul: document.getElementById("ul").textContent, | |
| ping: document.getElementById("ping").textContent, | |
| date: new Date().toLocaleString() | |
| }; | |
| let history = JSON.parse(localStorage.getItem("speedTestHistory") || "[]"); | |
| history.push(result); | |
| localStorage.setItem("speedTestHistory", JSON.stringify(history)); | |
| } | |