From 90cf44906d4951599b921285d2ded0319fc6b387 Mon Sep 17 00:00:00 2001 From: Adrian Victor Date: Thu, 30 Apr 2026 21:59:04 -0300 Subject: [PATCH 1/4] Depend on cordova plugins only when on cordova. --- www/script.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/www/script.js b/www/script.js index 944a1fc..bf18cab 100644 --- a/www/script.js +++ b/www/script.js @@ -6,6 +6,8 @@ const body = document.querySelector("body"); const hintCheckbox = document.querySelector("#hintCheck"); const timerInput = document.getElementById("timerInput"); +const isCordova = typeof cordova !== 'undefined'; + const theme = localStorage.getItem('theme'); if (theme == "light") { @@ -86,10 +88,11 @@ startButton.addEventListener('click', () => { break; } case 3: { - if (!!navigator.vibrate) { + if (isCordova && !!navigator.vibrate) { navigator.vibrate(0); } - if (!!StayAwake.enableScreenTimeout) { + + if (isCordova && !!StayAwake.enableScreenTimeout) { StayAwake.enableScreenTimeout(); } clearInterval(timer); @@ -159,26 +162,28 @@ startButton.addEventListener('click', () => { var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000); timerElement.innerText = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`; - if (!!StayAwake.disableScreenTimeout) { + + if (isCordova && !!StayAwake.disableScreenTimeout) { StayAwake.disableScreenTimeout(); } if (distance < 0) { clearInterval(timer); - + if (!!navigator.vibrate) { navigator.vibrate([1000, 500, 1000, 2000, 1000, 500, 1000, 2000, 1000, 500, 1000, 2000]); } - - if (!!StayAwake.enableScreenTimeout) { + + if (isCordova && !!StayAwake.enableScreenTimeout) { StayAwake.enableScreenTimeout(); } - + timerElement.innerText = "Acabou!"; } }, 1000) } + function changeTheme(){ body.classList.toggle('light-theme'); console.log(body.classList.contains('light-theme') ? "light" : "dark") From 8e5b1ed77fd11d4e616f5e5ee0896ff7dbdaf71f Mon Sep 17 00:00:00 2001 From: Adrian Victor Date: Fri, 1 May 2026 09:38:49 -0300 Subject: [PATCH 2/4] Adjust body size to visible viewport. --- www/style.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/style.css b/www/style.css index e44f0cb..2c8913f 100644 --- a/www/style.css +++ b/www/style.css @@ -37,8 +37,8 @@ body { flex-direction: column; padding: 2em; gap: 1em; - height: 100vh; - max-height: 100vh; + height: 100svh; + max-height: 100svh; width: 30vw; margin: auto; overflow: hidden; From 4418fd3279bd15441ffaf2eb4f11300662600876 Mon Sep 17 00:00:00 2001 From: Adrian Victor Date: Fri, 1 May 2026 09:50:54 -0300 Subject: [PATCH 3/4] Use dvh instead of svh for body size. --- www/style.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/style.css b/www/style.css index 2c8913f..de93b8b 100644 --- a/www/style.css +++ b/www/style.css @@ -37,8 +37,8 @@ body { flex-direction: column; padding: 2em; gap: 1em; - height: 100svh; - max-height: 100svh; + height: 100dvh; + max-height: 100dvh; width: 30vw; margin: auto; overflow: hidden; From 6ab23129833556ee08be65903f69a9b0c9d07265 Mon Sep 17 00:00:00 2001 From: Adrian Victor Date: Fri, 1 May 2026 09:54:54 -0300 Subject: [PATCH 4/4] Revert to use vh because mobile sucks --- www/style.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/style.css b/www/style.css index de93b8b..e44f0cb 100644 --- a/www/style.css +++ b/www/style.css @@ -37,8 +37,8 @@ body { flex-direction: column; padding: 2em; gap: 1em; - height: 100dvh; - max-height: 100dvh; + height: 100vh; + max-height: 100vh; width: 30vw; margin: auto; overflow: hidden;