diff --git a/src/components/HomePage.vue b/src/components/HomePage.vue index 3a926d0..277b61d 100644 --- a/src/components/HomePage.vue +++ b/src/components/HomePage.vue @@ -14,7 +14,7 @@ export default { visuForm: false, visuButt: true, sp: { - serv: "home", + servHome: true, punt: { home: 0, guest: 0 }, set: { home: 0, guest: 0 }, nomi: { home: "Antoniana", guest: "Guest" }, @@ -28,34 +28,12 @@ export default { mounted() { this.voices = window.speechSynthesis.getVoices(); if (this.isMobile()) { + this.speak(); var noSleep = new NoSleep(); noSleep.enable(); document.documentElement.requestFullscreen(); } - window.addEventListener("keydown", (e) => { - e.preventDefault(); - if (e.ctrlKey && e.key == "m") { - this.diaNomi.show = true - } else if (e.ctrlKey && e.key == "b") { - this.visuButt = !this.visuButt - } else if (e.ctrlKey && e.key == "f") { - document.documentElement.requestFullscreen(); - } else if (e.ctrlKey && e.key == "z") { - this.visuForm = !this.visuForm - } else if (e.ctrlKey && e.key == "ArrowUp") { - this.incPunt("home") - } else if (e.ctrlKey && e.key == "ArrowDown") { - this.decPunt("home") - } else if (e.ctrlKey && e.key == "ArrowRight") { - this.incSet("home") - } else if (e.shiftKey && e.key == "ArrowUp") { - this.incPunt("guest") - } else if (e.shiftKey && e.key == "ArrowDown") { - this.decPunt("guest") - } else if (e.shiftKey && e.key == "ArrowRight") { - this.incSet("guest") - } else { return false } - }) + this.abilitaTastiSpeciali(); }, methods: { closeApp() { @@ -95,7 +73,7 @@ export default { }, incPunt(team) { this.sp.punt[team]++; - this.sp.serv = team; + this.sp.servHome = (team == "home"); this.sp.form[team].push(this.sp.form[team].shift()); }, decPunt(team) { @@ -105,21 +83,19 @@ export default { this.sp.form[team].unshift(this.sp.form[team].pop()); } }, - changeServ() { - // cambio servizio... usato per speak del punteggio - if (this.sp.serv == "home") { - this.sp.serv = "guest"; - } else { - this.sp.serv = "home"; - } - }, speak() { const msg = new SpeechSynthesisUtterance(); - if (this.sp.serv == "home") { - msg.text = this.sp.punt.home + " a " + this.sp.punt.guest; + if (this.sp.punt.home + this.sp.punt.guest == 0) { + msg.text = "zero a zero"; + } else if (this.sp.punt.home == this.sp.punt.guest) { + msg.text = this.sp.punt.home + " pari"; } else { - msg.text = this.sp.punt.guest + " a " + this.sp.punt.home; - } + if (this.sp.servHome) { + msg.text = this.sp.punt.home + " a " + this.sp.punt.guest; + } else { + msg.text = this.sp.punt.guest + " a " + this.sp.punt.home; + } + } // msg.volume = 1.0; // speech volume (default: 1.0) // msg.pitch = 1.0; // speech pitch (default: 1.0) // msg.rate = 1.0; // speech rate (default: 1.0) @@ -133,28 +109,68 @@ export default { // console.log('Speech paused:', event.utterance.text.substring(event.charIndex)); // }; window.speechSynthesis.speak(msg); + }, + apriDialogConfig() { + this.disabilitaTastiSpeciali(); + this.diaNomi.show = true; + }, + disabilitaTastiSpeciali() { + window.removeEventListener("keydown", this.funzioneTastiSpeciali); + }, + abilitaTastiSpeciali() { + window.addEventListener("keydown", this.funzioneTastiSpeciali); + }, + funzioneTastiSpeciali(e) { + e.preventDefault(); + if (e.ctrlKey && e.key == "m") { + this.diaNomi.show = true + } else if (e.ctrlKey && e.key == "b") { + this.visuButt = !this.visuButt + } else if (e.ctrlKey && e.key == "f") { + document.documentElement.requestFullscreen(); + } else if (e.ctrlKey && e.key == "s") { + this.speak(); + } else if (e.ctrlKey && e.key == "z") { + this.visuForm = !this.visuForm + } else if (e.ctrlKey && e.key == "ArrowUp") { + this.incPunt("home") + } else if (e.ctrlKey && e.key == "ArrowDown") { + this.decPunt("home") + } else if (e.ctrlKey && e.key == "ArrowRight") { + this.incSet("home") + } else if (e.shiftKey && e.key == "ArrowUp") { + this.incPunt("guest") + } else if (e.shiftKey && e.key == "ArrowDown") { + this.decPunt("guest") + } else if (e.shiftKey && e.key == "ArrowRight") { + this.incSet("guest") + } else if (e.ctrlKey && e.key == "ArrowLeft") { + this.sp.servHome = !this.sp.servHome + } else { return false } } } };