Frontend: Adjust vibration patterns

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-01-31 12:48:27 +00:00
parent a226c8ff72
commit 1beeaa592a
5 changed files with 18 additions and 11 deletions

View File

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

View File

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

View File

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

View File

@ -114,12 +114,19 @@ async function getQuery(param) {
} }
} }
async function vibrate(type) { async function vibe(type) {
vb = navigator.vibrate let canVibrate = "vibrate" in navigator || "mozVibrate" in navigator
if (canVibrate && !("vibrate" in navigator)){
navigator.vibrate = navigator.mozVibrate
}
switch (type) { switch (type) {
case "err": case "err":
vb(1200) navigator.vibrate([300,200,300])
break;
case "ok": case "ok":
vb([100,30,100]) navigator.vibrate([50,150,50])
break;
default:
navigator.vibrate(30)
} }
} }

View File

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