Skip to content

Commit

Permalink
feat: press t to change theme
Browse files Browse the repository at this point in the history
  • Loading branch information
heycalmdown committed Nov 24, 2018
1 parent e50e0d8 commit 75d7a0c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions views/page.pug
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ html
Reveal.addEventListener('ready', onReadyToRenderMermaid);
Reveal.addEventListener('slidechanged', onReadyToRenderMermaid);
mermaid.initialize({startOnLoad: false});
document.addEventListener('keypress', function (event) {
if (typeof URL === 'undefined') return;
const url = new URL(document.location);
if (!url.searchParams) return;
if (event.keyCode === 116) {
const themes = [
'beige', 'black', 'blood', 'league', 'moon', 'night', 'serif', 'simple', 'sky', 'solarized', 'white'
];
const prevTheme = url.searchParams.get('theme');
const prevIndex = themes.indexOf(prevTheme || 'black');
url.searchParams.set('theme', themes[(prevIndex + 1) % themes.length]);
document.location = url.href;
}
}, false);

0 comments on commit 75d7a0c

Please sign in to comment.