slideparts 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +8 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +40 -0
  8. data/Rakefile +7 -0
  9. data/bin/slide +5 -0
  10. data/lib/slide_template/Guardfile +3 -0
  11. data/lib/slide_template/_layouts/default.html.erb +74 -0
  12. data/lib/slide_template/css/print/paper.css +202 -0
  13. data/lib/slide_template/css/print/pdf.css +157 -0
  14. data/lib/slide_template/css/reveal.css +1141 -0
  15. data/lib/slide_template/css/reveal.scss +1316 -0
  16. data/lib/slide_template/css/theme/README.md +25 -0
  17. data/lib/slide_template/css/theme/beige.css +265 -0
  18. data/lib/slide_template/css/theme/black.css +261 -0
  19. data/lib/slide_template/css/theme/blood.css +291 -0
  20. data/lib/slide_template/css/theme/league.css +267 -0
  21. data/lib/slide_template/css/theme/moon.css +265 -0
  22. data/lib/slide_template/css/theme/night.css +259 -0
  23. data/lib/slide_template/css/theme/serif.css +261 -0
  24. data/lib/slide_template/css/theme/simple.css +261 -0
  25. data/lib/slide_template/css/theme/sky.css +268 -0
  26. data/lib/slide_template/css/theme/solarized.css +265 -0
  27. data/lib/slide_template/css/theme/source/beige.scss +39 -0
  28. data/lib/slide_template/css/theme/source/black.scss +49 -0
  29. data/lib/slide_template/css/theme/source/blood.scss +91 -0
  30. data/lib/slide_template/css/theme/source/league.scss +34 -0
  31. data/lib/slide_template/css/theme/source/moon.scss +57 -0
  32. data/lib/slide_template/css/theme/source/night.scss +35 -0
  33. data/lib/slide_template/css/theme/source/serif.scss +35 -0
  34. data/lib/slide_template/css/theme/source/simple.scss +38 -0
  35. data/lib/slide_template/css/theme/source/sky.scss +46 -0
  36. data/lib/slide_template/css/theme/source/solarized.scss +63 -0
  37. data/lib/slide_template/css/theme/source/white.scss +49 -0
  38. data/lib/slide_template/css/theme/template/mixins.scss +29 -0
  39. data/lib/slide_template/css/theme/template/settings.scss +43 -0
  40. data/lib/slide_template/css/theme/template/theme.scss +339 -0
  41. data/lib/slide_template/css/theme/white.css +261 -0
  42. data/lib/slide_template/index.haml +5 -0
  43. data/lib/slide_template/js/reveal.js +4276 -0
  44. data/lib/slide_template/lib/css/zenburn.css +117 -0
  45. data/lib/slide_template/lib/font/league-gothic/LICENSE +2 -0
  46. data/lib/slide_template/lib/font/league-gothic/league-gothic.css +10 -0
  47. data/lib/slide_template/lib/font/league-gothic/league-gothic.eot +0 -0
  48. data/lib/slide_template/lib/font/league-gothic/league-gothic.ttf +0 -0
  49. data/lib/slide_template/lib/font/league-gothic/league-gothic.woff +0 -0
  50. data/lib/slide_template/lib/font/source-sans-pro/LICENSE +45 -0
  51. data/lib/slide_template/lib/font/source-sans-pro/source-sans-pro-italic.eot +0 -0
  52. data/lib/slide_template/lib/font/source-sans-pro/source-sans-pro-italic.ttf +0 -0
  53. data/lib/slide_template/lib/font/source-sans-pro/source-sans-pro-italic.woff +0 -0
  54. data/lib/slide_template/lib/font/source-sans-pro/source-sans-pro-regular.eot +0 -0
  55. data/lib/slide_template/lib/font/source-sans-pro/source-sans-pro-regular.ttf +0 -0
  56. data/lib/slide_template/lib/font/source-sans-pro/source-sans-pro-regular.woff +0 -0
  57. data/lib/slide_template/lib/font/source-sans-pro/source-sans-pro-semibold.eot +0 -0
  58. data/lib/slide_template/lib/font/source-sans-pro/source-sans-pro-semibold.ttf +0 -0
  59. data/lib/slide_template/lib/font/source-sans-pro/source-sans-pro-semibold.woff +0 -0
  60. data/lib/slide_template/lib/font/source-sans-pro/source-sans-pro-semibolditalic.eot +0 -0
  61. data/lib/slide_template/lib/font/source-sans-pro/source-sans-pro-semibolditalic.ttf +0 -0
  62. data/lib/slide_template/lib/font/source-sans-pro/source-sans-pro-semibolditalic.woff +0 -0
  63. data/lib/slide_template/lib/font/source-sans-pro/source-sans-pro.css +39 -0
  64. data/lib/slide_template/lib/js/classList.js +2 -0
  65. data/lib/slide_template/lib/js/head.min.js +8 -0
  66. data/lib/slide_template/lib/js/html5shiv.js +7 -0
  67. data/lib/slide_template/plugin/highlight/highlight.js +30 -0
  68. data/lib/slide_template/plugin/leap/leap.js +159 -0
  69. data/lib/slide_template/plugin/markdown/example.html +129 -0
  70. data/lib/slide_template/plugin/markdown/example.md +31 -0
  71. data/lib/slide_template/plugin/markdown/markdown.js +393 -0
  72. data/lib/slide_template/plugin/markdown/marked.js +37 -0
  73. data/lib/slide_template/plugin/math/math.js +64 -0
  74. data/lib/slide_template/plugin/multiplex/client.js +13 -0
  75. data/lib/slide_template/plugin/multiplex/index.js +56 -0
  76. data/lib/slide_template/plugin/multiplex/master.js +51 -0
  77. data/lib/slide_template/plugin/notes-server/client.js +60 -0
  78. data/lib/slide_template/plugin/notes-server/index.js +66 -0
  79. data/lib/slide_template/plugin/notes-server/notes.html +396 -0
  80. data/lib/slide_template/plugin/notes/notes.html +406 -0
  81. data/lib/slide_template/plugin/notes/notes.js +122 -0
  82. data/lib/slide_template/plugin/print-pdf/print-pdf.js +48 -0
  83. data/lib/slide_template/plugin/remotes/remotes.js +39 -0
  84. data/lib/slide_template/plugin/search/search.js +196 -0
  85. data/lib/slide_template/plugin/zoom-js/zoom.js +278 -0
  86. data/lib/slideparts.rb +20 -0
  87. data/lib/slideparts/command.rb +38 -0
  88. data/lib/slideparts/commands/build.rb +34 -0
  89. data/lib/slideparts/commands/new.rb +23 -0
  90. data/lib/slideparts/commands/server.rb +26 -0
  91. data/lib/slideparts/version.rb +3 -0
  92. data/slideparts.gemspec +24 -0
  93. data/spec/command_spec.rb +9 -0
  94. data/spec/spec_helper.rb +2 -0
  95. metadata +182 -0
@@ -0,0 +1,37 @@
1
+ /**
2
+ * marked - a markdown parser
3
+ * Copyright (c) 2011-2013, Christopher Jeffrey. (MIT Licensed)
4
+ * https://github.com/chjj/marked
5
+ */
6
+
7
+ (function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){3,} *\n*/,blockquote:/^( *>[^\n]+(\n[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
8
+ text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,"gm")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)("hr",/\n+(?=(?: *[-*_]){3,} *(?:\n+|$))/)();block._tag="(?!(?:"+"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code"+"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo"+"|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|@)\\b";block.html=replace(block.html)("comment",/\x3c!--[\s\S]*?--\x3e/)("closed",
9
+ /<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)("hr",block.hr)("heading",block.heading)("lheading",block.lheading)("blockquote",block.blockquote)("tag","<"+block._tag)("def",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/});block.gfm.paragraph=replace(block.paragraph)("(?!","(?!"+block.gfm.fences.source.replace("\\1",
10
+ "\\2")+"|")();block.tables=merge({},block.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm)if(this.options.tables)this.rules=block.tables;else this.rules=block.gfm}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)};
11
+ Lexer.prototype.lex=function(src){src=src.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(src,true)};Lexer.prototype.token=function(src,top){var src=src.replace(/^ +$/gm,""),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1)this.tokens.push({type:"space"})}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm,
12
+ "");this.tokens.push({type:"code",text:!this.options.pedantic?cap.replace(/\n+$/,""):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"code",lang:cap[2],text:cap[3]});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,
13
+ "").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/\n$/,"").split("\n")};for(i=0;i<item.align.length;i++)if(/^ *-+: *$/.test(item.align[i]))item.align[i]="right";else if(/^ *:-+: *$/.test(item.align[i]))item.align[i]="center";else if(/^ *:-+ *$/.test(item.align[i]))item.align[i]="left";else item.align[i]=null;for(i=0;i<item.cells.length;i++)item.cells[i]=item.cells[i].split(/ *\| */);this.tokens.push(item);continue}if(cap=this.rules.lheading.exec(src)){src=
14
+ src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[2]==="="?1:2,text:cap[1]});continue}if(cap=this.rules.hr.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"hr"});continue}if(cap=this.rules.blockquote.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"blockquote_start"});cap=cap[0].replace(/^ *> ?/gm,"");this.token(cap,top);this.tokens.push({type:"blockquote_end"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length);
15
+ bull=cap[2];this.tokens.push({type:"list_start",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i<l;i++){item=cap[i];space=item.length;item=item.replace(/^ *([*+-]|\d+\.) +/,"");if(~item.indexOf("\n ")){space-=item.length;item=!this.options.pedantic?item.replace(new RegExp("^ {1,"+space+"}","gm"),""):item.replace(/^ {1,4}/gm,"")}if(this.options.smartLists&&i!==l-1){b=block.bullet.exec(cap[i+1])[0];if(bull!==b&&!(bull.length>1&&b.length>1)){src=cap.slice(i+
16
+ 1).join("\n")+src;i=l-1}}loose=next||/\n\n(?!\s*$)/.test(item);if(i!==l-1){next=item[item.length-1]==="\n";if(!loose)loose=next}this.tokens.push({type:loose?"loose_item_start":"list_item_start"});this.token(item,false);this.tokens.push({type:"list_item_end"})}this.tokens.push({type:"list_end"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:cap[1]==="pre"||cap[1]==="script",text:cap[0]});continue}if(top&&
17
+ (cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(i=0;i<item.align.length;i++)if(/^ *-+: *$/.test(item.align[i]))item.align[i]="right";else if(/^ *:-+: *$/.test(item.align[i]))item.align[i]=
18
+ "center";else if(/^ *:-+ *$/.test(item.align[i]))item.align[i]="left";else item.align[i]=null;for(i=0;i<item.cells.length;i++)item.cells[i]=item.cells[i].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(item);continue}if(top&&(cap=this.rules.paragraph.exec(src))){src=src.substring(cap[0].length);this.tokens.push({type:"paragraph",text:cap[1][cap[1].length-1]==="\n"?cap[1].slice(0,-1):cap[1]});continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"text",
19
+ text:cap[0]});continue}if(src)throw new Error("Infinite loop on byte: "+src.charCodeAt(0));}return this.tokens};var inline={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:noop,tag:/^\x3c!--[\s\S]*?--\x3e|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
20
+ code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:noop,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};inline._inside=/(?:\[[^\]]*\]|[^\]]|\](?=[^\[]*\]))*/;inline._href=/\s*<?([^\s]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;inline.link=replace(inline.link)("inside",inline._inside)("href",inline._href)();inline.reflink=replace(inline.reflink)("inside",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
21
+ em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:replace(inline.text)("]|","~]|")("|","|https?://|")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)("{2,}","*")(),text:replace(inline.gfm.text)("{2,}","*")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal;
22
+ if(!this.links)throw new Error("Tokens array requires a `links` property.");if(this.options.gfm)if(this.options.breaks)this.rules=inline.breaks;else this.rules=inline.gfm;else if(this.options.pedantic)this.rules=inline.pedantic}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out="",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length);
23
+ out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]==="@"){text=cap[1][6]===":"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle("mailto:")+text}else{text=escape(cap[1]);href=text}out+='<a href="'+href+'">'+text+"</a>";continue}if(cap=this.rules.url.exec(src)){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+='<a href="'+href+'">'+text+"</a>";continue}if(cap=this.rules.tag.exec(src)){src=src.substring(cap[0].length);
24
+ out+=this.options.sanitize?escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);out+=this.outputLink(cap,{href:cap[2],title:cap[3]});continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/\s+/g," ");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0][0];src=cap[0].substring(1)+src;continue}out+=this.outputLink(cap,link);continue}if(cap=this.rules.strong.exec(src)){src=
25
+ src.substring(cap[0].length);out+="<strong>"+this.output(cap[2]||cap[1])+"</strong>";continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+="<em>"+this.output(cap[2]||cap[1])+"</em>";continue}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+="<code>"+escape(cap[2],true)+"</code>";continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+="<br>";continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+="<del>"+
26
+ this.output(cap[1])+"</del>";continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=escape(cap[0]);continue}if(src)throw new Error("Infinite loop on byte: "+src.charCodeAt(0));}return out};InlineLexer.prototype.outputLink=function(cap,link){if(cap[0][0]!=="!")return'<a href="'+escape(link.href)+'"'+(link.title?' title="'+escape(link.title)+'"':"")+">"+this.output(cap[1])+"</a>";else return'<img src="'+escape(link.href)+'" alt="'+escape(cap[1])+'"'+(link.title?' title="'+
27
+ escape(link.title)+'"':"")+">"};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants)return text;return text.replace(/--/g,"\u2014").replace(/'([^']*)'/g,"\u2018$1\u2019").replace(/"([^"]*)"/g,"\u201c$1\u201d").replace(/\.{3}/g,"\u2026")};InlineLexer.prototype.mangle=function(text){var out="",l=text.length,i=0,ch;for(;i<l;i++){ch=text.charCodeAt(i);if(Math.random()>0.5)ch="x"+ch.toString(16);out+="&#"+ch+";"}return out};function Parser(options){this.tokens=[];this.token=null;
28
+ this.options=options||marked.defaults}Parser.parse=function(src,options){var parser=new Parser(options);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options);this.tokens=src.reverse();var out="";while(this.next())out+=this.tok();return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;
29
+ while(this.peek().type==="text")body+="\n"+this.next().text;return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case "space":return"";case "hr":return"<hr>\n";case "heading":return"<h"+this.token.depth+">"+this.inline.output(this.token.text)+"</h"+this.token.depth+">\n";case "code":if(this.options.highlight){var code=this.options.highlight(this.token.text,this.token.lang);if(code!=null&&code!==this.token.text){this.token.escaped=true;this.token.text=code}}if(!this.token.escaped)this.token.text=
30
+ escape(this.token.text,true);return"<pre><code"+(this.token.lang?' class="'+this.options.langPrefix+this.token.lang+'"':"")+">"+this.token.text+"</code></pre>\n";case "table":var body="",heading,i,row,cell,j;body+="<thead>\n<tr>\n";for(i=0;i<this.token.header.length;i++){heading=this.inline.output(this.token.header[i]);body+=this.token.align[i]?'<th align="'+this.token.align[i]+'">'+heading+"</th>\n":"<th>"+heading+"</th>\n"}body+="</tr>\n</thead>\n";body+="<tbody>\n";for(i=0;i<this.token.cells.length;i++){row=
31
+ this.token.cells[i];body+="<tr>\n";for(j=0;j<row.length;j++){cell=this.inline.output(row[j]);body+=this.token.align[j]?'<td align="'+this.token.align[j]+'">'+cell+"</td>\n":"<td>"+cell+"</td>\n"}body+="</tr>\n"}body+="</tbody>\n";return"<table>\n"+body+"</table>\n";case "blockquote_start":var body="";while(this.next().type!=="blockquote_end")body+=this.tok();return"<blockquote>\n"+body+"</blockquote>\n";case "list_start":var type=this.token.ordered?"ol":"ul",body="";while(this.next().type!=="list_end")body+=
32
+ this.tok();return"<"+type+">\n"+body+"</"+type+">\n";case "list_item_start":var body="";while(this.next().type!=="list_item_end")body+=this.token.type==="text"?this.parseText():this.tok();return"<li>"+body+"</li>\n";case "loose_item_start":var body="";while(this.next().type!=="list_item_end")body+=this.tok();return"<li>"+body+"</li>\n";case "html":return!this.token.pre&&!this.options.pedantic?this.inline.output(this.token.text):this.token.text;case "paragraph":return"<p>"+this.inline.output(this.token.text)+
33
+ "</p>\n";case "text":return"<p>"+this.parseText()+"</p>\n"}};function escape(html,encode){return html.replace(!encode?/&(?!#?\w+;)/g:/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function replace(regex,opt){regex=regex.source;opt=opt||"";return function self(name,val){if(!name)return new RegExp(regex,opt);val=val.source||val;val=val.replace(/(^|[^\[])\^/g,"$1");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i=
34
+ 1,target,key;for(;i<arguments.length;i++){target=arguments[i];for(key in target)if(Object.prototype.hasOwnProperty.call(target,key))obj[key]=target[key]}return obj}function marked(src,opt,callback){if(callback||typeof opt==="function"){if(!callback){callback=opt;opt=null}if(opt)opt=merge({},marked.defaults,opt);var tokens=Lexer.lex(tokens,opt),highlight=opt.highlight,pending=0,l=tokens.length,i=0;if(!highlight||highlight.length<3)return callback(null,Parser.parse(tokens,opt));var done=function(){delete opt.highlight;
35
+ var out=Parser.parse(tokens,opt);opt.highlight=highlight;return callback(null,out)};for(;i<l;i++)(function(token){if(token.type!=="code")return;pending++;return highlight(token.text,token.lang,function(err,code){if(code==null||code===token.text)return--pending||done();token.text=code;token.escaped=true;--pending||done()})})(tokens[i]);return}try{if(opt)opt=merge({},marked.defaults,opt);return Parser.parse(Lexer.lex(src,opt),opt)}catch(e){e.message+="\nPlease report this to https://github.com/chjj/marked.";
36
+ if((opt||marked.defaults).silent)return"<p>An error occured:</p><pre>"+escape(e.message+"",true)+"</pre>";throw e;}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,smartLists:false,silent:false,highlight:null,langPrefix:""};marked.Parser=Parser;marked.parser=Parser.parse;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;
37
+ marked.parse=marked;if(typeof exports==="object")module.exports=marked;else if(typeof define==="function"&&define.amd)define(function(){return marked});else this.marked=marked}).call(function(){return this||(typeof window!=="undefined"?window:global)}());
@@ -0,0 +1,64 @@
1
+ /**
2
+ * A plugin which enables rendering of math equations inside
3
+ * of reveal.js slides. Essentially a thin wrapper for MathJax.
4
+ *
5
+ * @author Hakim El Hattab
6
+ */
7
+ var RevealMath = window.RevealMath || (function(){
8
+
9
+ var options = Reveal.getConfig().math || {};
10
+ options.mathjax = options.mathjax || 'http://cdn.mathjax.org/mathjax/latest/MathJax.js';
11
+ options.config = options.config || 'TeX-AMS_HTML-full';
12
+
13
+ loadScript( options.mathjax + '?config=' + options.config, function() {
14
+
15
+ MathJax.Hub.Config({
16
+ messageStyle: 'none',
17
+ tex2jax: { inlineMath: [['$','$'],['\\(','\\)']] },
18
+ skipStartupTypeset: true
19
+ });
20
+
21
+ // Typeset followed by an immediate reveal.js layout since
22
+ // the typesetting process could affect slide height
23
+ MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub ] );
24
+ MathJax.Hub.Queue( Reveal.layout );
25
+
26
+ // Reprocess equations in slides when they turn visible
27
+ Reveal.addEventListener( 'slidechanged', function( event ) {
28
+
29
+ MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, event.currentSlide ] );
30
+
31
+ } );
32
+
33
+ } );
34
+
35
+ function loadScript( url, callback ) {
36
+
37
+ var head = document.querySelector( 'head' );
38
+ var script = document.createElement( 'script' );
39
+ script.type = 'text/javascript';
40
+ script.src = url;
41
+
42
+ // Wrapper for callback to make sure it only fires once
43
+ var finish = function() {
44
+ if( typeof callback === 'function' ) {
45
+ callback.call();
46
+ callback = null;
47
+ }
48
+ }
49
+
50
+ script.onload = finish;
51
+
52
+ // IE
53
+ script.onreadystatechange = function() {
54
+ if ( this.readyState === 'loaded' ) {
55
+ finish();
56
+ }
57
+ }
58
+
59
+ // Normal browsers
60
+ head.appendChild( script );
61
+
62
+ }
63
+
64
+ })();
@@ -0,0 +1,13 @@
1
+ (function() {
2
+ var multiplex = Reveal.getConfig().multiplex;
3
+ var socketId = multiplex.id;
4
+ var socket = io.connect(multiplex.url);
5
+
6
+ socket.on(multiplex.id, function(data) {
7
+ // ignore data from sockets that aren't ours
8
+ if (data.socketId !== socketId) { return; }
9
+ if( window.location.host === 'localhost:1947' ) return;
10
+
11
+ Reveal.slide(data.indexh, data.indexv, data.indexf, 'remote');
12
+ });
13
+ }());
@@ -0,0 +1,56 @@
1
+ var express = require('express');
2
+ var fs = require('fs');
3
+ var io = require('socket.io');
4
+ var crypto = require('crypto');
5
+
6
+ var app = express.createServer();
7
+ var staticDir = express.static;
8
+
9
+ io = io.listen(app);
10
+
11
+ var opts = {
12
+ port: 1948,
13
+ baseDir : __dirname + '/../../'
14
+ };
15
+
16
+ io.sockets.on('connection', function(socket) {
17
+ socket.on('slidechanged', function(slideData) {
18
+ if (typeof slideData.secret == 'undefined' || slideData.secret == null || slideData.secret === '') return;
19
+ if (createHash(slideData.secret) === slideData.socketId) {
20
+ slideData.secret = null;
21
+ socket.broadcast.emit(slideData.socketId, slideData);
22
+ };
23
+ });
24
+ });
25
+
26
+ app.configure(function() {
27
+ [ 'css', 'js', 'plugin', 'lib' ].forEach(function(dir) {
28
+ app.use('/' + dir, staticDir(opts.baseDir + dir));
29
+ });
30
+ });
31
+
32
+ app.get("/", function(req, res) {
33
+ res.writeHead(200, {'Content-Type': 'text/html'});
34
+ fs.createReadStream(opts.baseDir + '/index.html').pipe(res);
35
+ });
36
+
37
+ app.get("/token", function(req,res) {
38
+ var ts = new Date().getTime();
39
+ var rand = Math.floor(Math.random()*9999999);
40
+ var secret = ts.toString() + rand.toString();
41
+ res.send({secret: secret, socketId: createHash(secret)});
42
+ });
43
+
44
+ var createHash = function(secret) {
45
+ var cipher = crypto.createCipher('blowfish', secret);
46
+ return(cipher.final('hex'));
47
+ };
48
+
49
+ // Actually listen
50
+ app.listen(opts.port || null);
51
+
52
+ var brown = '\033[33m',
53
+ green = '\033[32m',
54
+ reset = '\033[0m';
55
+
56
+ console.log( brown + "reveal.js:" + reset + " Multiplex running on port " + green + opts.port + reset );
@@ -0,0 +1,51 @@
1
+ (function() {
2
+ // Don't emit events from inside of notes windows
3
+ if ( window.location.search.match( /receiver/gi ) ) { return; }
4
+
5
+ var multiplex = Reveal.getConfig().multiplex;
6
+
7
+ var socket = io.connect(multiplex.url);
8
+
9
+ var notify = function( slideElement, indexh, indexv, origin ) {
10
+ if( typeof origin === 'undefined' && origin !== 'remote' ) {
11
+ var nextindexh;
12
+ var nextindexv;
13
+
14
+ var fragmentindex = Reveal.getIndices().f;
15
+ if (typeof fragmentindex == 'undefined') {
16
+ fragmentindex = 0;
17
+ }
18
+
19
+ if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') {
20
+ nextindexh = indexh;
21
+ nextindexv = indexv + 1;
22
+ } else {
23
+ nextindexh = indexh + 1;
24
+ nextindexv = 0;
25
+ }
26
+
27
+ var slideData = {
28
+ indexh : indexh,
29
+ indexv : indexv,
30
+ indexf : fragmentindex,
31
+ nextindexh : nextindexh,
32
+ nextindexv : nextindexv,
33
+ secret: multiplex.secret,
34
+ socketId : multiplex.id
35
+ };
36
+
37
+ socket.emit('slidechanged', slideData);
38
+ }
39
+ }
40
+
41
+ Reveal.addEventListener( 'slidechanged', function( event ) {
42
+ notify( event.currentSlide, event.indexh, event.indexv, event.origin );
43
+ } );
44
+
45
+ var fragmentNotify = function( event ) {
46
+ notify( Reveal.getCurrentSlide(), Reveal.getIndices().h, Reveal.getIndices().v, event.origin );
47
+ };
48
+
49
+ Reveal.addEventListener( 'fragmentshown', fragmentNotify );
50
+ Reveal.addEventListener( 'fragmenthidden', fragmentNotify );
51
+ }());
@@ -0,0 +1,60 @@
1
+ (function() {
2
+
3
+ // don't emit events from inside the previews themselves
4
+ if( window.location.search.match( /receiver/gi ) ) { return; }
5
+
6
+ var socket = io.connect( window.location.origin ),
7
+ socketId = Math.random().toString().slice( 2 );
8
+
9
+ console.log( 'View slide notes at ' + window.location.origin + '/notes/' + socketId );
10
+
11
+ window.open( window.location.origin + '/notes/' + socketId, 'notes-' + socketId );
12
+
13
+ /**
14
+ * Posts the current slide data to the notes window
15
+ */
16
+ function post() {
17
+
18
+ var slideElement = Reveal.getCurrentSlide(),
19
+ notesElement = slideElement.querySelector( 'aside.notes' );
20
+
21
+ var messageData = {
22
+ notes: '',
23
+ markdown: false,
24
+ socketId: socketId,
25
+ state: Reveal.getState()
26
+ };
27
+
28
+ // Look for notes defined in a slide attribute
29
+ if( slideElement.hasAttribute( 'data-notes' ) ) {
30
+ messageData.notes = slideElement.getAttribute( 'data-notes' );
31
+ }
32
+
33
+ // Look for notes defined in an aside element
34
+ if( notesElement ) {
35
+ messageData.notes = notesElement.innerHTML;
36
+ messageData.markdown = typeof notesElement.getAttribute( 'data-markdown' ) === 'string';
37
+ }
38
+
39
+ socket.emit( 'statechanged', messageData );
40
+
41
+ }
42
+
43
+ // When a new notes window connects, post our current state
44
+ socket.on( 'connect', function( data ) {
45
+ post();
46
+ } );
47
+
48
+ // Monitor events that trigger a change in state
49
+ Reveal.addEventListener( 'slidechanged', post );
50
+ Reveal.addEventListener( 'fragmentshown', post );
51
+ Reveal.addEventListener( 'fragmenthidden', post );
52
+ Reveal.addEventListener( 'overviewhidden', post );
53
+ Reveal.addEventListener( 'overviewshown', post );
54
+ Reveal.addEventListener( 'paused', post );
55
+ Reveal.addEventListener( 'resumed', post );
56
+
57
+ // Post the initial state
58
+ post();
59
+
60
+ }());
@@ -0,0 +1,66 @@
1
+ var express = require('express');
2
+ var fs = require('fs');
3
+ var io = require('socket.io');
4
+ var _ = require('underscore');
5
+ var Mustache = require('mustache');
6
+
7
+ var app = express.createServer();
8
+ var staticDir = express.static;
9
+
10
+ io = io.listen(app);
11
+
12
+ var opts = {
13
+ port : 1947,
14
+ baseDir : __dirname + '/../../'
15
+ };
16
+
17
+ io.sockets.on( 'connection', function( socket ) {
18
+
19
+ socket.on( 'connect', function( data ) {
20
+ socket.broadcast.emit( 'connect', data );
21
+ });
22
+
23
+ socket.on( 'statechanged', function( data ) {
24
+ socket.broadcast.emit( 'statechanged', data );
25
+ });
26
+
27
+ });
28
+
29
+ app.configure( function() {
30
+
31
+ [ 'css', 'js', 'images', 'plugin', 'lib' ].forEach( function( dir ) {
32
+ app.use( '/' + dir, staticDir( opts.baseDir + dir ) );
33
+ });
34
+
35
+ });
36
+
37
+ app.get('/', function( req, res ) {
38
+
39
+ res.writeHead( 200, { 'Content-Type': 'text/html' } );
40
+ fs.createReadStream( opts.baseDir + '/index.html' ).pipe( res );
41
+
42
+ });
43
+
44
+ app.get( '/notes/:socketId', function( req, res ) {
45
+
46
+ fs.readFile( opts.baseDir + 'plugin/notes-server/notes.html', function( err, data ) {
47
+ res.send( Mustache.to_html( data.toString(), {
48
+ socketId : req.params.socketId
49
+ }));
50
+ });
51
+
52
+ });
53
+
54
+ // Actually listen
55
+ app.listen( opts.port || null );
56
+
57
+ var brown = '\033[33m',
58
+ green = '\033[32m',
59
+ reset = '\033[0m';
60
+
61
+ var slidesLocation = 'http://localhost' + ( opts.port ? ( ':' + opts.port ) : '' );
62
+
63
+ console.log( brown + 'reveal.js - Speaker Notes' + reset );
64
+ console.log( '1. Open the slides at ' + green + slidesLocation + reset );
65
+ console.log( '2. Click on the link your JS console to go to the notes page' );
66
+ console.log( '3. Advance through your slides and your notes will advance automatically' );
@@ -0,0 +1,396 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+
6
+ <title>reveal.js - Slide Notes</title>
7
+
8
+ <style>
9
+ body {
10
+ font-family: Helvetica;
11
+ }
12
+
13
+ #current-slide,
14
+ #upcoming-slide,
15
+ #speaker-controls {
16
+ padding: 6px;
17
+ box-sizing: border-box;
18
+ -moz-box-sizing: border-box;
19
+ }
20
+
21
+ #current-slide iframe,
22
+ #upcoming-slide iframe {
23
+ width: 100%;
24
+ height: 100%;
25
+ border: 1px solid #ddd;
26
+ }
27
+
28
+ #current-slide .label,
29
+ #upcoming-slide .label {
30
+ position: absolute;
31
+ top: 10px;
32
+ left: 10px;
33
+ font-weight: bold;
34
+ font-size: 14px;
35
+ z-index: 2;
36
+ color: rgba( 255, 255, 255, 0.9 );
37
+ }
38
+
39
+ #current-slide {
40
+ position: absolute;
41
+ width: 65%;
42
+ height: 100%;
43
+ top: 0;
44
+ left: 0;
45
+ padding-right: 0;
46
+ }
47
+
48
+ #upcoming-slide {
49
+ position: absolute;
50
+ width: 35%;
51
+ height: 40%;
52
+ right: 0;
53
+ top: 0;
54
+ }
55
+
56
+ #speaker-controls {
57
+ position: absolute;
58
+ top: 40%;
59
+ right: 0;
60
+ width: 35%;
61
+ height: 60%;
62
+
63
+ font-size: 18px;
64
+ }
65
+
66
+ .speaker-controls-time.hidden,
67
+ .speaker-controls-notes.hidden {
68
+ display: none;
69
+ }
70
+
71
+ .speaker-controls-time .label,
72
+ .speaker-controls-notes .label {
73
+ text-transform: uppercase;
74
+ font-weight: normal;
75
+ font-size: 0.66em;
76
+ color: #666;
77
+ margin: 0;
78
+ }
79
+
80
+ .speaker-controls-time {
81
+ border-bottom: 1px solid rgba( 200, 200, 200, 0.5 );
82
+ margin-bottom: 10px;
83
+ padding: 10px 16px;
84
+ padding-bottom: 20px;
85
+ cursor: pointer;
86
+ }
87
+
88
+ .speaker-controls-time .reset-button {
89
+ opacity: 0;
90
+ float: right;
91
+ color: #666;
92
+ text-decoration: none;
93
+ }
94
+ .speaker-controls-time:hover .reset-button {
95
+ opacity: 1;
96
+ }
97
+
98
+ .speaker-controls-time .timer,
99
+ .speaker-controls-time .clock {
100
+ width: 50%;
101
+ font-size: 1.9em;
102
+ }
103
+
104
+ .speaker-controls-time .timer {
105
+ float: left;
106
+ }
107
+
108
+ .speaker-controls-time .clock {
109
+ float: right;
110
+ text-align: right;
111
+ }
112
+
113
+ .speaker-controls-time span.mute {
114
+ color: #bbb;
115
+ }
116
+
117
+ .speaker-controls-notes {
118
+ padding: 10px 16px;
119
+ }
120
+
121
+ .speaker-controls-notes .value {
122
+ margin-top: 5px;
123
+ line-height: 1.4;
124
+ font-size: 1.2em;
125
+ }
126
+
127
+ .clear {
128
+ clear: both;
129
+ }
130
+
131
+ @media screen and (max-width: 1080px) {
132
+ #speaker-controls {
133
+ font-size: 16px;
134
+ }
135
+ }
136
+
137
+ @media screen and (max-width: 900px) {
138
+ #speaker-controls {
139
+ font-size: 14px;
140
+ }
141
+ }
142
+
143
+ @media screen and (max-width: 800px) {
144
+ #speaker-controls {
145
+ font-size: 12px;
146
+ }
147
+ }
148
+
149
+ </style>
150
+ </head>
151
+
152
+ <body>
153
+
154
+ <div id="current-slide"></div>
155
+ <div id="upcoming-slide"><span class="label">UPCOMING:</span></div>
156
+ <div id="speaker-controls">
157
+ <div class="speaker-controls-time">
158
+ <h4 class="label">Time <span class="reset-button">Click to Reset</span></h4>
159
+ <div class="clock">
160
+ <span class="clock-value">0:00 AM</span>
161
+ </div>
162
+ <div class="timer">
163
+ <span class="hours-value">00</span><span class="minutes-value">:00</span><span class="seconds-value">:00</span>
164
+ </div>
165
+ <div class="clear"></div>
166
+ </div>
167
+
168
+ <div class="speaker-controls-notes hidden">
169
+ <h4 class="label">Notes</h4>
170
+ <div class="value"></div>
171
+ </div>
172
+ </div>
173
+
174
+ <script src="/socket.io/socket.io.js"></script>
175
+ <script src="/plugin/markdown/marked.js"></script>
176
+
177
+ <script>
178
+ (function() {
179
+
180
+ var notes,
181
+ notesValue,
182
+ currentState,
183
+ currentSlide,
184
+ upcomingSlide,
185
+ connected = false;
186
+
187
+ var socket = io.connect( window.location.origin ),
188
+ socketId = '{{socketId}}';
189
+
190
+ socket.on( 'statechanged', function( data ) {
191
+
192
+ // ignore data from sockets that aren't ours
193
+ if( data.socketId !== socketId ) { return; }
194
+
195
+ if( connected === false ) {
196
+ connected = true;
197
+
198
+ setupIframes( data );
199
+ setupKeyboard();
200
+ setupNotes();
201
+ setupTimer();
202
+
203
+ }
204
+
205
+ handleStateMessage( data );
206
+
207
+ } );
208
+
209
+ window.addEventListener( 'message', function( event ) {
210
+
211
+ var data = JSON.parse( event.data );
212
+
213
+ if( data && data.namespace === 'reveal' ) {
214
+ if( /ready/.test( data.eventName ) ) {
215
+ socket.emit( 'connect', { socketId: socketId } );
216
+ }
217
+ }
218
+
219
+ } );
220
+
221
+ /**
222
+ * Called when the main window sends an updated state.
223
+ */
224
+ function handleStateMessage( data ) {
225
+
226
+ // Store the most recently set state to avoid circular loops
227
+ // applying the same state
228
+ currentState = JSON.stringify( data.state );
229
+
230
+ // No need for updating the notes in case of fragment changes
231
+ if ( data.notes ) {
232
+ notes.classList.remove( 'hidden' );
233
+ if( data.markdown ) {
234
+ notesValue.innerHTML = marked( data.notes );
235
+ }
236
+ else {
237
+ notesValue.innerHTML = data.notes;
238
+ }
239
+ }
240
+ else {
241
+ notes.classList.add( 'hidden' );
242
+ }
243
+
244
+ // Update the note slides
245
+ currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'setState', args: [ data.state ] }), '*' );
246
+ upcomingSlide.contentWindow.postMessage( JSON.stringify({ method: 'setState', args: [ data.state ] }), '*' );
247
+ upcomingSlide.contentWindow.postMessage( JSON.stringify({ method: 'next' }), '*' );
248
+
249
+ }
250
+
251
+ // Limit to max one state update per X ms
252
+ handleStateMessage = debounce( handleStateMessage, 200 );
253
+
254
+ /**
255
+ * Forward keyboard events to the current slide window.
256
+ * This enables keyboard events to work even if focus
257
+ * isn't set on the current slide iframe.
258
+ */
259
+ function setupKeyboard() {
260
+
261
+ document.addEventListener( 'keydown', function( event ) {
262
+ currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'triggerKey', args: [ event.keyCode ] }), '*' );
263
+ } );
264
+
265
+ }
266
+
267
+ /**
268
+ * Creates the preview iframes.
269
+ */
270
+ function setupIframes( data ) {
271
+
272
+ var params = [
273
+ 'receiver',
274
+ 'progress=false',
275
+ 'history=false',
276
+ 'transition=none',
277
+ 'backgroundTransition=none'
278
+ ].join( '&' );
279
+
280
+ var hash = '#/' + data.state.indexh + '/' + data.state.indexv;
281
+ var currentURL = '/?' + params + '&postMessageEvents=true' + hash;
282
+ var upcomingURL = '/?' + params + '&controls=false' + hash;
283
+
284
+ currentSlide = document.createElement( 'iframe' );
285
+ currentSlide.setAttribute( 'width', 1280 );
286
+ currentSlide.setAttribute( 'height', 1024 );
287
+ currentSlide.setAttribute( 'src', currentURL );
288
+ document.querySelector( '#current-slide' ).appendChild( currentSlide );
289
+
290
+ upcomingSlide = document.createElement( 'iframe' );
291
+ upcomingSlide.setAttribute( 'width', 640 );
292
+ upcomingSlide.setAttribute( 'height', 512 );
293
+ upcomingSlide.setAttribute( 'src', upcomingURL );
294
+ document.querySelector( '#upcoming-slide' ).appendChild( upcomingSlide );
295
+
296
+ }
297
+
298
+ /**
299
+ * Setup the notes UI.
300
+ */
301
+ function setupNotes() {
302
+
303
+ notes = document.querySelector( '.speaker-controls-notes' );
304
+ notesValue = document.querySelector( '.speaker-controls-notes .value' );
305
+
306
+ }
307
+
308
+ /**
309
+ * Create the timer and clock and start updating them
310
+ * at an interval.
311
+ */
312
+ function setupTimer() {
313
+
314
+ var start = new Date(),
315
+ timeEl = document.querySelector( '.speaker-controls-time' ),
316
+ clockEl = timeEl.querySelector( '.clock-value' ),
317
+ hoursEl = timeEl.querySelector( '.hours-value' ),
318
+ minutesEl = timeEl.querySelector( '.minutes-value' ),
319
+ secondsEl = timeEl.querySelector( '.seconds-value' );
320
+
321
+ function _updateTimer() {
322
+
323
+ var diff, hours, minutes, seconds,
324
+ now = new Date();
325
+
326
+ diff = now.getTime() - start.getTime();
327
+ hours = Math.floor( diff / ( 1000 * 60 * 60 ) );
328
+ minutes = Math.floor( ( diff / ( 1000 * 60 ) ) % 60 );
329
+ seconds = Math.floor( ( diff / 1000 ) % 60 );
330
+
331
+ clockEl.innerHTML = now.toLocaleTimeString( 'en-US', { hour12: true, hour: '2-digit', minute:'2-digit' } );
332
+ hoursEl.innerHTML = zeroPadInteger( hours );
333
+ hoursEl.className = hours > 0 ? '' : 'mute';
334
+ minutesEl.innerHTML = ':' + zeroPadInteger( minutes );
335
+ minutesEl.className = minutes > 0 ? '' : 'mute';
336
+ secondsEl.innerHTML = ':' + zeroPadInteger( seconds );
337
+
338
+ }
339
+
340
+ // Update once directly
341
+ _updateTimer();
342
+
343
+ // Then update every second
344
+ setInterval( _updateTimer, 1000 );
345
+
346
+ timeEl.addEventListener( 'click', function() {
347
+ start = new Date();
348
+ _updateTimer();
349
+ return false;
350
+ } );
351
+
352
+ }
353
+
354
+ function zeroPadInteger( num ) {
355
+
356
+ var str = '00' + parseInt( num );
357
+ return str.substring( str.length - 2 );
358
+
359
+ }
360
+
361
+ /**
362
+ * Limits the frequency at which a function can be called.
363
+ */
364
+ function debounce( fn, ms ) {
365
+
366
+ var lastTime = 0,
367
+ timeout;
368
+
369
+ return function() {
370
+
371
+ var args = arguments;
372
+ var context = this;
373
+
374
+ clearTimeout( timeout );
375
+
376
+ var timeSinceLastCall = Date.now() - lastTime;
377
+ if( timeSinceLastCall > ms ) {
378
+ fn.apply( context, args );
379
+ lastTime = Date.now();
380
+ }
381
+ else {
382
+ timeout = setTimeout( function() {
383
+ fn.apply( context, args );
384
+ lastTime = Date.now();
385
+ }, ms - timeSinceLastCall );
386
+ }
387
+
388
+ }
389
+
390
+ }
391
+
392
+ })();
393
+ </script>
394
+
395
+ </body>
396
+ </html>