Skip to content

Commit

Permalink
add presentation mode
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaIT committed Jan 10, 2023
1 parent 631fea7 commit fe39e82
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion breakpoints.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ <h2>Trick of the day:</h2>
document.getElementById('next').onclick = e => {
var allowed = false;
console.log('Allowed', allowed);
if (!allowed) {
if (!allowed && !localStorage.presentationMode) {
alert('You shall not pass!')
e.preventDefault();
}
Expand All @@ -99,5 +99,6 @@ <h2>Trick of the day:</h2>
<footer class="container">
WebCore 2021
</footer>
<script src="js/mode-switch.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ <h1 class="title">Unorthodox ways to debug JS</h1>
<footer class="container">
WebCore 2021
</footer>
<script src="js/mode-switch.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion js/log-debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ termsCheckbox.onchange = () => {
};

function next() {
if (termsAccepted !== true) {
if (termsAccepted !== true && !localStorage.presentationMode) {
console.log('termsAccepted:', termsAccepted);
termsCheckbox.setAttribute('aria-invalid', 'true');
alert('Accept terms first!');
Expand Down
18 changes: 18 additions & 0 deletions js/mode-switch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// add toggle element
const footer = document.querySelector('footer');
footer.innerHTML += `, <a id="mode-switch" onclick="toggleMode()">presentation mode</a>`;

function renderModeSwitch() {
const modeSwitch = document.querySelector('#mode-switch');
modeSwitch.innerText = (localStorage.presentationMode ? 'disable' : 'enable') + ' presentation mode';
}

function toggleMode() {
if (localStorage.presentationMode) {
delete localStorage.presentationMode;
} else {
localStorage.presentationMode = 'true';
}
renderModeSwitch();
}
renderModeSwitch();
1 change: 1 addition & 0 deletions log-debugger.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,6 @@ <h1>Nice modal bro</h1>
<footer class="container">
WebCore 2021
</footer>
<script src="js/mode-switch.js"></script>
</body>
</html>
2 changes: 2 additions & 0 deletions other-breakpoints.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ <h2>XHR Fetch breakpoints</h2>

<h2>Event listeners breakpoints</h2>
<p>Will stop on any event you like!</p>
<!-- TODO: example with break on page load ??? -->
</article>

<div class="grid">
Expand All @@ -58,5 +59,6 @@ <h2>Event listeners breakpoints</h2>
<footer class="container">
WebCore 2021
</footer>
<script src="js/mode-switch.js"></script>
</body>
</html>

0 comments on commit fe39e82

Please sign in to comment.