mattmatt-showoff 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +280 -0
  3. data/Rakefile +15 -0
  4. data/bin/showoff +115 -0
  5. data/lib/princely.rb +84 -0
  6. data/lib/showoff.rb +346 -0
  7. data/lib/showoff_utils.rb +259 -0
  8. data/public/css/fg.menu.css +114 -0
  9. data/public/css/onepage.css +44 -0
  10. data/public/css/pdf.css +12 -0
  11. data/public/css/reset.css +53 -0
  12. data/public/css/sh_style.css +66 -0
  13. data/public/css/showoff.css +258 -0
  14. data/public/css/spinner_bar.gif +0 -0
  15. data/public/css/theme/images/ui-bg_diagonals-small_100_f0efea_40x40.png +0 -0
  16. data/public/css/theme/images/ui-bg_flat_35_f0f0f0_40x100.png +0 -0
  17. data/public/css/theme/images/ui-bg_glass_55_fcf0ba_1x400.png +0 -0
  18. data/public/css/theme/images/ui-bg_glow-ball_25_2e2e28_600x600.png +0 -0
  19. data/public/css/theme/images/ui-bg_highlight-soft_100_f0efea_1x100.png +0 -0
  20. data/public/css/theme/images/ui-bg_highlight-soft_25_327E04_1x100.png +0 -0
  21. data/public/css/theme/images/ui-bg_highlight-soft_25_5A9D1A_1x100.png +0 -0
  22. data/public/css/theme/images/ui-bg_highlight-soft_95_ffedad_1x100.png +0 -0
  23. data/public/css/theme/images/ui-bg_inset-soft_22_3b3b35_1x100.png +0 -0
  24. data/public/css/theme/images/ui-icons_808080_256x240.png +0 -0
  25. data/public/css/theme/images/ui-icons_8DC262_256x240.png +0 -0
  26. data/public/css/theme/images/ui-icons_cd0a0a_256x240.png +0 -0
  27. data/public/css/theme/images/ui-icons_e7e6e4_256x240.png +0 -0
  28. data/public/css/theme/images/ui-icons_eeeeee_256x240.png +0 -0
  29. data/public/css/theme/images/ui-icons_ffffff_256x240.png +0 -0
  30. data/public/css/theme/ui.accordion.css +9 -0
  31. data/public/css/theme/ui.all.css +2 -0
  32. data/public/css/theme/ui.base.css +9 -0
  33. data/public/css/theme/ui.core.css +37 -0
  34. data/public/css/theme/ui.datepicker.css +62 -0
  35. data/public/css/theme/ui.dialog.css +13 -0
  36. data/public/css/theme/ui.progressbar.css +4 -0
  37. data/public/css/theme/ui.resizable.css +13 -0
  38. data/public/css/theme/ui.slider.css +17 -0
  39. data/public/css/theme/ui.tabs.css +9 -0
  40. data/public/css/theme/ui.theme.css +245 -0
  41. data/public/favicon.ico +0 -0
  42. data/public/js/fg.menu.js +645 -0
  43. data/public/js/jTypeWriter.js +26 -0
  44. data/public/js/jquery-1.4.min.js +151 -0
  45. data/public/js/jquery-print.js +109 -0
  46. data/public/js/jquery.batchImageLoad.js +56 -0
  47. data/public/js/jquery.cookie.js +96 -0
  48. data/public/js/jquery.cycle.all.js +1284 -0
  49. data/public/js/jquery.doubletap-0.1.js +105 -0
  50. data/public/js/jquery.uuid.js +24 -0
  51. data/public/js/jquery.ws-0.3pre.js +201 -0
  52. data/public/js/onepage.js +5 -0
  53. data/public/js/sh_lang/sh_bison.min.js +1 -0
  54. data/public/js/sh_lang/sh_c.min.js +1 -0
  55. data/public/js/sh_lang/sh_caml.min.js +1 -0
  56. data/public/js/sh_lang/sh_changelog.min.js +1 -0
  57. data/public/js/sh_lang/sh_cpp.min.js +1 -0
  58. data/public/js/sh_lang/sh_csharp.min.js +1 -0
  59. data/public/js/sh_lang/sh_css.min.js +1 -0
  60. data/public/js/sh_lang/sh_desktop.min.js +1 -0
  61. data/public/js/sh_lang/sh_diff.min.js +1 -0
  62. data/public/js/sh_lang/sh_flex.min.js +1 -0
  63. data/public/js/sh_lang/sh_glsl.min.js +1 -0
  64. data/public/js/sh_lang/sh_haxe.min.js +1 -0
  65. data/public/js/sh_lang/sh_html.min.js +1 -0
  66. data/public/js/sh_lang/sh_java.min.js +1 -0
  67. data/public/js/sh_lang/sh_javascript.min.js +1 -0
  68. data/public/js/sh_lang/sh_javascript_dom.min.js +1 -0
  69. data/public/js/sh_lang/sh_latex.min.js +1 -0
  70. data/public/js/sh_lang/sh_ldap.min.js +1 -0
  71. data/public/js/sh_lang/sh_log.min.js +1 -0
  72. data/public/js/sh_lang/sh_lsm.min.js +1 -0
  73. data/public/js/sh_lang/sh_m4.min.js +1 -0
  74. data/public/js/sh_lang/sh_makefile.min.js +1 -0
  75. data/public/js/sh_lang/sh_oracle.min.js +1 -0
  76. data/public/js/sh_lang/sh_pascal.min.js +1 -0
  77. data/public/js/sh_lang/sh_perl.min.js +1 -0
  78. data/public/js/sh_lang/sh_php.min.js +1 -0
  79. data/public/js/sh_lang/sh_prolog.min.js +1 -0
  80. data/public/js/sh_lang/sh_properties.min.js +1 -0
  81. data/public/js/sh_lang/sh_python.min.js +1 -0
  82. data/public/js/sh_lang/sh_ruby.min.js +1 -0
  83. data/public/js/sh_lang/sh_scala.min.js +1 -0
  84. data/public/js/sh_lang/sh_sh.min.js +1 -0
  85. data/public/js/sh_lang/sh_slang.min.js +1 -0
  86. data/public/js/sh_lang/sh_sml.min.js +1 -0
  87. data/public/js/sh_lang/sh_spec.min.js +1 -0
  88. data/public/js/sh_lang/sh_sql.min.js +1 -0
  89. data/public/js/sh_lang/sh_tcl.min.js +1 -0
  90. data/public/js/sh_lang/sh_xml.min.js +1 -0
  91. data/public/js/sh_lang/sh_xorg.min.js +1 -0
  92. data/public/js/sh_main.min.js +4 -0
  93. data/public/js/showoff.js +441 -0
  94. data/views/index.erb +73 -0
  95. data/views/onepage.erb +36 -0
  96. metadata +198 -0
@@ -0,0 +1 @@
1
+ if(!this.sh_languages){this.sh_languages={}}sh_languages.tcl=[[[/#/g,"sh_comment",1],[/\b[+-]?(?:(?:0x[A-Fa-f0-9]+)|(?:(?:[\d]*\.)?[\d]+(?:[eE][+-]?[\d]+)?))u?(?:(?:int(?:8|16|32|64))|L)?\b/g,"sh_number",-1],[/"/g,"sh_string",2],[/'/g,"sh_string",3],[/~|!|%|\^|\*|\(|\)|-|\+|=|\[|\]|\\|:|;|,|\.|\/|\?|&|<|>|\|/g,"sh_symbol",-1],[/\{|\}/g,"sh_cbracket",-1],[/\b(?:proc|global|upvar|if|then|else|elseif|for|foreach|break|continue|while|set|eval|case|in|switch|default|exit|error|proc|return|uplevel|loop|for_array_keys|for_recursive_glob|for_file|unwind_protect|expr|catch|namespace|rename|variable|method|itcl_class|public|protected|append|binary|format|re_syntax|regexp|regsub|scan|string|subst|concat|join|lappend|lindex|list|llength|lrange|lreplace|lsearch|lset|lsort|split|expr|incr|close|eof|fblocked|fconfigure|fcopy|file|fileevent|flush|gets|open|puts|read|seek|socket|tell|load|loadTk|package|pgk::create|pgk_mkIndex|source|bgerror|history|info|interp|memory|unknown|enconding|http|msgcat|cd|clock|exec|exit|glob|pid|pwd|time|dde|registry|resource)\b/g,"sh_keyword",-1],[/\$[A-Za-z0-9_]+/g,"sh_variable",-1]],[[/$/g,null,-2]],[[/"/g,"sh_string",-2],[/\\./g,"sh_specialchar",-1]],[[/'/g,"sh_string",-2],[/\\./g,"sh_specialchar",-1]]];
@@ -0,0 +1 @@
1
+ if(!this.sh_languages){this.sh_languages={}}sh_languages.xml=[[[/<\?xml/g,"sh_preproc",1,1],[/<!DOCTYPE/g,"sh_preproc",3,1],[/<!--/g,"sh_comment",4],[/<(?:\/)?[A-Za-z](?:[A-Za-z0-9_:.-]*)(?:\/)?>/g,"sh_keyword",-1],[/<(?:\/)?[A-Za-z](?:[A-Za-z0-9_:.-]*)/g,"sh_keyword",5,1],[/&(?:[A-Za-z0-9]+);/g,"sh_preproc",-1]],[[/\?>/g,"sh_preproc",-2],[/([^=" \t>]+)([ \t]*)(=?)/g,["sh_type","sh_normal","sh_symbol"],-1],[/"/g,"sh_string",2]],[[/\\(?:\\|")/g,null,-1],[/"/g,"sh_string",-2]],[[/>/g,"sh_preproc",-2],[/([^=" \t>]+)([ \t]*)(=?)/g,["sh_type","sh_normal","sh_symbol"],-1],[/"/g,"sh_string",2]],[[/-->/g,"sh_comment",-2],[/<!--/g,"sh_comment",4]],[[/(?:\/)?>/g,"sh_keyword",-2],[/([^=" \t>]+)([ \t]*)(=?)/g,["sh_type","sh_normal","sh_symbol"],-1],[/"/g,"sh_string",2]]];
@@ -0,0 +1 @@
1
+ if(!this.sh_languages){this.sh_languages={}}sh_languages.xorg=[[[/#/g,"sh_comment",1],[/\b[+-]?(?:(?:0x[A-Fa-f0-9]+)|(?:(?:[\d]*\.)?[\d]+(?:[eE][+-]?[\d]+)?))u?(?:(?:int(?:8|16|32|64))|L)?\b/g,"sh_number",-1],[/"/g,"sh_string",2],[/'/g,"sh_string",3],[/\b(?:End)?(?:Sub)*Section\b/g,"sh_keyword",-1],[/[A-Za-z0-9_]+/g,"sh_type",-1]],[[/$/g,null,-2]],[[/"/g,"sh_string",-2],[/\\./g,"sh_specialchar",-1]],[[/'/g,"sh_string",-2],[/\\./g,"sh_specialchar",-1]]];
@@ -0,0 +1,4 @@
1
+ /* Copyright (C) 2007, 2008 gnombat@users.sourceforge.net */
2
+ /* License: http://shjs.sourceforge.net/doc/gplv3.html */
3
+
4
+ if(!this.sh_languages){this.sh_languages={}}var sh_requests={};function sh_isEmailAddress(a){if(/^mailto:/.test(a)){return false}return a.indexOf("@")!==-1}function sh_setHref(b,c,d){var a=d.substring(b[c-2].pos,b[c-1].pos);if(a.length>=2&&a.charAt(0)==="<"&&a.charAt(a.length-1)===">"){a=a.substr(1,a.length-2)}if(sh_isEmailAddress(a)){a="mailto:"+a}b[c-2].node.href=a}function sh_konquerorExec(b){var a=[""];a.index=b.length;a.input=b;return a}function sh_highlightString(B,o){if(/Konqueror/.test(navigator.userAgent)){if(!o.konquered){for(var F=0;F<o.length;F++){for(var H=0;H<o[F].length;H++){var G=o[F][H][0];if(G.source==="$"){G.exec=sh_konquerorExec}}}o.konquered=true}}var N=document.createElement("a");var q=document.createElement("span");var A=[];var j=0;var n=[];var C=0;var k=null;var x=function(i,a){var p=i.length;if(p===0){return}if(!a){var Q=n.length;if(Q!==0){var r=n[Q-1];if(!r[3]){a=r[1]}}}if(k!==a){if(k){A[j++]={pos:C};if(k==="sh_url"){sh_setHref(A,j,B)}}if(a){var P;if(a==="sh_url"){P=N.cloneNode(false)}else{P=q.cloneNode(false)}P.className=a;A[j++]={node:P,pos:C}}}C+=p;k=a};var t=/\r\n|\r|\n/g;t.lastIndex=0;var d=B.length;while(C<d){var v=C;var l;var w;var h=t.exec(B);if(h===null){l=d;w=d}else{l=h.index;w=t.lastIndex}var g=B.substring(v,l);var M=[];for(;;){var I=C-v;var D;var y=n.length;if(y===0){D=0}else{D=n[y-1][2]}var O=o[D];var z=O.length;var m=M[D];if(!m){m=M[D]=[]}var E=null;var u=-1;for(var K=0;K<z;K++){var f;if(K<m.length&&(m[K]===null||I<=m[K].index)){f=m[K]}else{var c=O[K][0];c.lastIndex=I;f=c.exec(g);m[K]=f}if(f!==null&&(E===null||f.index<E.index)){E=f;u=K;if(f.index===I){break}}}if(E===null){x(g.substring(I),null);break}else{if(E.index>I){x(g.substring(I,E.index),null)}var e=O[u];var J=e[1];var b;if(J instanceof Array){for(var L=0;L<J.length;L++){b=E[L+1];x(b,J[L])}}else{b=E[0];x(b,J)}switch(e[2]){case -1:break;case -2:n.pop();break;case -3:n.length=0;break;default:n.push(e);break}}}if(k){A[j++]={pos:C};if(k==="sh_url"){sh_setHref(A,j,B)}k=null}C=w}return A}function sh_getClasses(d){var a=[];var b=d.className;if(b&&b.length>0){var e=b.split(" ");for(var c=0;c<e.length;c++){if(e[c].length>0){a.push(e[c])}}}return a}function sh_addClass(c,a){var d=sh_getClasses(c);for(var b=0;b<d.length;b++){if(a.toLowerCase()===d[b].toLowerCase()){return}}d.push(a);c.className=d.join(" ")}function sh_extractTagsFromNodeList(c,a){var f=c.length;for(var d=0;d<f;d++){var e=c.item(d);switch(e.nodeType){case 1:if(e.nodeName.toLowerCase()==="br"){var b;if(/MSIE/.test(navigator.userAgent)){b="\r"}else{b="\n"}a.text.push(b);a.pos++}else{a.tags.push({node:e.cloneNode(false),pos:a.pos});sh_extractTagsFromNodeList(e.childNodes,a);a.tags.push({pos:a.pos})}break;case 3:case 4:a.text.push(e.data);a.pos+=e.length;break}}}function sh_extractTags(c,b){var a={};a.text=[];a.tags=b;a.pos=0;sh_extractTagsFromNodeList(c.childNodes,a);return a.text.join("")}function sh_mergeTags(d,f){var a=d.length;if(a===0){return f}var c=f.length;if(c===0){return d}var i=[];var e=0;var b=0;while(e<a&&b<c){var h=d[e];var g=f[b];if(h.pos<=g.pos){i.push(h);e++}else{i.push(g);if(f[b+1].pos<=h.pos){b++;i.push(f[b]);b++}else{i.push({pos:h.pos});f[b]={node:g.node.cloneNode(false),pos:h.pos}}}}while(e<a){i.push(d[e]);e++}while(b<c){i.push(f[b]);b++}return i}function sh_insertTags(k,h){var g=document;var l=document.createDocumentFragment();var e=0;var d=k.length;var b=0;var j=h.length;var c=l;while(b<j||e<d){var i;var a;if(e<d){i=k[e];a=i.pos}else{a=j}if(a<=b){if(i.node){var f=i.node;c.appendChild(f);c=f}else{c=c.parentNode}e++}else{c.appendChild(g.createTextNode(h.substring(b,a)));b=a}}return l}function sh_highlightElement(d,g){sh_addClass(d,"sh_sourceCode");var c=[];var e=sh_extractTags(d,c);var f=sh_highlightString(e,g);var b=sh_mergeTags(c,f);var a=sh_insertTags(b,e);while(d.hasChildNodes()){d.removeChild(d.firstChild)}d.appendChild(a)}function sh_getXMLHttpRequest(){if(window.ActiveXObject){return new ActiveXObject("Msxml2.XMLHTTP")}else{if(window.XMLHttpRequest){return new XMLHttpRequest()}}throw"No XMLHttpRequest implementation available"}function sh_load(language,element,prefix,suffix){if(language in sh_requests){sh_requests[language].push(element);return}sh_requests[language]=[element];var request=sh_getXMLHttpRequest();var url=prefix+"sh_"+language+suffix;request.open("GET",url,true);request.onreadystatechange=function(){if(request.readyState===4){try{if(!request.status||request.status===200){eval(request.responseText);var elements=sh_requests[language];for(var i=0;i<elements.length;i++){sh_highlightElement(elements[i],sh_languages[language])}}else{throw"HTTP error: status "+request.status}}finally{request=null}}};request.send(null)}function sh_highlightDocument(g,k){var b=document.getElementsByTagName("pre");for(var e=0;e<b.length;e++){var f=b.item(e);var a=sh_getClasses(f);for(var c=0;c<a.length;c++){var h=a[c].toLowerCase();if(h==="sh_sourcecode"){continue}if(h.substr(0,3)==="sh_"){var d=h.substring(3);if(d in sh_languages){sh_highlightElement(f,sh_languages[d])}else{if(typeof(g)==="string"&&typeof(k)==="string"){sh_load(d,f,g,k)}else{throw'Found <pre> element with class="'+h+'", but no such language exists'}}break}}}};
@@ -0,0 +1,441 @@
1
+ /* ShowOff JS Logic */
2
+
3
+ var ShowOff = {};
4
+
5
+ var preso_started = false
6
+ var slidenum = 0
7
+ var slideTotal = 0
8
+ var slides
9
+ var currentSlide
10
+ var totalslides = 0
11
+ var slidesLoaded = false
12
+ var incrSteps = 0
13
+ var incrElem
14
+ var incrCurr = 0
15
+ var incrCode = false
16
+ var debugMode = false
17
+ var gotoSlidenum = 0
18
+ var shiftKeyActive = false
19
+
20
+
21
+ function setupPreso(load_slides, prefix) {
22
+ if (preso_started)
23
+ {
24
+ alert("already started")
25
+ return
26
+ }
27
+ preso_started = true
28
+
29
+
30
+ loadSlides(load_slides, prefix)
31
+
32
+ doDebugStuff()
33
+
34
+ // bind event handlers
35
+ document.onkeydown = keyDown
36
+ document.onkeyup = keyUp
37
+ /* window.onresize = resized; */
38
+ /* window.onscroll = scrolled; */
39
+ /* window.onunload = unloaded; */
40
+ }
41
+
42
+ function loadSlides(load_slides, prefix) {
43
+ //load slides offscreen, wait for images and then initialize
44
+ if (load_slides) {
45
+ $("#slides").load("/slides", false, function(){
46
+ $("#slides img").batchImageLoad({
47
+ loadingCompleteCallback: initializePresentation(prefix)
48
+ })
49
+ })
50
+ } else {
51
+ $("#slides img").batchImageLoad({
52
+ loadingCompleteCallback: initializePresentation(prefix)
53
+ })
54
+ }
55
+ }
56
+
57
+ function initializePresentation(prefix) {
58
+ //center slides offscreen
59
+ centerSlides($('#slides > .slide'))
60
+
61
+ //copy into presentation area
62
+ $("#preso").empty()
63
+ $('#slides > .slide').appendTo($("#preso"))
64
+
65
+ //populate vars
66
+ slides = $('#preso > .slide')
67
+ slideTotal = slides.size()
68
+
69
+ //setup manual jquery cycle
70
+ $('#preso').cycle({
71
+ timeout: 0
72
+ })
73
+
74
+ setupMenu()
75
+ if (slidesLoaded) {
76
+ showSlide()
77
+ alert('slides loaded')
78
+ } else {
79
+ showFirstSlide();
80
+ slidesLoaded = true
81
+ }
82
+ setupSlideParamsCheck();
83
+ sh_highlightDocument(prefix+'/js/sh_lang/', '.min.js')
84
+ }
85
+
86
+ function centerSlides(slides) {
87
+ slides.each(function(s, slide) {
88
+ centerSlide(slide)
89
+ })
90
+ }
91
+
92
+ function centerSlide(slide) {
93
+ var slide_content = $(slide).children(".content").first()
94
+ var height = slide_content.height()
95
+ var mar_top = (0.5 * parseFloat($(slide).height())) - (0.5 * parseFloat(height))
96
+ if (mar_top < 0) {
97
+ mar_top = 0
98
+ }
99
+ slide_content.css('margin-top', mar_top)
100
+ }
101
+
102
+ function setupMenu() {
103
+ $('#navmenu').hide();
104
+
105
+ var currSlide = 0
106
+ var menu = new ListMenu()
107
+
108
+ slides.each(function(s, elem) {
109
+ content = $(elem).children(".content")
110
+ shortTxt = $(content).text().substr(0, 20)
111
+ path = $(content).attr('ref').split('/')
112
+ currSlide += 1
113
+ menu.addItem(path, shortTxt, currSlide)
114
+ })
115
+
116
+ $('#navigation').html(menu.getList())
117
+ $('#navmenu').menu({
118
+ content: $('#navigation').html(),
119
+ flyOut: true
120
+ });
121
+ }
122
+
123
+ function checkSlideParameter() {
124
+ if (slideParam = currentSlideFromParams()) {
125
+ slidenum = slideParam;
126
+ }
127
+ }
128
+
129
+ function currentSlideFromParams() {
130
+ var result;
131
+ if (result = window.location.hash.match(/#([0-9]+)/)) {
132
+ return result[result.length - 1] - 1;
133
+ }
134
+ }
135
+
136
+ function setupSlideParamsCheck() {
137
+ var check = function() {
138
+ var currentSlide = currentSlideFromParams();
139
+ if (slidenum != currentSlide) {
140
+ slidenum = currentSlide;
141
+ showSlide();
142
+ }
143
+ setTimeout(check, 100);
144
+ }
145
+ setTimeout(check, 100);
146
+ }
147
+
148
+ function gotoSlide(slideNum) {
149
+ slidenum = parseInt(slideNum)
150
+ if (!isNaN(slidenum)) {
151
+ showSlide()
152
+ }
153
+ }
154
+
155
+ function showFirstSlide() {
156
+ slidenum = 0
157
+ checkSlideParameter();
158
+ showSlide()
159
+ }
160
+
161
+ function showSlide(back_step) {
162
+
163
+ if(slidenum < 0) {
164
+ slidenum = 0
165
+ return
166
+ }
167
+
168
+ if(slidenum > (slideTotal - 1)) {
169
+ slidenum = slideTotal - 1
170
+ return
171
+ }
172
+
173
+ currentSlide = slides.eq(slidenum)
174
+
175
+ var transition = currentSlide.attr('data-transition')
176
+ var fullPage = currentSlide.find(".content").is('.full-page');
177
+
178
+ if (back_step || fullPage) {
179
+ transition = 'none'
180
+ }
181
+
182
+ $('#preso').cycle(slidenum, transition)
183
+
184
+ if (fullPage) {
185
+ $('#preso').css({'width' : '100%', 'overflow' : 'visible'});
186
+ currentSlide.css({'width' : '100%', 'text-align' : 'center', 'overflow' : 'visible'});
187
+ } else {
188
+ $('#preso').css({'width' : '1020px', 'overflow' : 'hidden'});
189
+ }
190
+
191
+ percent = getSlidePercent()
192
+ $("#slideInfo").text((slidenum + 1) + '/' + slideTotal + ' - ' + percent + '%')
193
+
194
+ if(!back_step) {
195
+ // determine if there are incremental bullets to show
196
+ // unless we are moving backward
197
+ determineIncremental()
198
+ } else {
199
+ incrCurr = 0
200
+ incrSteps = 0
201
+ }
202
+ location.hash = slidenum + 1;
203
+ $('body').addSwipeEvents().
204
+ bind('swipeleft', swipeLeft).
205
+ bind('swiperight', swipeRight)
206
+ removeResults()
207
+
208
+ return getCurrentNotes()
209
+ }
210
+
211
+ function getSlideProgress()
212
+ {
213
+ return (slidenum + 1) + '/' + slideTotal
214
+ }
215
+
216
+ function getCurrentNotes()
217
+ {
218
+ return currentSlide.find("p.notes").text()
219
+ }
220
+
221
+ function getSlidePercent()
222
+ {
223
+ return Math.ceil(((slidenum + 1) / slideTotal) * 100)
224
+ }
225
+
226
+ function determineIncremental()
227
+ {
228
+ incrCurr = 0
229
+ incrCode = false
230
+ incrElem = currentSlide.find(".incremental > ul > li")
231
+ incrSteps = incrElem.size()
232
+ if(incrSteps == 0) {
233
+ // also look for commandline
234
+ incrElem = currentSlide.find(".incremental > pre > code > code")
235
+ incrSteps = incrElem.size()
236
+ incrCode = true
237
+ }
238
+ incrElem.each(function(s, elem) {
239
+ $(elem).hide()
240
+ })
241
+ }
242
+
243
+ function prevStep()
244
+ {
245
+ slidenum--
246
+ return showSlide(true) // We show the slide fully loaded
247
+ }
248
+
249
+ function nextStep()
250
+ {
251
+ if (incrCurr >= incrSteps) {
252
+ slidenum++
253
+ return showSlide()
254
+ } else {
255
+ elem = incrElem.eq(incrCurr)
256
+ if (incrCode && elem.hasClass('command')) {
257
+ incrElem.eq(incrCurr).show().jTypeWriter({duration:1.0})
258
+ } else {
259
+ incrElem.eq(incrCurr).show()
260
+ }
261
+ incrCurr++
262
+ }
263
+ }
264
+
265
+ function prevStep() {
266
+ slidenum--
267
+ return showSlide(true) // We show the slide fully loaded
268
+ }
269
+
270
+ function doDebugStuff()
271
+ {
272
+ if (debugMode) {
273
+ $('#debugInfo').show()
274
+ debug('debug mode on')
275
+ } else {
276
+ $('#debugInfo').hide()
277
+ }
278
+ }
279
+
280
+ function debug(data)
281
+ {
282
+ $('#debugInfo').text(data)
283
+ }
284
+ // See e.g. http://www.quirksmode.org/js/events/keys.html for keycodes
285
+ function keyDown(event)
286
+ {
287
+ var key = event.keyCode;
288
+
289
+ if (event.ctrlKey || event.altKey || event.metaKey)
290
+ return true;
291
+
292
+ debug('keyDown: ' + key)
293
+
294
+ if (key >= 48 && key <= 57) // 0 - 9
295
+ {
296
+ gotoSlidenum = gotoSlidenum * 10 + (key - 48);
297
+ return true;
298
+ }
299
+ if (key == 13 && gotoSlidenum > 0)
300
+ {
301
+ debug('go to ' + gotoSlidenum);
302
+ slidenum = gotoSlidenum - 1;
303
+ showSlide(true);
304
+ }
305
+ gotoSlidenum = 0;
306
+
307
+ if (key == 16) // shift key
308
+ {
309
+ shiftKeyActive = true;
310
+ }
311
+ if (key == 32) // space bar
312
+ {
313
+ if (shiftKeyActive) { prevStep() }
314
+ else { nextStep() }
315
+ }
316
+ else if (key == 68) // 'd' for debug
317
+ {
318
+ debugMode = !debugMode
319
+ doDebugStuff()
320
+ }
321
+ else if (key == 37 || key == 33) // Left arrow or page up
322
+ {
323
+ prevStep()
324
+ }
325
+ else if (key == 39 || key == 34) // Right arrow or page down
326
+ {
327
+ nextStep()
328
+ }
329
+ else if (key == 82) // R for reload
330
+ {
331
+ if (confirm('really reload slides?')) {
332
+ loadSlides()
333
+ showSlide()
334
+ }
335
+ }
336
+ else if (key == 84 || key == 67) // T or C for table of contents
337
+ {
338
+ $('#navmenu').toggle().trigger('click')
339
+ }
340
+ else if (key == 90) // z for help
341
+ {
342
+ $('#help').toggle()
343
+ }
344
+ else if (key == 66 || key == 70) // f for footer (also "b" which is what kensington remote "stop" button sends
345
+ {
346
+ toggleFooter()
347
+ }
348
+ else if (key == 27) // esc
349
+ {
350
+ removeResults();
351
+ }
352
+ return true
353
+ }
354
+
355
+ function toggleFooter()
356
+ {
357
+ $('#footer').toggle()
358
+ }
359
+
360
+ function keyUp(event) {
361
+ var key = event.keyCode;
362
+ debug('keyUp: ' + key);
363
+ if (key == 16) // shift key
364
+ {
365
+ shiftKeyActive = false;
366
+ }
367
+ }
368
+
369
+
370
+ function swipeLeft() {
371
+ nextStep()
372
+ }
373
+
374
+ function swipeRight() {
375
+ prevStep()
376
+ }
377
+
378
+ function ListMenu(s)
379
+ {
380
+ this.slide = s
381
+ this.typeName = 'ListMenu'
382
+ this.itemLength = 0;
383
+ this.items = new Array();
384
+ this.addItem = function (key, text, slide) {
385
+ if (key.length > 1) {
386
+ thisKey = key.shift()
387
+ if (!this.items[thisKey]) {
388
+ this.items[thisKey] = new ListMenu(slide)
389
+ }
390
+ this.items[thisKey].addItem(key, text, slide)
391
+ } else {
392
+ thisKey = key.shift()
393
+ this.items[thisKey] = new ListMenuItem(text, slide)
394
+ }
395
+ }
396
+ this.getList = function() {
397
+ var newMenu = $("<ul>")
398
+ for(var i in this.items) {
399
+ var item = this.items[i]
400
+ var domItem = $("<li>")
401
+ if (item.typeName == 'ListMenu') {
402
+ choice = $("<a rel=\"" + (item.slide - 1) + "\" href=\"#\">" + i + "</a>")
403
+ domItem.append(choice)
404
+ domItem.append(item.getList())
405
+ }
406
+ if (item.typeName == 'ListMenuItem') {
407
+ choice = $("<a rel=\"" + (item.slide - 1) + "\" href=\"#\">" + item.slide + '. ' + item.textName + "</a>")
408
+ domItem.append(choice)
409
+ }
410
+ newMenu.append(domItem)
411
+ }
412
+ return newMenu
413
+ }
414
+ }
415
+
416
+ function ListMenuItem(t, s)
417
+ {
418
+ this.typeName = "ListMenuItem"
419
+ this.slide = s
420
+ this.textName = t
421
+ }
422
+
423
+ var removeResults = function() {
424
+ $('.results').remove();
425
+ };
426
+
427
+ var print = function(text) {
428
+ removeResults();
429
+ var _results = $('<div>').addClass('results').text($.print(text));
430
+ $('body').append(_results);
431
+ _results.click(removeResults);
432
+ };
433
+
434
+ $('.sh_javaScript code').live("click", function() {
435
+ result = null;
436
+ var codeDiv = $(this);
437
+ codeDiv.addClass("executing");
438
+ eval(codeDiv.text());
439
+ setTimeout(function() { codeDiv.removeClass("executing");}, 250 );
440
+ if (result != null) print(result);
441
+ });