From 3a93e29e51bce56b57ac3527219ce530d3894ab6 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Tue, 17 Jan 2023 13:54:10 +0000 Subject: [PATCH] Frontend: QLS Settings under test Signed-off-by: Fred Boniface --- static/index.html | 11 ++------ static/js/find-code.js | 2 +- static/js/index.js | 18 +++++++++++++ static/js/settings.js | 52 ++++++++++++++++++++++++++++++++++++++ static/settings.html | 32 ++++++++++++----------- static/styles/settings.css | 7 +---- static/styles/style.css | 7 +++++ 7 files changed, 98 insertions(+), 31 deletions(-) diff --git a/static/index.html b/static/index.html index eb0d56f..247a658 100644 --- a/static/index.html +++ b/static/index.html @@ -53,15 +53,8 @@ apologies for any inconvinience caused to you.

Quick Links

- - - - - - - - - +

diff --git a/static/js/find-code.js b/static/js/find-code.js index 85969a1..fe3e0f6 100644 --- a/static/js/find-code.js +++ b/static/js/find-code.js @@ -1,4 +1,4 @@ -async function fetchEntry(){ +async function fetchEntry(){ // This can be condensed showLoading(); var name = document.getElementById("name") var crs = document.getElementById("3alpha") diff --git a/static/js/index.js b/static/js/index.js index 4e7bfbe..4fe9b9d 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -12,4 +12,22 @@ async function sidebarClose() { async function gotoBoard(station){ window.location.assign(`${window.location.origin}/board.html?stn=${station}`) +} + +async function setQls(){ + var qlOpt = JSON.parse(localStorage.getItem("qlOpt")) + var qlDef = ["bri","lwh","srd","mtp","rda","cfn","sml","shh","pri","avn"] + if (qlOpt) { + for(var i = 0; i < qlOpt.length; i++) { + console.log(`Button: ${qlOpt[i]}`) + var btn = `` + document.getElementById("quick_links").insertAdjacentHTML("beforeend", btn) // Append btn + } + } else { + for(var i = 0; i < qlDef.length; i++) { + console.log(`Button: ${qlDef[i]}`) + var btn = `` + document.getElementById("quick_links").insertAdjacentHTML("beforeend", btn) // Append btn + } + } } \ No newline at end of file diff --git a/static/js/settings.js b/static/js/settings.js index e69de29..32edc8f 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -0,0 +1,52 @@ +// Init: +const ql = ["ql0","ql1","ql2","ql3","ql4","ql5","ql6","ql7","ql8","ql9"] +checkStorageSupport(); + +async function checkStorageSupport(){ + if (window.localStorage){ + localStorage.setItem("support-check","8441"); + if (localStorage.getItem("support-check")=="8441"){ + console.log("Local Storage supported.") + localStorage.removeItem("support-check") + } else if (localStorage.getItem("support-check" != "8441")){ + console.log("Error fetching test value.") + } + } else { + console.log("Local Storage is not supported") + window.alert("Settings cannot be saved on your device, try updating your browser.") + } +} + +async function getQl(){ + var qlOpt = JSON.parse(localStorage.getItem("qlOpt")) + if (qlOpt){ + var i = 0 + while (i < 10) { + if (qlOpt[i] != 'undefined') { + console.log(`Setting box ql${i} to ${qlOpt[i]}`) + document.getElementById(`ql${i}`).value = qlOpt[i] + i +=1 + } + } + } +} + +async function setQl(){ + var qlSet = [] + for (i in ql) { + console.log(`Try to get value of 'ql${i}'`) + var opt = document.getElementById(`ql${i}`).value + console.log(`Found value: ${opt}`) + if (opt != ""){ + qlSet.push(opt) + } + qlSet.sort() + } + console.log(qlSet) + localStorage.setItem("qlOpt", JSON.stringify(qlSet)) +} + +async function clearQl(){ + localStorage.removeItem("qlOpt") + getQl() +} \ No newline at end of file diff --git a/static/settings.html b/static/settings.html index fb7e8c4..57248e3 100644 --- a/static/settings.html +++ b/static/settings.html @@ -13,7 +13,7 @@ OwlBoard - Settings - + @@ -32,19 +32,21 @@

Any settings you apply will only apply to the device you are using now.

Settings are not yet fully implemented, some options won't apply properly yet.

-
-
-

Enter one CRS/3ALPHA code per box

- -
- -
- -
- -
- -
-
+ +
+

Enter one CRS/3ALPHA code per box

+ +
+ +
+ +
+ +
+ +
+ + + \ No newline at end of file diff --git a/static/styles/settings.css b/static/styles/settings.css index 43be0c5..fe3cb01 100644 --- a/static/styles/settings.css +++ b/static/styles/settings.css @@ -1,9 +1,4 @@ -.small-box{ +.small-lookup-box{ max-width: 100px; height: 20px; - margin-top: 5px; - font-family: urwgothic, sans-serif; - text-align: center; - border-radius: 40px; - text-transform: uppercase; } \ No newline at end of file diff --git a/static/styles/style.css b/static/styles/style.css index c57cef6..1f49eab 100644 --- a/static/styles/style.css +++ b/static/styles/style.css @@ -160,6 +160,11 @@ label { margin-bottom: 10px; cursor: pointer; } +#quick_links{ + width: 75%; + max-width: 300px; + margin: auto; +} .actionbutton { display: inline-block; text-decoration: none; @@ -173,6 +178,8 @@ label { padding: 3px; padding-left: 8px; padding-right: 8px; + margin-left: 5px; + margin-right: 5px; margin-bottom: 10px; font-size: 18px; }