Frontend: Add common vibrate function

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-01-31 12:00:26 +00:00
parent bbdaf4308a
commit a226c8ff72
5 changed files with 17 additions and 3 deletions

View File

@ -62,7 +62,7 @@
<!-- Footer -->
<footer>
<p>Created by <a href="https://fredboniface.co.uk" target="_blank" rel="noreferrer noopener">Fred Boniface</a> - 0.0.1-dev-20230127001</p>
<p>Created by <a href="https://fredboniface.co.uk" target="_blank" rel="noreferrer noopener">Fred Boniface</a> - 0.0.1-dev-2023013104</p>
</footer>
</body>

View File

@ -38,6 +38,7 @@ async function parseData(values){
log("find-code.parseData: No data entered", "WARN")
await clearForm();
document.getElementById("name").value = "No data entered"
vibrate("err");
hideLoading();
return;
}
@ -52,6 +53,7 @@ async function getData(type, value){
return await resp.json()
} catch (err) {
log(`find-code.getData: Error getting data: ${err}`, "WARN")
vibrate("err")
return "";
}
}
@ -88,5 +90,6 @@ async function clearForm(){
document.getElementById("nlc").value = ""
document.getElementById("tiploc").value = ""
document.getElementById("stanox").value = ""
navigator.vibrate("ok");
hideLoading();
}

View File

@ -75,11 +75,12 @@ async function send() {
var res = await fetch("/api/v1/issue", opt)
if (res.status == 200) {
setLoadingDesc("Success")
vibrate("ok")
await delay(2500)
window.location.replace("/")
} else {
setLoadingDesc("Error")
navigator.vibrate(1500)
vibrate("err")
await delay(2500)
hideLoading()
document.getElementById("preflight").style = "display: none;"

View File

@ -112,4 +112,14 @@ async function getQuery(param) {
} else {
return 'false'
}
}
async function vibrate(type) {
vb = navigator.vibrate
switch (type) {
case "err":
vb(1200)
case "ok":
vb([100,30,100])
}
}

View File

@ -1,6 +1,6 @@
/* Service Worker */
const appVersion = "0.0.1-dev-20230127001"
const appVersion = "0.0.1-dev-2023013104"
const cacheName = `owlboard-${appVersion}`
const cacheIDs = [cacheName]
const cacheFiles = [