Compare commits

..

4 commits

View file

@ -6,6 +6,8 @@ const body = document.querySelector("body");
const hintCheckbox = document.querySelector("#hintCheck"); const hintCheckbox = document.querySelector("#hintCheck");
const timerInput = document.getElementById("timerInput"); const timerInput = document.getElementById("timerInput");
const isCordova = typeof cordova !== 'undefined';
const theme = localStorage.getItem('theme'); const theme = localStorage.getItem('theme');
if (theme == "light") { if (theme == "light") {
@ -86,10 +88,11 @@ startButton.addEventListener('click', () => {
break; break;
} }
case 3: { case 3: {
if (!!navigator.vibrate) { if (isCordova && !!navigator.vibrate) {
navigator.vibrate(0); navigator.vibrate(0);
} }
if (!!StayAwake.enableScreenTimeout) {
if (isCordova && !!StayAwake.enableScreenTimeout) {
StayAwake.enableScreenTimeout(); StayAwake.enableScreenTimeout();
} }
clearInterval(timer); clearInterval(timer);
@ -159,26 +162,28 @@ startButton.addEventListener('click', () => {
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000); var seconds = Math.floor((distance % (1000 * 60)) / 1000);
timerElement.innerText = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`; timerElement.innerText = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
if (!!StayAwake.disableScreenTimeout) {
if (isCordova && !!StayAwake.disableScreenTimeout) {
StayAwake.disableScreenTimeout(); StayAwake.disableScreenTimeout();
} }
if (distance < 0) { if (distance < 0) {
clearInterval(timer); clearInterval(timer);
if (!!navigator.vibrate) { if (!!navigator.vibrate) {
navigator.vibrate([1000, 500, 1000, 2000, 1000, 500, 1000, 2000, 1000, 500, 1000, 2000]); navigator.vibrate([1000, 500, 1000, 2000, 1000, 500, 1000, 2000, 1000, 500, 1000, 2000]);
} }
if (!!StayAwake.enableScreenTimeout) { if (isCordova && !!StayAwake.enableScreenTimeout) {
StayAwake.enableScreenTimeout(); StayAwake.enableScreenTimeout();
} }
timerElement.innerText = "Acabou!"; timerElement.innerText = "Acabou!";
} }
}, 1000) }, 1000)
} }
function changeTheme(){ function changeTheme(){
body.classList.toggle('light-theme'); body.classList.toggle('light-theme');
console.log(body.classList.contains('light-theme') ? "light" : "dark") console.log(body.classList.contains('light-theme') ? "light" : "dark")