Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Polish/keep device awake #193

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,21 @@ <h1>Are you sure you want to delete all tasks?</h1>
<script type="module" src="./js/Misc/Settings.js"></script>
<script type="module" src="./js/FAQ/FAQ.js"></script>
<script src="./js/ThirdParty/intro.js"></script>
<script src="https://raw.githack.com/Uriopass/NoSleep.js/master/dist/NoSleep.js"></script>
</div>
<script>
// set the transition back to 2s after dark theme is painted
document.querySelector('body').style.transitionDuration = '0.2s';

localStorage.setItem('timer-running', false);
const noSleep = new NoSleep();
document.addEventListener('click', function() {
if (localStorage.getItem('timer-running') === 'true'){
noSleep.enable();
} else {
noSleep.disable();
}
}, false);
</script>
</body>

Expand Down
9 changes: 9 additions & 0 deletions js/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ TimerObj.addEventListener('timer-complete', (e) => {
workModeSound();
}
updateSessionIndicators(e.detail.longBreakLocation);
localStorage.setItem('timer-running', false);
// Click an arbitrary element to remind the event listener in index.html
timeDisplay.click();
});

/**
Expand Down Expand Up @@ -315,6 +318,9 @@ TimerObj.addEventListener('timer-start', (e) => {
});
exitFocusMode();
}
localStorage.setItem('timer-running', true);
// Click an arbitrary element to remind the event listener in index.html
timeDisplay.click();
});

/**
Expand All @@ -331,6 +337,9 @@ TimerObj.addEventListener('timer-end', () => {
element.style.pointerEvents = 'auto';
});
exitFocusMode();
localStorage.setItem('timer-running', false);
// Click an arbitrary element to remind the event listener in index.html
timeDisplay.click();
});

document.body.addEventListener('task-up', (e) => {
Expand Down