notes.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>reveal.js - Slide Notes</title>
  6. <style>
  7. body {
  8. font-family: Helvetica;
  9. }
  10. #notes {
  11. font-size: 24px;
  12. width: 640px;
  13. margin-top: 5px;
  14. clear: left;
  15. }
  16. #wrap-current-slide {
  17. width: 640px;
  18. height: 512px;
  19. float: left;
  20. overflow: hidden;
  21. }
  22. #current-slide {
  23. width: 1280px;
  24. height: 1024px;
  25. border: none;
  26. -webkit-transform-origin: 0 0;
  27. -moz-transform-origin: 0 0;
  28. -ms-transform-origin: 0 0;
  29. -o-transform-origin: 0 0;
  30. transform-origin: 0 0;
  31. -webkit-transform: scale(0.5);
  32. -moz-transform: scale(0.5);
  33. -ms-transform: scale(0.5);
  34. -o-transform: scale(0.5);
  35. transform: scale(0.5);
  36. }
  37. #wrap-next-slide {
  38. width: 448px;
  39. height: 358px;
  40. float: left;
  41. margin: 0 0 0 10px;
  42. overflow: hidden;
  43. }
  44. #next-slide {
  45. width: 1280px;
  46. height: 1024px;
  47. border: none;
  48. -webkit-transform-origin: 0 0;
  49. -moz-transform-origin: 0 0;
  50. -ms-transform-origin: 0 0;
  51. -o-transform-origin: 0 0;
  52. transform-origin: 0 0;
  53. -webkit-transform: scale(0.35);
  54. -moz-transform: scale(0.35);
  55. -ms-transform: scale(0.35);
  56. -o-transform: scale(0.35);
  57. transform: scale(0.35);
  58. }
  59. .slides {
  60. position: relative;
  61. margin-bottom: 10px;
  62. border: 1px solid black;
  63. border-radius: 2px;
  64. background: rgb(28, 30, 32);
  65. }
  66. .slides span {
  67. position: absolute;
  68. top: 3px;
  69. left: 3px;
  70. font-weight: bold;
  71. font-size: 14px;
  72. z-index: 2;
  73. color: rgba( 255, 255, 255, 0.9 );
  74. }
  75. .error {
  76. font-weight: bold;
  77. color: red;
  78. font-size: 1.5em;
  79. text-align: center;
  80. margin-top: 10%;
  81. }
  82. .error code {
  83. font-family: monospace;
  84. }
  85. .time {
  86. width: 448px;
  87. margin: 30px 0 0 10px;
  88. float: left;
  89. text-align: center;
  90. opacity: 0;
  91. -webkit-transition: opacity 0.4s;
  92. -moz-transition: opacity 0.4s;
  93. -o-transition: opacity 0.4s;
  94. transition: opacity 0.4s;
  95. }
  96. .elapsed,
  97. .clock {
  98. color: #333;
  99. font-size: 2em;
  100. text-align: center;
  101. display: inline-block;
  102. padding: 0.5em;
  103. background-color: #eee;
  104. border-radius: 10px;
  105. }
  106. .elapsed h2,
  107. .clock h2 {
  108. font-size: 0.8em;
  109. line-height: 100%;
  110. margin: 0;
  111. color: #aaa;
  112. }
  113. .elapsed .mute {
  114. color: #ddd;
  115. }
  116. </style>
  117. </head>
  118. <body>
  119. <div id="wrap-current-slide" class="slides"></div>
  120. <div id="wrap-next-slide" class="slides"><span>UPCOMING:</span></div>
  121. <div class="time">
  122. <div class="clock">
  123. <h2>Time</h2>
  124. <span id="clock">0:00:00 AM</span>
  125. </div>
  126. <div class="elapsed">
  127. <h2>Elapsed</h2>
  128. <span id="hours">00</span><span id="minutes">:00</span><span id="seconds">:00</span>
  129. </div>
  130. </div>
  131. <div id="notes"></div>
  132. <script src="../../plugin/markdown/marked.js"></script>
  133. <script>
  134. (function() {
  135. var notes,
  136. currentState,
  137. currentSlide,
  138. nextSlide,
  139. connected = false;
  140. window.addEventListener( 'message', function( event ) {
  141. var data = JSON.parse( event.data );
  142. // Messages sent by the notes plugin inside of the main window
  143. if( data && data.namespace === 'reveal-notes' ) {
  144. if( data.type === 'connect' ) {
  145. handleConnectMessage( data );
  146. }
  147. else if( data.type === 'state' ) {
  148. handleStateMessage( data );
  149. }
  150. }
  151. // Messages sent by the reveal.js inside of the current slide preview
  152. else if( data && data.namespace === 'reveal' ) {
  153. if( /ready/.test( data.eventName ) ) {
  154. // Send a message back to notify that the handshake is complete
  155. window.opener.postMessage( JSON.stringify({ namespace: 'reveal-notes', type: 'connected'} ), '*' );
  156. }
  157. else if( /slidechanged|fragmentshown|fragmenthidden|overviewshown|overviewhidden|paused|resumed/.test( data.eventName ) && currentState !== JSON.stringify( data.state ) ) {
  158. window.opener.postMessage( JSON.stringify({ method: 'setState', args: [ data.state ]} ), '*' );
  159. }
  160. }
  161. } );
  162. /**
  163. * Called when the main window is trying to establish a
  164. * connection.
  165. */
  166. function handleConnectMessage( data ) {
  167. if( connected === false ) {
  168. connected = true;
  169. setupIframes( data );
  170. setupTimer();
  171. }
  172. }
  173. /**
  174. * Called when the main window sends an updated state.
  175. */
  176. function handleStateMessage( data ) {
  177. // Store the most recently set state to avoid circular loops
  178. // applying the same state
  179. currentState = JSON.stringify( data.state );
  180. // No need for updating the notes in case of fragment changes
  181. if ( data.notes !== undefined) {
  182. if( data.markdown ) {
  183. notes.innerHTML = marked( data.notes );
  184. }
  185. else {
  186. notes.innerHTML = data.notes;
  187. }
  188. }
  189. // Update the note slides
  190. currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'setState', args: [ data.state ] }), '*' );
  191. nextSlide.contentWindow.postMessage( JSON.stringify({ method: 'setState', args: [ data.state ] }), '*' );
  192. nextSlide.contentWindow.postMessage( JSON.stringify({ method: 'next' }), '*' );
  193. }
  194. /**
  195. * Creates the preview iframes.
  196. */
  197. function setupIframes( data ) {
  198. notes = document.getElementById( 'notes' );
  199. var url = data.url + '?receiver&progress=false&overview=false&history=false';
  200. var hash = '#/' + data.state.indexh + '/' + data.state.indexv;
  201. currentSlide = document.createElement( 'iframe' );
  202. currentSlide.setAttribute( 'id', 'current-slide' );
  203. currentSlide.setAttribute( 'width', 1280 );
  204. currentSlide.setAttribute( 'height', 1024 );
  205. currentSlide.setAttribute( 'src', url + '&postMessageEvents=true' + hash );
  206. document.querySelector( '#wrap-current-slide' ).appendChild( currentSlide );
  207. nextSlide = document.createElement( 'iframe' );
  208. nextSlide.setAttribute( 'id', 'next-slide' );
  209. nextSlide.setAttribute( 'width', 640 );
  210. nextSlide.setAttribute( 'height', 512 );
  211. nextSlide.setAttribute( 'src', url + '&controls=false' + hash );
  212. document.querySelector( '#wrap-next-slide' ).appendChild( nextSlide );
  213. }
  214. /**
  215. * Create the timer and clock and start updating them
  216. * at an interval.
  217. */
  218. function setupTimer() {
  219. var start = new Date(),
  220. timeEl = document.querySelector( '.time' ),
  221. clockEl = document.getElementById( 'clock' ),
  222. hoursEl = document.getElementById( 'hours' ),
  223. minutesEl = document.getElementById( 'minutes' ),
  224. secondsEl = document.getElementById( 'seconds' );
  225. setInterval( function() {
  226. timeEl.style.opacity = 1;
  227. var diff, hours, minutes, seconds,
  228. now = new Date();
  229. diff = now.getTime() - start.getTime();
  230. hours = Math.floor( diff / ( 1000 * 60 * 60 ) );
  231. minutes = Math.floor( ( diff / ( 1000 * 60 ) ) % 60 );
  232. seconds = Math.floor( ( diff / 1000 ) % 60 );
  233. clockEl.innerHTML = now.toLocaleTimeString();
  234. hoursEl.innerHTML = zeroPadInteger( hours );
  235. hoursEl.className = hours > 0 ? '' : 'mute';
  236. minutesEl.innerHTML = ':' + zeroPadInteger( minutes );
  237. minutesEl.className = minutes > 0 ? '' : 'mute';
  238. secondsEl.innerHTML = ':' + zeroPadInteger( seconds );
  239. }, 1000 );
  240. }
  241. function zeroPadInteger( num ) {
  242. var str = '00' + parseInt( num );
  243. return str.substring( str.length - 2 );
  244. }
  245. })();
  246. </script>
  247. </body>
  248. </html>