summaryrefslogtreecommitdiffstats
path: root/prog/jelka/templates/index.html
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-11-29 11:05:18 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2023-11-29 11:05:18 +0100
commitacc8625c563a3b05b1cbfdbc94d39870c7a71b42 (patch)
treee34722420c64be71768923d9b04b611293fcefea /prog/jelka/templates/index.html
parentb5 (diff)
downloadr-acc8625c563a3b05b1cbfdbc94d39870c7a71b42.tar
r-acc8625c563a3b05b1cbfdbc94d39870c7a71b42.tar.gz
r-acc8625c563a3b05b1cbfdbc94d39870c7a71b42.tar.bz2
r-acc8625c563a3b05b1cbfdbc94d39870c7a71b42.tar.lz
r-acc8625c563a3b05b1cbfdbc94d39870c7a71b42.tar.xz
r-acc8625c563a3b05b1cbfdbc94d39870c7a71b42.tar.zst
r-acc8625c563a3b05b1cbfdbc94d39870c7a71b42.zip
Diffstat (limited to 'prog/jelka/templates/index.html')
-rw-r--r--prog/jelka/templates/index.html88
1 files changed, 88 insertions, 0 deletions
diff --git a/prog/jelka/templates/index.html b/prog/jelka/templates/index.html
new file mode 100644
index 0000000..f73d0b7
--- /dev/null
+++ b/prog/jelka/templates/index.html
@@ -0,0 +1,88 @@
+<meta name=viewport content='width=device-width, initial-scale=1.0'>
+<title>jelka na fmf</title>
+<h1>jelka na fmf</h1>
+<label for=geslo>geslo: </label><input id=geslo type=text placeholder=geslo /> (geslo najdete na LED zaslonu)
+<br>
+<label for=čas>čas vzorca v sekundah: </label><input id=čas type=number placeholder=10 min=1 max=300 /> <button onclick=nastavi_čas()>nastavi!</button>
+<br>
+<!-- enkrat poženi poljuben vzorec: <input type=file id=file /> <button id=poženi>poženi</button> -->
+<ul id=vzorci></ul>
+<script>
+ function nastavi_čas() {
+ if (geslo.value == "") {
+ alert("nastavite geslo!");
+ return;
+ }
+ fetch(geslo.value, {
+ method: "POST",
+ body: JSON.stringify({
+ "čas": Number(čas.value)
+ }),
+ }).then(data => {
+ data.json().then(json => {
+ if (Object.keys(json).includes("napaka")) {
+ alert(json.napaka.besedilo)
+ }
+ })
+ });
+ }
+ geslo.value = location.hash.substr(1);
+ const evt = new EventSource("stream/");
+ evt.onmessage = (e) => {
+ data = JSON.parse(e.data);
+ console.log(data);
+ vzorci.innerHTML = "";
+ for (let i = 0; i < data.vzorci.length; i++) {
+ const li = document.createElement("li");
+ const začni = document.createElement("button");
+ const a = document.createElement("a");
+ if (data["trenuten"] == data.vzorci[i])
+ li.innerText = "trenuten: ";
+ začni.innerText = "začni";
+ a.innerText = data.vzorci[i];
+ a.href = "vzorci/" + data.vzorci[i];
+ li.appendChild(a);
+ začni.onclick = () => {
+ if (geslo.value == "") {
+ alert("nastavite geslo!");
+ return;
+ }
+ fetch(geslo.value, {
+ method: "POST",
+ body: JSON.stringify({
+ "začni": data.vzorci[i]
+ }),
+ }).then(data => {
+ data.json().then(json => {
+ if (Object.keys(json).includes("napaka")) {
+ alert(a.napaka.besedilo)
+ }
+ })
+ });
+ };
+ li.appendChild(začni);
+ const stanje = document.createElement("button");
+ stanje.innerText = "onemogoči";
+ if (data.onemogočeni.includes(data.vzorci[i]))
+ stanje.innerText = "omogoči";
+ stanje.onclick = () => {
+ if (geslo.value == "") {
+ alert("nastavite geslo!");
+ return;
+ }
+ fetch(geslo.value, {
+ method: "POST",
+ body: "{\"" + stanje.innerText + "\": [\"" + data.vzorci[i] + "\"]}",
+ }).then(data => {
+ data.json().then(json => {
+ if (Object.keys(json).includes("napaka")) {
+ alert(a.napaka.besedilo)
+ }
+ })
+ });
+ };
+ li.appendChild(stanje);
+ vzorci.appendChild(li);
+ }
+ }
+</script>