diff options
Diffstat (limited to 'plugin/notes/notes.html')
-rw-r--r-- | plugin/notes/notes.html | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/plugin/notes/notes.html b/plugin/notes/notes.html index e368a5f..5b75d73 100644 --- a/plugin/notes/notes.html +++ b/plugin/notes/notes.html @@ -427,10 +427,17 @@ * Forward keyboard events to the current slide window. * This enables keyboard events to work even if focus * isn't set on the current slide iframe. + * + * Block F5 default handling, it reloads and disconnects + * the speaker notes window. */ function setupKeyboard() { document.addEventListener( 'keydown', function( event ) { + if( event.keyCode === 116 || ( event.metaKey && event.keyCode === 82 ) ) { + event.preventDefault(); + return false; + } currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'triggerKey', args: [ event.keyCode ] }), '*' ); } ); @@ -675,7 +682,7 @@ document.body.setAttribute( 'data-speaker-layout', value ); // Persist locally - if( window.localStorage ) { + if( supportsLocalStorage() ) { window.localStorage.setItem( 'reveal-speaker-layout', value ); } @@ -687,7 +694,7 @@ */ function getLayout() { - if( window.localStorage ) { + if( supportsLocalStorage() ) { var layout = window.localStorage.getItem( 'reveal-speaker-layout' ); if( layout ) { return layout; @@ -701,6 +708,19 @@ } + function supportsLocalStorage() { + + try { + localStorage.setItem('test', 'test'); + localStorage.removeItem('test'); + return true; + } + catch( e ) { + return false; + } + + } + function zeroPadInteger( num ) { var str = '00' + parseInt( num ); |