├── .gitignore ├── Makefile ├── README ├── bin ├── pre.pl └── render-template ├── config.yaml ├── css └── sporx.css ├── lib ├── jquery.js └── sporx.js ├── sample-slides.sld └── template ├── license.html └── sporx.html /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *~ 3 | *_ 4 | ~* 5 | _* 6 | *.bak 7 | upload 8 | images 9 | *.swp 10 | sample-slides.html 11 | bin/upload 12 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all 2 | 3 | all: sample-slides.html 4 | 5 | %.slides: %.sld 6 | perl bin/pre.pl $< > $@ 7 | 8 | %.html: %.slides template/* 9 | perl bin/render-template $< $@ 10 | 11 | %.png: %.dot 12 | dot -Tpng $< > $@ 13 | 14 | %.dot: %.tt 15 | tpage $< > $@ 16 | 17 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This is a tool to convert POD-like text into a shiney HTML 2 | based slides. We borrowed most of the code and style from 3 | the excellent XUL slidemaker tool named Sporx. 4 | 5 | To produce your own slides, just edit sample-slides.sld 6 | file and run "make" again. If you prefer another file name, 7 | just rename the sample-slides.sld file and also edit the 8 | Makefile's first line to my-new-name.html where "my-new-name" 9 | is your slides source file's new basename. 10 | 11 | Final sample-slides.html can be browsed here 12 | 13 | http://agentzh.org/misc/slides/taobao-fe/sample-slides.html 14 | 15 | h2. BUG 16 | 17 | * mac 下快捷键不好用 18 | 19 | 20 | h2. TODO 21 | 22 | * 添加图片 loading 23 | -------------------------------------------------------------------------------- /bin/pre.pl: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | sub gen_wh { 5 | my $file = shift; 6 | my $out = `identify $file`; 7 | my $retval = ''; 8 | if ($out =~ /\b(\d+)x(\d+)\b/) { 9 | my ($w, $h) = ($1, $2); 10 | $retval = qq{width="$w" height="$h"}; 11 | } 12 | #warn $retval; 13 | return $retval; 14 | } 15 | 16 | my $firstTime = 1; 17 | while (<>) { 18 | s/(X|CI|C|XI|I|KW|TAG|CM|V|KEY|ATT|T)<<(.*?)>>/'{{#' . lc($1) . "|$2}}"/ge; 19 | s/(X|CI|C|XI|I|KW|TAG|CM|V|KEY|ATT|T)<([^>]*)>/'{{#' . lc($1) . "|$2}}"/ge; 20 | s/\{\{img\s+src="([^"]+)"\}\}/"{{img src=\"$1\" " . gen_wh($1) . "}}"/ge; 21 | my $new; 22 | if (/\{\{img\s+/) { 23 | #$new = qq<{{img src="#" width="0" height="0"}}\n>; 24 | $firstTime = 0; 25 | } 26 | while (1) { 27 | if (/\G\{\{.*?\}\}/gcs) { 28 | $new .= $&; 29 | } elsif (/\G"/gcs) { 30 | $new .= '\\"'; 31 | #warn $new; 32 | } elsif (/\G./gcs) { 33 | $new .= $&; 34 | } else { 35 | last; 36 | } 37 | } 38 | $new =~ s/^$/ /g; 39 | print $new; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /bin/render-template: -------------------------------------------------------------------------------- 1 | #!/usr/sbin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | use Template; 6 | use YAML; 7 | 8 | my ($slides_path, $output_path) = @ARGV; 9 | 10 | my $config = YAML::LoadFile('config.yaml'); 11 | my $main_template = $config->{main_template} || 'sporx.html'; 12 | 13 | open SLIDES, $slides_path 14 | or die "Can't open $slides_path for input:\n$!"; 15 | my $slides_content = do {local $/; }; 16 | close SLIDES; 17 | 18 | $slides_content =~ s/&/&/g; 19 | $slides_content =~ s/ $slides_content, 24 | }; 25 | 26 | my $result; 27 | 28 | my $t = Template->new( { INCLUDE_PATH => ['template/'] }); 29 | $t->process($main_template, $data, \$result) or die $t->error; 30 | 31 | open OUTPUT, "> $output_path" 32 | or die "Can't open $output_path for output:\n$!"; 33 | print OUTPUT $result; 34 | close OUTPUT; 35 | -------------------------------------------------------------------------------- /config.yaml: -------------------------------------------------------------------------------- 1 | main_template: sporx.html 2 | license_template: license.html 3 | css_location: css/sporx.css 4 | javascript_runtime: lib/sporx.js 5 | -------------------------------------------------------------------------------- /css/sporx.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /* ***** BEGIN LICENSE BLOCK ***** 4 | * Version: MPL 1.1 5 | * 6 | * The contents of this file are subject to the Mozilla Public License Version 7 | * 1.1 (the "License"); you may not use this file except in compliance with 8 | * the License. You may obtain a copy of the License at 9 | * http://www.mozilla.org/MPL/ 10 | * 11 | * Software distributed under the License is distributed on an "AS IS" basis, 12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing rights and limitations under the 14 | * License. 15 | * 16 | * The Original Code is the Takahashi-Method-based Presentation Tool in XUL. 17 | * 18 | * The Initial Developer of the Original Code is SHIMODA Hiroshi. 19 | * Portions created by the Initial Developer are Copyright (C) 2005 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): SHIMODA Hiroshi 23 | * 24 | * ***** END LICENSE BLOCK ***** */ 25 | 26 | #canvas { 27 | color: #000 !important; 28 | background: white !important; 29 | font-family: 30 | "Candara" 31 | "Georgia" 32 | "DejaVu Serif Condensed" 33 | "Arial" 34 | "微软雅黑" 35 | "Bitstream Vera Sans" 36 | "Verdana" 37 | "Apple LiGothic" 38 | "Arial Black" 39 | "Bitstream Vera Sans" 40 | 41 | sans-serif !important; 42 | } 43 | body.in-print #canvas, 44 | body.in-print #canvasToolbar { 45 | display: none; 46 | } 47 | #canvas * { 48 | cursor: text !important; 49 | } 50 | #canvas img { 51 | width: auto; 52 | height: auto; 53 | } 54 | .link-text { 55 | color: #000066 !important; 56 | text-decoration: none !important; 57 | } 58 | .link-text:hover { 59 | color: #3333FF !important; 60 | /* border-bottom: dotted 1px; */ 61 | } 62 | .link-text:active { 63 | color: #9999FF !important; 64 | } 65 | .kw { 66 | color: #3333FF 67 | } 68 | .s { 69 | text-decoration: line-through; 70 | } 71 | .iu { 72 | text-decoration: underline; 73 | font-style: italic; 74 | } 75 | .ui { 76 | /* text-decoration: underline; */ 77 | font-style: italic; 78 | } 79 | .u { 80 | text-decoration: underline; 81 | } 82 | .date { 83 | font-style: italic; 84 | text-decoration: underline; 85 | font-size: 40%; 86 | color: #339933; 87 | } 88 | .bdate { 89 | font-style: italic; 90 | text-decoration: underline; 91 | font-size: 90%; 92 | color: #339933; 93 | } 94 | .i { 95 | font-style: italic; 96 | font-family: "Cambria" "Times New Roman" "Bitstream Vera Serif" serif; 97 | } 98 | .t { 99 | font-style: italic; 100 | } 101 | .tag { 102 | color: #998833; 103 | } 104 | .v { 105 | color: #998833; 106 | } 107 | .att { 108 | color: #333399; 109 | } 110 | .key { 111 | color: #009999; 112 | } 113 | .h { 114 | color: #000; 115 | margin: 0px; 116 | } 117 | .c { 118 | color: #C39; 119 | margin: 0px; 120 | } 121 | .cm { 122 | color: #117711; 123 | } 124 | .m { 125 | color: #963; 126 | margin: 0px; 127 | font-family: "Comic Sans MS"; 128 | } 129 | .cz { 130 | color: #C39; 131 | margin: 0px; 132 | font-family: "Candara"; 133 | margin-right: -10px; 134 | } 135 | .z { 136 | margin: 0px; 137 | margin-left: -10px; 138 | font-family: "Candara" 139 | } 140 | .x { 141 | color: #C00; 142 | margin: 0px; 143 | } 144 | .xs { 145 | color: #633; 146 | margin: 0px; 147 | text-decoration: line-through; 148 | } 149 | .ci { 150 | color: #C39; 151 | margin: 0px; 152 | font-style: italic; 153 | } 154 | .author { 155 | color: #C39; 156 | margin: 0px; 157 | font-style: italic; 158 | font-family: "Consolas" 159 | "Constantia" 160 | "Times New Roman" 161 | "微软雅黑" 162 | "Bitstream Vera Serif" 163 | serif; 164 | font-size: 70%; 165 | } 166 | .cu { 167 | color: #C39; 168 | margin: 0px; 169 | text-decoration: underline; 170 | } 171 | .ct { 172 | color: #C39; 173 | margin: 0px; 174 | font-style: italic; 175 | } 176 | .hs { 177 | color: #f33; 178 | margin: 0px; 179 | text-decoration: line-through; 180 | } 181 | .ht { 182 | color: #aaa; 183 | font-style: italic; 184 | } 185 | .pre { 186 | font-family: "Consolas" 187 | "Courier New" 188 | "Anonymous" 189 | "Andale Mono" 190 | "Bitstream Vera Sans Mono" 191 | "微软雅黑" 192 | monospace; 193 | padding-bottom: 8px; 194 | font-weight: bold; 195 | } 196 | 197 | .pre-big { 198 | font-family: "Consolas" 199 | "Courier New" 200 | "Anonymous" 201 | "Andale Mono" 202 | "Bitstream Vera Sans Mono" 203 | "微软雅黑" 204 | monospace; 205 | padding-bottom: 8px; 206 | font-weight: bold; 207 | /* margin-left: 10%; */ 208 | } 209 | 210 | .pre { 211 | font-family: "Consolas" 212 | "Courier New" 213 | "Anonymous" 214 | "Andale Mono" 215 | "Bitstream Vera Sans Mono" 216 | "微软雅黑" 217 | monospace; 218 | padding-bottom: 8px; 219 | font-weight: bold; 220 | } 221 | #canvas[rendering="true"] img { 222 | display: none; 223 | } 224 | #canvas[rendering="true"] *, 225 | #canvas[rendering="true"] .text-link { 226 | color: white !important; 227 | } 228 | 229 | 230 | html, body, div { 231 | margin: 0; 232 | padding: 2px; 233 | } 234 | 235 | body{ 236 | margin:0 10px; 237 | } 238 | 239 | 240 | #canvas[eva="true"] { 241 | background: white !important; 242 | color: black !important; 243 | font-family: 244 | "Georgia" 245 | "DejaVu Serif Condensed" 246 | "Apple LiGothic" 247 | "Arial Black" 248 | serif !important; 249 | } 250 | #canvas[eva="true"] .link-text { 251 | color: red !important; 252 | text-decoration: none !important; 253 | } 254 | #canvas[eva="true"] .link-text:hover { 255 | color: pink !important; 256 | } 257 | #canvas[eva="true"] .link-text:active { 258 | color: orange !important; 259 | } 260 | #canvas[rendering="true"] *, 261 | #canvas[rendering="true"] .text-link { 262 | color: black !important; 263 | } 264 | 265 | 266 | #canvasToolbar { 267 | position: absolute; 268 | border-bottom:3px solid #ccc; 269 | background:#eee; 270 | width:90%; 271 | left:5%; 272 | padding:5px 10px; 273 | z-index:5; 274 | } 275 | #canvasToolbar .fr{ 276 | float:right; 277 | } 278 | 279 | #edit {display:none;} 280 | 281 | #content{position:relative;zoom:1;} 282 | 283 | -------------------------------------------------------------------------------- /lib/jquery.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery 1.2.2 - New Wave Javascript 3 | * 4 | * Copyright (c) 2007 John Resig (jquery.com) 5 | * Dual licensed under the MIT (MIT-LICENSE.txt) 6 | * and GPL (GPL-LICENSE.txt) licenses. 7 | * 8 | * $Date: 2008-01-14 17:56:07 -0500 (Mon, 14 Jan 2008) $ 9 | * $Rev: 4454 $ 10 | */ 11 | (function(){if(window.jQuery)var _jQuery=window.jQuery;var jQuery=window.jQuery=function(selector,context){return new jQuery.prototype.init(selector,context);};if(window.$)var _$=window.$;window.$=jQuery;var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;var isSimple=/^.[^:#\[\.]*$/;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;return this;}else if(typeof selector=="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1])selector=jQuery.clean([match[1]],context);else{var elem=document.getElementById(match[3]);if(elem)if(elem.id!=match[3])return jQuery().find(selector);else{this[0]=elem;this.length=1;return this;}else 12 | selector=[];}}else 13 | return new jQuery(context).find(selector);}else if(jQuery.isFunction(selector))return new jQuery(document)[jQuery.fn.ready?"ready":"load"](selector);return this.setArray(selector.constructor==Array&&selector||(selector.jquery||selector.length&&selector!=window&&!selector.nodeType&&selector[0]!=undefined&&selector[0].nodeType)&&jQuery.makeArray(selector)||[selector]);},jquery:"1.2.2",size:function(){return this.length;},length:0,get:function(num){return num==undefined?jQuery.makeArray(this):this[num];},pushStack:function(elems){var ret=jQuery(elems);ret.prevObject=this;return ret;},setArray:function(elems){this.length=0;Array.prototype.push.apply(this,elems);return this;},each:function(callback,args){return jQuery.each(this,callback,args);},index:function(elem){var ret=-1;this.each(function(i){if(this==elem)ret=i;});return ret;},attr:function(name,value,type){var options=name;if(name.constructor==String)if(value==undefined)return this.length&&jQuery[type||"attr"](this[0],name)||undefined;else{options={};options[name]=value;}return this.each(function(i){for(name in options)jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));});},css:function(key,value){if((key=='width'||key=='height')&&parseFloat(value)<0)value=undefined;return this.attr(key,value,"curCSS");},text:function(text){if(typeof text!="object"&&text!=null)return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));var ret="";jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8)ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);});});return ret;},wrapAll:function(html){if(this[0])jQuery(html,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){var elem=this;while(elem.firstChild)elem=elem.firstChild;return elem;}).append(this);return this;},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);});},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);});},append:function(){return this.domManip(arguments,true,false,function(elem){if(this.nodeType==1)this.appendChild(elem);});},prepend:function(){return this.domManip(arguments,true,true,function(elem){if(this.nodeType==1)this.insertBefore(elem,this.firstChild);});},before:function(){return this.domManip(arguments,false,false,function(elem){this.parentNode.insertBefore(elem,this);});},after:function(){return this.domManip(arguments,false,true,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);});},end:function(){return this.prevObject||jQuery([]);},find:function(selector){var elems=jQuery.map(this,function(elem){return jQuery.find(selector,elem);});return this.pushStack(/[^+>] [^+>]/.test(selector)||selector.indexOf("..")>-1?jQuery.unique(elems):elems);},clone:function(events){var ret=this.map(function(){if(jQuery.browser.msie&&!jQuery.isXMLDoc(this)){var clone=this.cloneNode(true),container=document.createElement("div"),container2=document.createElement("div");container.appendChild(clone);container2.innerHTML=container.innerHTML;return container2.firstChild;}else 14 | return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function(){if(this[expando]!=undefined)this[expando]=null;});if(events===true)this.find("*").andSelf().each(function(i){if(this.nodeType==3)return;var events=jQuery.data(this,"events");for(var type in events)for(var handler in events[type])jQuery.event.add(clone[i],type,events[type][handler],events[type][handler].data);});return ret;},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);})||jQuery.multiFilter(selector,this));},not:function(selector){if(selector.constructor==String)if(isSimple.test(selector))return this.pushStack(jQuery.multiFilter(selector,this,true));else 15 | selector=jQuery.multiFilter(selector,this);var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;});},add:function(selector){return!selector?this:this.pushStack(jQuery.merge(this.get(),selector.constructor==String?jQuery(selector).get():selector.length!=undefined&&(!selector.nodeName||jQuery.nodeName(selector,"form"))?selector:[selector]));},is:function(selector){return selector?jQuery.multiFilter(selector,this).length>0:false;},hasClass:function(selector){return this.is("."+selector);},val:function(value){if(value==undefined){if(this.length){var elem=this[0];if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";if(index<0)return null;for(var i=one?index:0,max=one?index+1:options.length;i=0||jQuery.inArray(this.name,value)>=0);else if(jQuery.nodeName(this,"select")){var values=value.constructor==Array?value:[value];jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);});if(!values.length)this.selectedIndex=-1;}else 17 | this.value=value;});},html:function(value){return value==undefined?(this.length?this[0].innerHTML:null):this.empty().append(value);},replaceWith:function(value){return this.after(value).remove();},eq:function(i){return this.slice(i,i+1);},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments));},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);}));},andSelf:function(){return this.add(this.prevObject);},domManip:function(args,table,reverse,callback){var clone=this.length>1,elems;return this.each(function(){if(!elems){elems=jQuery.clean(args,this.ownerDocument);if(reverse)elems.reverse();}var obj=this;if(table&&jQuery.nodeName(this,"table")&&jQuery.nodeName(elems[0],"tr"))obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));var scripts=jQuery([]);jQuery.each(elems,function(){var elem=clone?jQuery(this).clone(true)[0]:this;if(jQuery.nodeName(elem,"script")){scripts=scripts.add(elem);}else{if(elem.nodeType==1)scripts=scripts.add(jQuery("script",elem).remove());callback.call(obj,elem);}});scripts.each(evalScript);});}};jQuery.prototype.init.prototype=jQuery.prototype;function evalScript(i,elem){if(elem.src)jQuery.ajax({url:elem.src,async:false,dataType:"script"});else 18 | jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");if(elem.parentNode)elem.parentNode.removeChild(elem);}jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(target.constructor==Boolean){deep=target;target=arguments[1]||{};i=2;}if(typeof target!="object"&&typeof target!="function")target={};if(length==1){target=this;i=0;}for(;i-1;}},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name];}callback.call(elem);for(var name in options)elem.style[name]=old[name];},css:function(elem,name,force){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;var padding=0,border=0;jQuery.each(which,function(){padding+=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;border+=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;});val-=Math.round(padding+border);}if(jQuery(elem).is(":visible"))getWH();else 22 | jQuery.swap(elem,props,getWH);return Math.max(0,val);}return jQuery.curCSS(elem,name,force);},curCSS:function(elem,name,force){var ret;function color(elem){if(!jQuery.browser.safari)return false;var ret=document.defaultView.getComputedStyle(elem,null);return!ret||ret.getPropertyValue("color")=="";}if(name=="opacity"&&jQuery.browser.msie){ret=jQuery.attr(elem.style,"opacity");return ret==""?"1":ret;}if(jQuery.browser.opera&&name=="display"){var save=elem.style.display;elem.style.display="block";elem.style.display=save;}if(name.match(/float/i))name=styleFloat;if(!force&&elem.style&&elem.style[name])ret=elem.style[name];else if(document.defaultView&&document.defaultView.getComputedStyle){if(name.match(/float/i))name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var getComputedStyle=document.defaultView.getComputedStyle(elem,null);if(getComputedStyle&&!color(elem))ret=getComputedStyle.getPropertyValue(name);else{var swap=[],stack=[];for(var a=elem;a&&color(a);a=a.parentNode)stack.unshift(a);for(var i=0;i]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+">";});var tags=jQuery.trim(elem).toLowerCase(),div=context.createElement("div");var wrap=!tags.indexOf("",""]||!tags.indexOf("",""]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"","
"]||!tags.indexOf("",""]||(!tags.indexOf("",""]||!tags.indexOf("",""]||jQuery.browser.msie&&[1,"div
","
"]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)div=div.lastChild;if(jQuery.browser.msie){var tbody=!tags.indexOf(""&&tags.indexOf("=0;--j)if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length)tbody[j].parentNode.removeChild(tbody[j]);if(/^\s/.test(elem))div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);}elem=jQuery.makeArray(div.childNodes);}if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select")))return;if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options)ret.push(elem);else 23 | ret=jQuery.merge(ret,elem);});return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)return undefined;var fix=jQuery.isXMLDoc(elem)?{}:jQuery.props;if(name=="selected"&&jQuery.browser.safari)elem.parentNode.selectedIndex;if(fix[name]){if(value!=undefined)elem[fix[name]]=value;return elem[fix[name]];}else if(jQuery.browser.msie&&name=="style")return jQuery.attr(elem.style,"cssText",value);else if(value==undefined&&jQuery.browser.msie&&jQuery.nodeName(elem,"form")&&(name=="action"||name=="method"))return elem.getAttributeNode(name).nodeValue;else if(elem.tagName){if(value!=undefined){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)throw"type property can't be changed";elem.setAttribute(name,""+value);}if(jQuery.browser.msie&&/href|src/.test(name)&&!jQuery.isXMLDoc(elem))return elem.getAttribute(name,2);return elem.getAttribute(name);}else{if(name=="opacity"&&jQuery.browser.msie){if(value!=undefined){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseFloat(value).toString()=="NaN"?"":"alpha(opacity="+value*100+")");}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100).toString():"";}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(value!=undefined)elem[name]=value;return elem[name];}},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(typeof array!="array")for(var i=0,length=array.length;i*",this).remove();while(this.firstChild)this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");};});var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");jQuery.extend({expr:{"":"m[2]=='*'||jQuery.nodeName(a,m[2])","#":"a.getAttribute('id')==m[2]",":":{lt:"im[3]-0",nth:"m[3]-0==i",eq:"m[3]-0==i",first:"i==0",last:"i==r.length-1",even:"i%2==0",odd:"i%2","first-child":"a.parentNode.getElementsByTagName('*')[0]==a","last-child":"jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a","only-child":"!jQuery.nth(a.parentNode.lastChild,2,'previousSibling')",parent:"a.firstChild",empty:"!a.firstChild",contains:"(a.textContent||a.innerText||jQuery(a).text()||'').indexOf(m[3])>=0",visible:'"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',hidden:'"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"',enabled:"!a.disabled",disabled:"a.disabled",checked:"a.checked",selected:"a.selected||jQuery.attr(a,'selected')",text:"'text'==a.type",radio:"'radio'==a.type",checkbox:"'checkbox'==a.type",file:"'file'==a.type",password:"'password'==a.type",submit:"'submit'==a.type",image:"'image'==a.type",reset:"'reset'==a.type",button:'"button"==a.type||jQuery.nodeName(a,"button")',input:"/input|select|textarea|button/i.test(a.nodeName)",has:"jQuery.find(m[3],a).length",header:"/h\\d/i.test(a.nodeName)",animated:"jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length"}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];while(expr&&expr!=old){old=expr;var f=jQuery.filter(expr,elems,not);expr=f.t.replace(/^\s*,\s*/,"");cur=not?elems=f.r:jQuery.merge(cur,f.r);}return cur;},find:function(t,context){if(typeof t!="string")return[t];if(context&&context.nodeType!=1&&context.nodeType!=9)return[];context=context||document;var ret=[context],done=[],last,nodeName;while(t&&last!=t){var r=[];last=t;t=jQuery.trim(t);var foundToken=false;var re=quickChild;var m=re.exec(t);if(m){nodeName=m[1].toUpperCase();for(var i=0;ret[i];i++)for(var c=ret[i].firstChild;c;c=c.nextSibling)if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName))r.push(c);ret=r;t=t.replace(re,"");if(t.indexOf(" ")==0)continue;foundToken=true;}else{re=/^([>+~])\s*(\w*)/i;if((m=re.exec(t))!=null){r=[];var merge={};nodeName=m[2].toUpperCase();m=m[1];for(var j=0,rl=ret.length;j=0;if(!not&&pass||not&&!pass)tmp.push(r[i]);}return tmp;},filter:function(t,r,not){var last;while(t&&t!=last){last=t;var p=jQuery.parse,m;for(var i=0;p[i];i++){m=p[i].exec(t);if(m){t=t.substring(m[0].length);m[2]=m[2].replace(/\\/g,"");break;}}if(!m)break;if(m[1]==":"&&m[2]=="not")r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);else if(m[1]==".")r=jQuery.classFilter(r,m[2],not);else if(m[1]=="["){var tmp=[],type=m[3];for(var i=0,rl=r.length;i=0)^not)tmp.push(a);}r=tmp;}else if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;for(var i=0,rl=r.length;i=0)add=true;if(add^not)tmp.push(node);}r=tmp;}else{var f=jQuery.expr[m[1]];if(typeof f!="string")f=jQuery.expr[m[1]][m[2]];f=eval("false||function(a,i){return "+f+"}");r=jQuery.grep(r,f,not);}}return{r:r,t:t};},dir:function(elem,dir){var matched=[];var cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)matched.push(cur);cur=cur[dir];}return matched;},nth:function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir])if(cur.nodeType==1&&++num==result)break;return cur;},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&(!elem||n!=elem))r.push(n);}return r;}});jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)return;if(jQuery.browser.msie&&elem.setInterval!=undefined)elem=window;if(!handler.guid)handler.guid=this.guid++;if(data!=undefined){var fn=handler;handler=function(){return fn.apply(this,arguments);};handler.data=data;handler.guid=fn.guid;}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){var val;if(typeof jQuery=="undefined"||jQuery.event.triggered)return val;val=jQuery.event.handle.apply(arguments.callee.elem,arguments);return val;});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];handler.type=parts[1];var handlers=events[type];if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener)elem.addEventListener(type,handle,false);else if(elem.attachEvent)elem.attachEvent("on"+type,handle);}}handlers[handler.guid]=handler;jQuery.event.global[type]=true;});elem=null;},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8)return;var events=jQuery.data(elem,"events"),ret,index;if(events){if(types==undefined)for(var type in events)this.remove(elem,type);else{if(types.type){handler=types.handler;types=types.type;}jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];if(events[type]){if(handler)delete events[type][handler.guid];else 26 | for(handler in events[type])if(!parts[1]||events[type][handler].type==parts[1])delete events[type][handler];for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener)elem.removeEventListener(type,jQuery.data(elem,"handle"),false);else if(elem.detachEvent)elem.detachEvent("on"+type,jQuery.data(elem,"handle"));}ret=null;delete events[type];}}});}for(ret in events)break;if(!ret){var handle=jQuery.data(elem,"handle");if(handle)handle.elem=null;jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle");}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data||[]);if(!elem){if(this.global[type])jQuery("*").add([window,document]).trigger(type,data);}else{if(elem.nodeType==3||elem.nodeType==8)return undefined;var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;if(event)data.unshift(this.fix({type:type,target:elem}));data[0].type=type;if(jQuery.isFunction(jQuery.data(elem,"handle")))val=jQuery.data(elem,"handle").apply(elem,data);if(!fn&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)val=false;if(event)data.shift();if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));if(ret!==undefined)val=ret;}if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}this.triggered=false;}return val;},handle:function(event){var val;event=jQuery.event.fix(event||window.event||{});var parts=event.type.split(".");event.type=parts[0];var handlers=jQuery.data(this,"events")&&jQuery.data(this,"events")[event.type],args=Array.prototype.slice.call(arguments,1);args.unshift(event);for(var j in handlers){var handler=handlers[j];args[0].handler=handler;args[0].data=handler.data;if(!parts[1]||handler.type==parts[1]){var ret=handler.apply(this,args);if(val!==false)val=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}}if(jQuery.browser.msie)event.target=event.preventDefault=event.stopPropagation=event.handler=event.data=null;return val;},fix:function(event){var originalEvent=event;event=jQuery.extend({},originalEvent);event.preventDefault=function(){if(originalEvent.preventDefault)originalEvent.preventDefault();originalEvent.returnValue=false;};event.stopPropagation=function(){if(originalEvent.stopPropagation)originalEvent.stopPropagation();originalEvent.cancelBubble=true;};if(!event.target)event.target=event.srcElement||document;if(event.target.nodeType==3)event.target=originalEvent.target.parentNode;if(!event.relatedTarget&&event.fromElement)event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode))event.which=event.charCode||event.keyCode;if(!event.metaKey&&event.ctrlKey)event.metaKey=event.ctrlKey;if(!event.which&&event.button)event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));return event;},special:{ready:{setup:function(){bindReady();return;},teardown:function(){return;}},mouseenter:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);return true;},handler:function(event){if(withinElement(event,this))return true;arguments[0].type="mouseenter";return jQuery.event.handle.apply(this,arguments);}},mouseleave:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);return true;},handler:function(event){if(withinElement(event,this))return true;arguments[0].type="mouseleave";return jQuery.event.handle.apply(this,arguments);}}}};jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);});},one:function(type,data,fn){return this.each(function(){jQuery.event.add(this,type,function(event){jQuery(this).unbind(event);return(fn||data).apply(this,arguments);},fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);});},triggerHandler:function(type,data,fn){if(this[0])return jQuery.event.trigger(type,data,this[0],false,fn);return undefined;},toggle:function(){var args=arguments;return this.click(function(event){this.lastToggle=0==this.lastToggle?1:0;event.preventDefault();return args[this.lastToggle].apply(this,arguments)||false;});},hover:function(fnOver,fnOut){return this.bind('mouseenter',fnOver).bind('mouseleave',fnOut);},ready:function(fn){bindReady();if(jQuery.isReady)fn.call(document,jQuery);else 27 | jQuery.readyList.push(function(){return fn.call(this,jQuery);});return this;}});jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.apply(document);});jQuery.readyList=null;}jQuery(document).triggerHandler("ready");}}});var readyBound=false;function bindReady(){if(readyBound)return;readyBound=true;if(document.addEventListener&&!jQuery.browser.opera)document.addEventListener("DOMContentLoaded",jQuery.ready,false);if(jQuery.browser.msie&&window==top)(function(){if(jQuery.isReady)return;try{document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,0);return;}jQuery.ready();})();if(jQuery.browser.opera)document.addEventListener("DOMContentLoaded",function(){if(jQuery.isReady)return;for(var i=0;i=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}callback=callback||function(){};var type="GET";if(params)if(jQuery.isFunction(params)){callback=params;params=null;}else{params=jQuery.param(params);type="POST";}var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified")self.html(selector?jQuery("
").append(res.responseText.replace(//g,"")).find(selector):res.responseText);self.each(callback,[res.responseText,status,res]);}});return this;},serialize:function(){return jQuery.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return jQuery.nodeName(this,"form")?jQuery.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:val.constructor==Array?jQuery.map(val,function(val,i){return{name:elem.name,value:val};}):{name:elem.name,value:val};}).get();}});jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);};});var jsc=(new Date).getTime();jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data=null;}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data={};}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);},ajaxSettings:{global:true,type:"GET",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:null,username:null,password:null,accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){var jsonp,jsre=/=\?(&|$)/g,status,data;s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));if(s.data&&s.processData&&typeof s.data!="string")s.data=jQuery.param(s.data);if(s.dataType=="jsonp"){if(s.type.toLowerCase()=="get"){if(!s.url.match(jsre))s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";}else if(!s.data||!s.data.match(jsre))s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";s.dataType="json";}if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;if(s.data)s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp];}catch(e){}if(head)head.removeChild(script);};}if(s.dataType=="script"&&s.cache==null)s.cache=false;if(s.cache===false&&s.type.toLowerCase()=="get"){var ts=(new Date()).getTime();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");}if(s.data&&s.type.toLowerCase()=="get"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null;}if(s.global&&!jQuery.active++)jQuery.event.trigger("ajaxStart");if((!s.url.indexOf("http")||!s.url.indexOf("//"))&&(s.dataType=="script"||s.dataType=="json")&&s.type.toLowerCase()=="get"){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=s.url;if(s.scriptCharset)script.charset=s.scriptCharset;if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;success();complete();head.removeChild(script);}};}head.appendChild(script);return undefined;}var requestDone=false;var xml=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();xml.open(s.type,s.url,s.async,s.username,s.password);try{if(s.data)xml.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)xml.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xml.setRequestHeader("X-Requested-With","XMLHttpRequest");xml.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}if(s.beforeSend)s.beforeSend(xml);if(s.global)jQuery.event.trigger("ajaxSend",[xml,s]);var onreadystatechange=function(isTimeout){if(!requestDone&&xml&&(xml.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xml)&&"error"||s.ifModified&&jQuery.httpNotModified(xml,s.url)&&"notmodified"||"success";if(status=="success"){try{data=jQuery.httpData(xml,s.dataType);}catch(e){status="parsererror";}}if(status=="success"){var modRes;try{modRes=xml.getResponseHeader("Last-Modified");}catch(e){}if(s.ifModified&&modRes)jQuery.lastModified[s.url]=modRes;if(!jsonp)success();}else 28 | jQuery.handleError(s,xml,status);complete();if(s.async)xml=null;}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0)setTimeout(function(){if(xml){xml.abort();if(!requestDone)onreadystatechange("timeout");}},s.timeout);}try{xml.send(s.data);}catch(e){jQuery.handleError(s,xml,null,e);}if(!s.async)onreadystatechange();function success(){if(s.success)s.success(data,status);if(s.global)jQuery.event.trigger("ajaxSuccess",[xml,s]);}function complete(){if(s.complete)s.complete(xml,status);if(s.global)jQuery.event.trigger("ajaxComplete",[xml,s]);if(s.global&&!--jQuery.active)jQuery.event.trigger("ajaxStop");}return xml;},handleError:function(s,xml,status,e){if(s.error)s.error(xml,status,e);if(s.global)jQuery.event.trigger("ajaxError",[xml,s,e]);},active:0,httpSuccess:function(r){try{return!r.status&&location.protocol=="file:"||(r.status>=200&&r.status<300)||r.status==304||r.status==1223||jQuery.browser.safari&&r.status==undefined;}catch(e){}return false;},httpNotModified:function(xml,url){try{var xmlRes=xml.getResponseHeader("Last-Modified");return xml.status==304||xmlRes==jQuery.lastModified[url]||jQuery.browser.safari&&xml.status==undefined;}catch(e){}return false;},httpData:function(r,type){var ct=r.getResponseHeader("content-type");var xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0;var data=xml?r.responseXML:r.responseText;if(xml&&data.documentElement.tagName=="parsererror")throw"parsererror";if(type=="script")jQuery.globalEval(data);if(type=="json")data=eval("("+data+")");return data;},param:function(a){var s=[];if(a.constructor==Array||a.jquery)jQuery.each(a,function(){s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));});else 29 | for(var j in a)if(a[j]&&a[j].constructor==Array)jQuery.each(a[j],function(){s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));});else 30 | s.push(encodeURIComponent(j)+"="+encodeURIComponent(a[j]));return s.join("&").replace(/%20/g,"+");}});jQuery.fn.extend({show:function(speed,callback){return speed?this.animate({height:"show",width:"show",opacity:"show"},speed,callback):this.filter(":hidden").each(function(){this.style.display=this.oldblock||"";if(jQuery.css(this,"display")=="none"){var elem=jQuery("<"+this.tagName+" />").appendTo("body");this.style.display=elem.css("display");if(this.style.display=="none")this.style.display="block";elem.remove();}}).end();},hide:function(speed,callback){return speed?this.animate({height:"hide",width:"hide",opacity:"hide"},speed,callback):this.filter(":visible").each(function(){this.oldblock=this.oldblock||jQuery.css(this,"display");this.style.display="none";}).end();},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle(fn,fn2):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();});},slideDown:function(speed,callback){return this.animate({height:"show"},speed,callback);},slideUp:function(speed,callback){return this.animate({height:"hide"},speed,callback);},slideToggle:function(speed,callback){return this.animate({height:"toggle"},speed,callback);},fadeIn:function(speed,callback){return this.animate({opacity:"show"},speed,callback);},fadeOut:function(speed,callback){return this.animate({opacity:"hide"},speed,callback);},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);return this[optall.queue===false?"each":"queue"](function(){if(this.nodeType!=1)return false;var opt=jQuery.extend({},optall);var hidden=jQuery(this).is(":hidden"),self=this;for(var p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden)return jQuery.isFunction(opt.complete)&&opt.complete.apply(this);if(p=="height"||p=="width"){opt.display=jQuery.css(this,"display");opt.overflow=this.style.overflow;}}if(opt.overflow!=null)this.style.overflow="hidden";opt.curAnim=jQuery.extend({},prop);jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);if(/toggle|show|hide/.test(val))e[val=="toggle"?hidden?"show":"hide":val](prop);else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";if(unit!="px"){self.style[name]=(end||1)+unit;start=((end||1)/e.cur(true))*start;self.style[name]=start+unit;}if(parts[1])end=((parts[1]=="-="?-1:1)*end)+start;e.custom(start,end,unit);}else 31 | e.custom(start,val,"");}});return true;});},queue:function(type,fn){if(jQuery.isFunction(type)||(type&&type.constructor==Array)){fn=type;type="fx";}if(!type||(typeof type=="string"&&!fn))return queue(this[0],type);return this.each(function(){if(fn.constructor==Array)queue(this,type,fn);else{queue(this,type).push(fn);if(queue(this,type).length==1)fn.apply(this);}});},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;if(clearQueue)this.queue([]);this.each(function(){for(var i=timers.length-1;i>=0;i--)if(timers[i].elem==this){if(gotoEnd)timers[i](true);timers.splice(i,1);}});if(!gotoEnd)this.dequeue();return this;}});var queue=function(elem,type,array){if(!elem)return undefined;type=type||"fx";var q=jQuery.data(elem,type+"queue");if(!q||array)q=jQuery.data(elem,type+"queue",array?jQuery.makeArray(array):[]);return q;};jQuery.fn.dequeue=function(type){type=type||"fx";return this.each(function(){var q=queue(this,type);q.shift();if(q.length)q[0].apply(this);});};jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&speed.constructor==Object?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&easing.constructor!=Function&&easing};opt.duration=(opt.duration&&opt.duration.constructor==Number?opt.duration:{slow:600,fast:200}[opt.duration])||400;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false)jQuery(this).dequeue();if(jQuery.isFunction(opt.old))opt.old.apply(this);};return opt;},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;}},timers:[],timerId:null,fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig)options.orig={};}});jQuery.fx.prototype={update:function(){if(this.options.step)this.options.step.apply(this.elem,[this.now,this]);(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if(this.prop=="height"||this.prop=="width")this.elem.style.display="block";},cur:function(force){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null)return this.elem[this.prop];var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;},custom:function(from,to,unit){this.startTime=(new Date()).getTime();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;this.update();var self=this;function t(gotoEnd){return self.step(gotoEnd);}t.elem=this.elem;jQuery.timers.push(t);if(jQuery.timerId==null){jQuery.timerId=setInterval(function(){var timers=jQuery.timers;for(var i=0;ithis.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var done=true;for(var i in this.options.curAnim)if(this.options.curAnim[i]!==true)done=false;if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(jQuery.css(this.elem,"display")=="none")this.elem.style.display="block";}if(this.options.hide)this.elem.style.display="none";if(this.options.hide||this.options.show)for(var p in this.options.curAnim)jQuery.attr(this.elem.style,p,this.options.orig[p]);}if(done&&jQuery.isFunction(this.options.complete))this.options.complete.apply(this.elem);return false;}else{var n=t-this.startTime;this.state=n/this.options.duration;this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update();}return true;}};jQuery.fx.step={scrollLeft:function(fx){fx.elem.scrollLeft=fx.now;},scrollTop:function(fx){fx.elem.scrollTop=fx.now;},opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);},_default:function(fx){fx.elem.style[fx.prop]=fx.now+fx.unit;}};jQuery.fn.offset=function(){var left=0,top=0,elem=this[0],results;if(elem)with(jQuery.browser){var parent=elem.parentNode,offsetChild=elem,offsetParent=elem.offsetParent,doc=elem.ownerDocument,safari2=safari&&parseInt(version)<522,fixed=jQuery.css(elem,"position")=="fixed";if(elem.getBoundingClientRect){var box=elem.getBoundingClientRect();add(box.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),box.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));add(-doc.documentElement.clientLeft,-doc.documentElement.clientTop);}else{add(elem.offsetLeft,elem.offsetTop);while(offsetParent){add(offsetParent.offsetLeft,offsetParent.offsetTop);if(mozilla&&!/^t(able|d|h)$/i.test(offsetParent.tagName)||safari&&!safari2)border(offsetParent);if(!fixed&&jQuery.css(offsetParent,"position")=="fixed")fixed=true;offsetChild=/^body$/i.test(offsetParent.tagName)?offsetChild:offsetParent;offsetParent=offsetParent.offsetParent;}while(parent&&parent.tagName&&!/^body|html$/i.test(parent.tagName)){if(!/^inline|table.*$/i.test(jQuery.css(parent,"display")))add(-parent.scrollLeft,-parent.scrollTop);if(mozilla&&jQuery.css(parent,"overflow")!="visible")border(parent);parent=parent.parentNode;}if((safari2&&(fixed||jQuery.css(offsetChild,"position")=="absolute"))||(mozilla&&jQuery.css(offsetChild,"position")!="absolute"))add(-doc.body.offsetLeft,-doc.body.offsetTop);if(fixed)add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));}results={top:top,left:left};}function border(elem){add(jQuery.curCSS(elem,"borderLeftWidth",true),jQuery.curCSS(elem,"borderTopWidth",true));}function add(l,t){left+=parseInt(l)||0;top+=parseInt(t)||0;}return results;};})(); -------------------------------------------------------------------------------- /lib/sporx.js: -------------------------------------------------------------------------------- 1 | window._log=function(){window.console && console.log.apply(console, arguments);}; 2 | window._profile=function(){window.console && (arguments.length?console.profile:console.profileEnd).apply(console, arguments);}; 3 | 4 | var image_total_height = 0; 5 | 6 | function l_i(a){if(a in l_ma)return l_ma[a];return l_ma[a]=navigator.userAgent.toLowerCase().indexOf(a)!=-1} 7 | var l_ma={}; 8 | function l_h(){return l_i("msie")&&!window.opera} 9 | function l_ha(){return l_i("safari")||l_i("konqueror")} 10 | 11 | var l_ra={Xa:function(a){return a.document.body.scrollTop},Ya:function(a){return a.document.documentElement.scrollTop},Va:function(a){return a.pageYOffset}}; 12 | var l_sa={Xa:function(a){return a.document.body.scrollLeft},Ya:function(a){return a.document.documentElement.scrollLeft},Va:function(a){return a.pageXOffset}}; 13 | var l_ta={Xa:function(a){return a.document.body.clientHeight},Ya:function(a){return a.document.documentElement.clientHeight},Va:function(a){return a.innerHeight}}; 14 | function l_r(a,b){try{if(!window.opera&&"compatMode"in a.document&&a.document.compatMode=="CSS1Compat")return b.Ya(a);else if(l_h())return b.Xa(a)}catch(c){}return b.Va(a)} 15 | 16 | function get_pageHeight(w){ 17 | return l_r(w || window,l_ta) 18 | } 19 | function get_pageOffsetX(w){ 20 | return l_r(w || window,l_sa) 21 | } 22 | function get_pageOffsetY(w){ 23 | return l_r(w || window,l_ra) 24 | } 25 | 26 | var l_ua=/&/g,l_va=//g; 27 | var l_xa=/\"/g; 28 | var l_ws=/ /g; 29 | function escape_html_(a){if(!a)return"";return a.replace(l_ua,"&").replace(l_va,"<").replace(l_wa,">").replace(l_xa,""").replace(l_ws," ")} 30 | 31 | function escape_html(a){ 32 | if(!a)return ''; 33 | 34 | var m = {'&': '&', '>': '>', '<': '<', ' ': ' '}; 35 | return a.replace(/[&<> ]/g,function(a){ 36 | return m[a]; 37 | }); 38 | } 39 | 40 | 41 | // Sporx 42 | var Sporx = window.Sporx = function() {}; 43 | var floatProp = document.all?'styleFloat':'cssFloat'; 44 | 45 | var savedAnchor; 46 | 47 | Sporx.prototype = { 48 | dispatch: function () { 49 | var anchor = location.hash; 50 | anchor = anchor.replace(/^\#/, ''); 51 | if (anchor == savedAnchor) { 52 | return; 53 | } 54 | 55 | if (anchor == "") { 56 | anchor = '#1'; 57 | location.hash = anchor; 58 | } 59 | 60 | savedAnchor = anchor; 61 | var match = anchor.match(/^\d+$/); 62 | if (match) { 63 | sporx.showSlide(parseInt(match[0]) - 1); 64 | } else { 65 | location.hash = savedAnchor = '#' + (sporx.current + 1); 66 | } 67 | }, 68 | 69 | start: function() { 70 | 71 | this.size = 9; 72 | 73 | this._offset = 0; 74 | // 存储显示区域 75 | this.canvas = document.getElementById('canvas'); 76 | 77 | /* 78 | addEv(document.body, 'click', function(e){ 79 | if (e.altKey || e.ctrlKey) { 80 | return false; 81 | } 82 | 83 | var target = e.target || e.srcElement; 84 | alert("target: " + target.parentNode.tagName); 85 | if (target.parentNode && target.parentNode == document.body) { 86 | //alert("target: " + e.target.tagName); 87 | sporx.onPresentationClick(e); 88 | } 89 | }); 90 | */ 91 | 92 | // addEv(this.canvas, 'dblclick', function(ev){ sporx.prevSlide(); }); 93 | 94 | //addEv(document.body, 'contextmenu', function(ev){return false;alert(1);}); 95 | 96 | function resize_canvas(){ 97 | sporx.canvas.style.height = (get_pageHeight() - 40) + 'px'; 98 | sporx.adjustCanvasSize(); 99 | } 100 | resize_canvas(); 101 | $(window).resize(resize_canvas); 102 | 103 | // 存储显示数据 104 | this.content = document.getElementById('content'); 105 | 106 | // 编辑用 107 | /* 108 | this.textbox = document.getElementById('textField'); 109 | this.deck = document.getElementById('deck'); 110 | */ 111 | this.scroller = document.getElementById('scroller'); 112 | 113 | this.toolbar = document.getElementById('canvasToolbar'); 114 | this.toolbarHeight = this.toolbar.offsetHeight; 115 | this.hide_toolbar(); 116 | 117 | var slides_text = document.getElementById('builtinCode').value; 118 | 119 | this.slides = this.splitSlides(slides_text); 120 | 121 | this.current = 0; 122 | if (String(location).match(/#(\d+)$/)) { 123 | this.current = parseInt(RegExp.$1, 10) - 1; 124 | } 125 | 126 | document.getElementById("max_page").innerHTML = this.slides.length; 127 | 128 | if (this.slides.length) { 129 | if (!document.title) { 130 | document.title = this.slides[0]. 131 | replace(/[\r\n]/g, ' '). 132 | replace(/\{\{(.*\|)?\s*/g, ''). 133 | replace(/\s*\}\}/g, ''); 134 | } 135 | 136 | this.dataFolder = ('' + location.href).split('?')[0].replace(/[^\/]+$/, ''); 137 | this.takahashi(); 138 | } 139 | }, 140 | 141 | updateUrl: function() { 142 | location.hash = '#' + (this.current + 1); 143 | }, 144 | 145 | hide_toolbar: function() { 146 | this.toolbar.style.top = (0-this.toolbarHeight) + 'px'; 147 | this.isToolbarHidden = true; 148 | }, 149 | 150 | onPresentationClick: function(aEvent) { 151 | aEvent = aEvent || window.event; 152 | if (!this.isToolbarHidden) 153 | this.showHideToolbar(); 154 | 155 | var target = aEvent.target || aEvent.srcElement; 156 | var uri = target.getAttribute('href'); 157 | if (uri) { 158 | window.open(uri); 159 | } else { 160 | this.nextSlide(); 161 | } 162 | 163 | }, 164 | 165 | fix_pre: function(text) { 166 | return text; 167 | 168 | return text.replace( 169 | /((^ .*\n)+)/mg, function(m, $1) { 170 | return '.pre\n' + $1 + '.pre\n'; 171 | } 172 | ); 173 | }, 174 | 175 | takahashi: function(cb) { 176 | var num = this.current; 177 | this.updateUrl(); 178 | 179 | document.getElementById("current_page").value = num + 1; 180 | 181 | //this.scroller.setAttribute('maxpos', this.data().length - 1); 182 | //this.scroller.setAttribute('curpos', this.offset); 183 | 184 | this.canvas.rendering = true; 185 | 186 | var text = this.slides[num]; 187 | if (!text) { 188 | //alert("current page: " + num); 189 | return; 190 | } 191 | text = text. 192 | replace(/^[\r\n]+/,""). 193 | replace(/[\r\n]+$/,""). 194 | replace(/(\r\n|\r)/g,"\n"). 195 | split('\n'); 196 | 197 | this.content.innerHTML = ''; 198 | this.content.style.top = 0; 199 | 200 | var line; 201 | 202 | var labelId = 0; 203 | 204 | //for (var i = 0; i < text.length; i++) 205 | 206 | while (line = text.shift()) { 207 | this.content.appendChild(document.createElement('div')); 208 | this.content.lastChild.setAttribute('align', 'center'); 209 | //this.content.lastChild.setAttribute('pack', 'center'); 210 | 211 | //line = text[i]; 212 | image_width = 0; 213 | image_height = 0; 214 | 215 | if (line.match(/^\*\s+/)) { 216 | var ul = document.createElement('ul'); 217 | while (line.match(/^\*\s+/)) { 218 | var li = document.createElement('li'); 219 | var line_text = line.replace(/^\*\s+/, ''); 220 | // li.appendChild(document.createTextNode(line_text)); 221 | li.appendChild(document.createElement('div')); 222 | this.inlineMarkupMess(line_text, li); 223 | ul.appendChild(li); 224 | //i++; 225 | //line = text[i]; 226 | line = text.shift(); 227 | if (! line) line = ''; 228 | } 229 | this.content.appendChild(ul); 230 | continue; 231 | } 232 | 233 | if (line.charAt(0) === ' ') { 234 | this.content.lastChild.setAttribute('align', 'left'); 235 | this.content.lastChild.setAttribute('class', 'pre-big'); 236 | line = line.substring(1); 237 | //_log('"' + line + '"'); 238 | //line = line.replace(/ /g, ' '); 239 | } 240 | 241 | this.inlineMarkupMess(line, this.content); 242 | 243 | image_total_width = Math.max(image_total_width, image_width); 244 | image_total_height += image_height; 245 | } 246 | 247 | // 调整 slide 适应屏幕尺寸 248 | window.setTimeout(function () { 249 | sporx.adjustCanvasSize(); 250 | if (cb) { 251 | setTimeout(cb, 100); 252 | } 253 | }, 100); 254 | 255 | this.canvas.rendering = null; 256 | }, 257 | 258 | adjustCanvasSize: function() { 259 | // alert(arguments.callee.caller); 260 | if (!this.content) { 261 | return; 262 | } 263 | 264 | var contentStyle = this.content.style; 265 | function setFontSize(s) { 266 | contentStyle.fontSize = (s < 1 ? 1 : s) + 'px'; 267 | } 268 | 269 | //alert("font size: " + this.size); 270 | setFontSize(this.size); 271 | 272 | if (this.content.offsetHeight) { 273 | var canvas_w = this.canvas.offsetWidth; 274 | var canvas_h = this.canvas.offsetHeight - image_total_height; 275 | 276 | this.canvas.style.width = '9999px'; 277 | this.content.style[floatProp] = 'left'; 278 | 279 | var content_w = this.content.offsetWidth; 280 | var new_fs = Math.floor((canvas_w/content_w) * this.size); 281 | 282 | setFontSize(new_fs); 283 | 284 | if (this.content.offsetWidth < image_total_width) { 285 | content_w = image_total_width; 286 | new_fs = Math.floor((canvas_w/content_w) * this.size); 287 | setFontSize(new_fs); 288 | } 289 | 290 | this.canvas.style.width = ''; 291 | this.content.style[floatProp] = ''; 292 | 293 | var content_h = this.content.offsetHeight; 294 | if (content_h >= canvas_h) { 295 | new_fs = Math.ceil((canvas_h/content_h) * new_fs); 296 | setFontSize(new_fs); 297 | } 298 | 299 | content_h = this.content.offsetHeight; 300 | //content_h = 0; 301 | //_log("content_h: " + content_h); 302 | canvas_h = this.canvas.offsetHeight; 303 | 304 | var diff = canvas_h - content_h; 305 | /* 306 | _log("diff: " + diff + ", content_h: " 307 | + content_h + ", canvas_h: " 308 | + diff + ", content top: " 309 | + this.content.style.top); 310 | */ 311 | if (diff > 20) { 312 | //_log("adjusting... diff"); 313 | this.content.style.top = diff/2.8 + 'px'; 314 | } else if (this.content.style.top != 0) { 315 | //_log("adjusting... 0"); 316 | this.content.style.top = 0; 317 | } 318 | 319 | //_log("after top: " + this.content.style.top); 320 | } 321 | }, 322 | 323 | inlineMarkupMess: function(line, content) { 324 | 325 | var uri; 326 | image_total_width = 0; 327 | image_total_height = 0; 328 | var image_src; 329 | //alert("HERE!"); 330 | /* + + + + + + + + + + + + + + 331 | ^ 332 | ((?: 333 | [^\{] 334 | | 335 | \{[^\{] 336 | )+)? 337 | ( 338 | \{\{ima?ge? +src="([^"]+)" +width="([0-9]+)" +height="([0-9]+)"[^\}]*\}\} -> {{img src width height}} 339 | | -> {{image src width height}} 340 | \{\{(([^\|]+)?\||)(.+?)\}\} -> {{abc||def}} 341 | ) 342 | (.+)? 343 | 344 | 345 | $1 -> 普通文本 346 | $2 -> 图像和特殊标记 347 | $3 -> 图像地址 348 | $4 -> 图像宽度 349 | $5 -> 图像高度 350 | $6 -> abc||def 这样标记中的 abc|| 351 | $7 -> abc||def 这样标记中的 abc 352 | $8 -> abc||def 这样标记中的 def 353 | $9 -> 剩余数据 354 | + + + + + + + + + + + + + + */ 355 | 356 | var m; 357 | while (m = line.match(/^((?:[^\{]|\{[^\{])+)?(\{\{ima?ge? +src="([^"]+)" +width="([0-9]+)" +height="([0-9]+)"[^\}]*\}\}|\{\{(([^\|]+)?\||)(.+?)\}\})(.+)?/)) { 358 | if (RegExp.$1) { 359 | content.lastChild.appendChild( 360 | document.createElement('span') 361 | ); 362 | content.lastChild.lastChild.innerHTML = escape_html(RegExp.$1); 363 | 364 | this.fixPre(content.lastChild); 365 | } 366 | 367 | //_log(line, m); 368 | 369 | // Images 370 | if (/^((?:[^\{]|\{[^\{])+)?\{\{ima?ge? +src="([^\"]+)" +width="([0-9]+)" +height="([0-9]+)"[^\}]*\}\}/.test(line)) { 371 | content.lastChild. 372 | appendChild(document.createElement('img')); 373 | 374 | var image_src = RegExp.$2; 375 | if (image_src.indexOf('http://') < 0 && 376 | image_src.indexOf('https://') < 0) 377 | image_src = this.dataFolder + image_src; 378 | content.lastChild.lastChild.src = image_src; 379 | content.lastChild.lastChild.width = parseInt(RegExp.$3 || '0'); 380 | content.lastChild.lastChild.height = parseInt(RegExp.$4 || '0'); 381 | content.lastChild.lastChild.alt = ""; 382 | image_width += parseInt(RegExp.$3 || '0'); 383 | image_height = Math.max(image_height, parseInt(RegExp.$4 || '0')); 384 | 385 | this.fixPre(content.lastChild); 386 | 387 | } 388 | 389 | // Styles 普通带 class 文本,不是 link 390 | else if (/^((?:[^\{]|\{[^\{])+)?\{\{(#([^\|]+)?\|)(.+?)\}\}/.test(line)) { 391 | uri = RegExp.$4; // 误导的变量名 392 | className = RegExp.$3; 393 | content.lastChild. 394 | appendChild(document.createElement('span')); 395 | content.lastChild.lastChild.innerHTML = escape_html(uri); 396 | content.lastChild.lastChild.className = className; 397 | this.fixPre(content.lastChild); 398 | } 399 | 400 | // Links 401 | else if (/^((?:[^\{]|\{[^\{])+)?\{\{(([^\|]+)?\||)([^\}]+)\}\}/.test(line)) { 402 | uri = RegExp.$4; 403 | if (uri.indexOf('://') < 0) 404 | uri = this.dataFolder + uri; 405 | content.lastChild. 406 | appendChild(document.createElement('a')); 407 | 408 | content.lastChild.lastChild.innerHTML = escape_html(RegExp.$3 || RegExp.$4); 409 | content.lastChild.lastChild.href = uri; 410 | content.lastChild.lastChild.title = uri; 411 | content.lastChild.lastChild.target = '_blank'; 412 | content.lastChild.lastChild.className = 'link-text'; 413 | this.fixPre(content.lastChild); 414 | } 415 | 416 | line = m[9] || ''; 417 | } 418 | 419 | if (line) { 420 | //_log("text node: " + line); 421 | //_log("parent class name: " + content.lastChild.className); 422 | content.lastChild.appendChild(document.createElement('span')); 423 | content.lastChild.lastChild.innerHTML = escape_html(line); 424 | this.fixPre(content.lastChild); 425 | } 426 | 427 | }, 428 | 429 | fixPre: function (node) { 430 | /* 431 | if (/\bpre-big\b/.test(node.className)) { 432 | _log("found pre!!! " + node.className); 433 | } 434 | */ 435 | if (node.lastChild.className) { 436 | //node.lastChild.className += ' pre'; 437 | } else { 438 | //node.lastChild.className = 'pre'; 439 | } 440 | }, 441 | 442 | nextSlide: function() { 443 | if (this.current < (this.slides.length - 1)) { 444 | this.current++; 445 | this.takahashi(); 446 | } 447 | }, 448 | 449 | prevSlide: function() { 450 | if (this.current > 0) { 451 | this.current--; 452 | this.takahashi(); 453 | } 454 | }, 455 | 456 | printPdf: function() { 457 | var me = this; 458 | var xx = $('
'); 459 | var cont = $(me.content); 460 | var h = $(me.canvas).height(); 461 | var i = this.slides.length - 1; 462 | 463 | if (adjustTimer) { 464 | clearInterval(adjustTimer); 465 | adjustTimer = null; 466 | } 467 | 468 | if (dispatchTimer) { 469 | clearInterval(dispatchTimer); 470 | dispatchTimer = null; 471 | } 472 | 473 | function step() { 474 | xx.prepend(cont.clone().attr("_id", me.current).css({'height': h, 'page-break-after': 'always'})); 475 | // console.log(me.content, h); 476 | 477 | if (i > 0) { 478 | me.current = --i; 479 | setTimeout(proc, 0); 480 | 481 | } else { 482 | xx.prependTo(document.body); 483 | $(document.body).addClass('in-print'); 484 | window.print(); 485 | $(document.body).removeClass('in-print'); 486 | } 487 | } 488 | 489 | function proc() { 490 | me.takahashi(step); 491 | } 492 | 493 | me.current = i; 494 | proc(); 495 | }, 496 | 497 | firstSlide: function() { 498 | if (this.current != 0) { 499 | this.current = 0; 500 | this.takahashi(); 501 | } 502 | }, 503 | 504 | lastSlide: function() { 505 | if (this.current != this.slides.length - 1) { 506 | this.current = this.slides.length - 1; 507 | this.takahashi(); 508 | } 509 | }, 510 | 511 | showSlide: function(n) { 512 | n = Math.min(this.slides.length - 1, Math.max(0, n)); 513 | 514 | if (this.current != n) { 515 | this.current = n; 516 | this.takahashi(); 517 | } 518 | }, 519 | 520 | splitSlides: function(text) { 521 | var slides = text. 522 | replace(/\n__END__\r?\n[\s\S]*/m, '\n'). 523 | replace(/&/g, '&'). 524 | replace(/</g, '<'). 525 | split(/(?:^|\n)----[\r\n]/); 526 | 527 | for (var i = 0; i < slides.length; i++) { 528 | var slide = slides[i]; 529 | 530 | // 去除 # 开头的 slide 531 | if (slide.match(/^\n*$/) || slide.match(/^\s*#/)) { 532 | slides.splice(i, 1); 533 | i--; 534 | continue; 535 | } 536 | 537 | // + 开头的 条目 单独分到页面里去 538 | var set = []; 539 | if (slide.match(/^([\s\S]*?\n)\+/)) { 540 | while (slide.match(/^([\s\S]*?\n)\+/)) { 541 | set.push(RegExp.$1); 542 | slide = slide.replace(/\n\+/, '\n'); 543 | } 544 | set.push(slide); 545 | } 546 | if (set.length) { 547 | slides.splice(i, 1, set[0]); 548 | for (var j = 1; j < set.length; j++) { 549 | slides.splice(++i, 0, set[j]); 550 | } 551 | } 552 | } 553 | 554 | for (i = slides.length - 1; i >= 0; i--) { 555 | slides[i] = slides[i].replace(/\\(["\\])/g, '$1'); 556 | } 557 | 558 | return slides; 559 | }, 560 | 561 | onToolbarArea: false, 562 | toolbarHeight: 0, 563 | toolbarDelay: 300, 564 | toolbarTimer: null, 565 | isToolbarHidden: false, 566 | 567 | onMouseMoveOnCanvas: function(aEvent) { 568 | this.onToolbarArea = (aEvent.clientY < this.toolbarHeight); 569 | 570 | if (this.isToolbarHidden == this.onToolbarArea) { 571 | if (this.toolbarTimer) 572 | window.clearTimeout(this.toolbarTimer); 573 | 574 | this.toolbarTimer = window.setTimeout( 575 | function() { 576 | sporx.onMouseMoveOnCanvasCallback(); 577 | }, 578 | this.toolbarDelay 579 | ); 580 | } 581 | }, 582 | 583 | onMouseMoveOnCanvasCallback: function() { 584 | if (this.isToolbarHidden == this.onToolbarArea) 585 | this.showHideToolbar(); 586 | }, 587 | 588 | toolbarAnimationDelay: 100, 589 | toolbarAnimationSteps: 5, 590 | toolbarAnimationInfo: null, 591 | toolbarAnimationTimer: null, 592 | 593 | showHideToolbar: function() { 594 | if (this.toolbarAnimationTimer) 595 | window.clearTimeout(this.toolbarAnimationTimer); 596 | 597 | this.toolbarAnimationInfo = { count : 0 }; 598 | if (this.isToolbarHidden) { 599 | this.toolbarAnimationInfo.start = 0; 600 | this.toolbarAnimationInfo.end = this.toolbarHeight; 601 | } 602 | else { 603 | this.toolbarAnimationInfo.start = this.toolbarHeight; 604 | this.toolbarAnimationInfo.end = 0; 605 | } 606 | this.toolbarAnimationInfo.current = 0; 607 | 608 | this.toolbar.style.top = 609 | (0-(this.toolbarHeight-this.toolbarAnimationInfo.start)) + 'px'; 610 | 611 | this.toolbarAnimationTimer = window.setTimeout( 612 | function() { 613 | sporx.animateToolbar(); 614 | }, 615 | this.toolbarAnimationDelay/this.toolbarAnimationSteps 616 | ); 617 | }, 618 | 619 | animateToolbar: function() { 620 | this.toolbarAnimationInfo.current += 621 | parseInt(this.toolbarHeight/this.toolbarAnimationSteps); 622 | 623 | var top, bottom; 624 | if (this.toolbarAnimationInfo.start < this.toolbarAnimationInfo.end) { 625 | top = this.toolbarHeight-this.toolbarAnimationInfo.current; 626 | bottom = this.toolbarAnimationInfo.current; 627 | } 628 | else { 629 | top = this.toolbarAnimationInfo.current; 630 | bottom = this.toolbarHeight-this.toolbarAnimationInfo.current; 631 | } 632 | 633 | top = Math.min(Math.max(top, 0), this.toolbarHeight); 634 | bottom = Math.min(Math.max(bottom, 0), this.toolbarHeight); 635 | 636 | this.toolbar.style.top = (0-top) + 'px'; 637 | 638 | if (this.toolbarAnimationInfo.count < this.toolbarAnimationSteps) { 639 | this.toolbarAnimationInfo.count++; 640 | this.toolbarAnimationTimer = window.setTimeout( 641 | function() { 642 | sporx.animateToolbar(); 643 | }, 644 | this.toolbarAnimationDelay/this.toolbarAnimationSteps 645 | ); 646 | } 647 | else 648 | this.isToolbarHidden = !this.isToolbarHidden; 649 | } 650 | } 651 | 652 | //------------------------------------------------------------------------------ 653 | // Initialization code 654 | //------------------------------------------------------------------------------ 655 | 656 | var sporx; 657 | var adjustTimer; 658 | var dispatchTimer; 659 | 660 | $(window).ready(function () { 661 | sporx = new Sporx(); 662 | sporx.start(); 663 | 664 | adjustTimer = setInterval(function () { 665 | var sel; 666 | if (document.getSelection) { 667 | sel = document.getSelection(); 668 | } else { 669 | sel = document.selection; 670 | } 671 | 672 | if (!sel) { 673 | sporx.adjustCanvasSize(); 674 | //_log("selection: \"" + sel + "\""); 675 | } 676 | }, 200); 677 | 678 | dispatchTimer = setInterval(sporx.dispatch, 500); 679 | 680 | $(document.body).mousemove(function(e){ 681 | sporx.onMouseMoveOnCanvas(e); 682 | }); 683 | 684 | $(document).keydown(function(e){ 685 | //alert("Hi"); 686 | if (String(location.hash).match(/^#edit$/)) 687 | return; 688 | 689 | if (e.altKey || e.ctrlKey) { 690 | return; 691 | } 692 | 693 | key = e.keyCode; 694 | 695 | //alert("key: " + key); 696 | //_log("key: " + key); 697 | switch(key) { 698 | case 8: 699 | case 33: 700 | case 37: 701 | case 38: 702 | case 112: 703 | e.preventDefault(); 704 | sporx.prevSlide(); 705 | break; 706 | case 13: 707 | case 32: 708 | case 34: 709 | case 39: 710 | case 40: 711 | case 110: 712 | e.preventDefault(); 713 | sporx.nextSlide(); 714 | break; 715 | default: 716 | //xxx(e.which) 717 | break; 718 | } 719 | }); 720 | }); 721 | 722 | //------------------------------------------------------------------------------ 723 | // Sporx String Filters 724 | //------------------------------------------------------------------------------ 725 | String.prototype.convertPerl5ToPerl6 = function() { 726 | return this.replace(/print/g, 'say'); 727 | } 728 | 729 | String.prototype.current = function(regexp) { 730 | return this.replace(regexp, '{{#c|$1}}'); 731 | } 732 | 733 | String.prototype.color = function(regexp) { 734 | return this.current(regexp); 735 | } 736 | 737 | //------------------------------------------------------------------------------ 738 | // Debugging Support 739 | //------------------------------------------------------------------------------ 740 | 741 | function XXX(msg) { 742 | if (! confirm(msg)) 743 | throw("terminated..."); 744 | return msg; 745 | } 746 | 747 | function JJJ(obj) { 748 | XXX(JSON.stringify(obj)); 749 | return obj; 750 | } 751 | 752 | //------------------------------------------------------------------------------ 753 | // JSON Support 754 | //------------------------------------------------------------------------------ 755 | 756 | /* 757 | Copyright (c) 2005 JSON.org 758 | */ 759 | var JSON = function () { 760 | var m = { 761 | '\b': '\\b', 762 | '\t': '\\t', 763 | '\n': '\\n', 764 | '\f': '\\f', 765 | '\r': '\\r', 766 | '"' : '\\"', 767 | '\\': '\\\\' 768 | }, 769 | s = { 770 | 'boolean': function (x) { 771 | return String(x); 772 | }, 773 | number: function (x) { 774 | return isFinite(x) ? String(x) : 'null'; 775 | }, 776 | string: function (x) { 777 | if (/["\\\x00-\x1f]/.test(x)) { 778 | x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) { 779 | var c = m[b]; 780 | if (c) { 781 | return c; 782 | } 783 | c = b.charCodeAt(); 784 | return '\\u00' + 785 | Math.floor(c / 16).toString(16) + 786 | (c % 16).toString(16); 787 | }); 788 | } 789 | return '"' + x + '"'; 790 | }, 791 | object: function (x) { 792 | if (x) { 793 | var a = [], b, f, i, l, v; 794 | if (x instanceof Array) { 795 | a[0] = '['; 796 | l = x.length; 797 | for (i = 0; i < l; i += 1) { 798 | v = x[i]; 799 | f = s[typeof v]; 800 | if (f) { 801 | v = f(v); 802 | if (typeof v == 'string') { 803 | if (b) { 804 | a[a.length] = ','; 805 | } 806 | a[a.length] = v; 807 | b = true; 808 | } 809 | } 810 | } 811 | a[a.length] = ']'; 812 | } else if (x instanceof Object) { 813 | a[0] = '{'; 814 | for (i in x) { 815 | v = x[i]; 816 | f = s[typeof v]; 817 | if (f) { 818 | v = f(v); 819 | if (typeof v == 'string') { 820 | if (b) { 821 | a[a.length] = ','; 822 | } 823 | a.push(s.string(i), ':', v); 824 | b = true; 825 | } 826 | } 827 | } 828 | a[a.length] = '}'; 829 | } else { 830 | return; 831 | } 832 | return a.join(''); 833 | } 834 | return 'null'; 835 | } 836 | }; 837 | return { 838 | copyright: '(c)2005 JSON.org', 839 | license: 'http://www.crockford.com/JSON/license.html', 840 | stringify: function (v) { 841 | var f = s[typeof v]; 842 | if (f) { 843 | v = f(v); 844 | if (typeof v == 'string') { 845 | return v; 846 | } 847 | } 848 | return null; 849 | }, 850 | parse: function (text) { 851 | try { 852 | return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test( 853 | text.replace(/"(\\.|[^"\\])*"/g, ''))) && 854 | eval('(' + text + ')'); 855 | } catch (e) { 856 | return false; 857 | } 858 | } 859 | }; 860 | }(); 861 | 862 | 863 | /* 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 917 | 918 | */ 919 | // vim: se ts=4 sts=4 sw=4 : 920 | -------------------------------------------------------------------------------- /sample-slides.sld: -------------------------------------------------------------------------------- 1 | 2 | Introduction to 3 | our X & X cluster 4 | 5 | ☺{{#author|agentzh@yahoo.cn}}☺ 6 | {{#author|章亦春 (agentzh)}} 7 | {{#date|2009.9}} 8 | ---- 9 | 10 | 11 | V 12 | 13 | ➥ X DOM 14 | ➥ DOMs with CI 15 | 16 | 17 | ---- 18 | 19 | KW KW=X<"http://foo.bar.com/index.html"> 20 | KW=802 KW=929 21 | KW=943 KW=1272 { 22 | KW KW=914 KW=5119 { 23 | V<...> 24 | } 25 | } 26 | 27 | ---- 28 | 29 | KW KW=0 KW=0 KW=914 30 | KW=5119 31 | KW="Helvetica,Arial,sans-serif" 32 | KW="12px" KW="normal" 33 | KW="400" KW="rgb(0, 0, 0)" 34 | KW="rgb(255, 255, 255)" { 35 | X<"\\n "> w=0 { 36 | } 37 | KW
KW="append_parent" KW=0 KW=0 38 | KW=0 KW="transparent" { 39 | X<"首页\\n\\n"> KW=1 KW=1 { 40 | V<...> 41 | } 42 | } 43 | X<"\\n "> w=0 { 44 | } 45 | } 46 | 47 | ---- 48 | 49 | KW KW="rgb(255, 0, 0)" { 50 | KW KW="401" { 51 | X<"购物"> KW=32 KW=56 { 52 | } 53 | } 54 | } 55 | 56 | ---- 57 | 58 | "Why CI language?" 59 | "Why X just borrow HTML or XML's syntax?" 60 | 61 | ---- 62 | 63 | CM<✓> We want to keep VDOM dump size CI. 64 | CM<✓> We want to keep VDOM dump CI. 65 | CM<✓> We want to make VDOM more X and more 66 | X. 67 | (Yeah, XML/HTML's syntax is very I.) 68 | CM<✓> We want to make VDOM I & I 69 | CI to implement and verify. 70 | (tens of lines of Perl for example ;)) 71 | CM<✓> Low level structures like CI and CI 72 | are hard to express naturally in HTML or XML. 73 | 74 | ---- 75 | 76 | X<☺> We've already made both 77 | Mozilla X and Apple X I VDOMs 78 | 79 | ---- 80 | {{img src="images/gen-vdom.png"}} 81 | 82 | ---- 83 | 84 | CM<# Generate VDOM from the command line:> 85 | V<$> CI --enable-js --proxy=proxy.cn:1080 \\ 86 | http://www.sina.com.cn > sina.vdom 87 | 88 | CM<# Or access our vdomkit FastCGI server directly by HTTP:> 89 | V<$> curl 'http://vdom.cn.yahoo.com/vdom?X' \\ 90 | > sina.vdom 91 | 92 | ---- 93 | 94 | CM<# The VDOM dump is much smaller than the original HTML:> 95 | V<$> ls -lh CI 96 | -rw------- 1 agentz agentz X<278K> 2009-04-10 10:30 sina.vdom 97 | 98 | V<$> ls -lh CI 99 | -rw-r--r-- 1 agentz agentz X<400K> 2009-04-10 10:34 sina.html 100 | 101 | ---- 102 | 103 | CM<✓> Now CI enjoys X 104 | as good as those in JavaScript. 105 | 106 | ---- 107 | 108 | KW VDOM; 109 | KW V<$in>, X<"sina.vdom"> or die V<$!>; 110 | KW V<$win> = VDOM::Window->new->parse_file(V<$in>); 111 | KW V<$body> = V<$win>->document->body; 112 | KW V<$child> (V<$body>->childNodes) { 113 | print V<$child>->tagName; 114 | print V<$child>->x; 115 | print V<$child>->h; 116 | print V<$child>->color; 117 | print V<$child>->fontFamily; 118 | V<...> 119 | } 120 | 121 | ---- 122 | 123 | print V<$child>->nextSibling; 124 | V<$win>->document->getElementById(X<"foo">); 125 | 126 | CM<# These are Firefox 3.1 DOM methods, we have too ;)> 127 | print V<$child>->previousElementSibling; 128 | print V<$child>->firstElementChild; 129 | 130 | print $child->parentNode; 131 | print KW X<' '>, 132 | KW { V<$$_>->href . X<': '> . V<$$_>->textContent } 133 | V<$child>->getElmenetsByTagName(X<"A">); 134 | 135 | ---- 136 | {{img src="images/vdom-pm.png"}} 137 | ---- 138 | {{img src="images/vdom-pm2.png"}} 139 | ---- 140 | 141 | CM<☺> I our Perl code from within CI 142 | via our X extension 143 | 144 | ---- 145 | {{img src="images/visualdom-ch.png"}} 146 | ---- 147 | {{img src="images/visualdom-ch-cfg.png"}} 148 | ---- 149 | {{img src="images/between-ff-perl.png"}} 150 | ---- 151 | {{img src="images/visualdom-lh.png"}} 152 | ---- 153 | {{img src="images/visualdom-lh-cfg.png"}} 154 | ---- 155 | 156 | CM<☺> The CI of our X extension: 157 | I 158 | 159 | ---- 160 | {{img src="images/vdom-browser-config.png"}} 161 | ---- 162 | {{img src="images/ch-eeee.png"}} 163 | ---- 164 | {{img src="images/ch-bbs-big.png"}} 165 | ---- 166 | {{img src="images/ch-bbs-guided.png"}} 167 | ---- 168 | {{img src="images/between-vdombrowser-perl.png"}} 169 | ---- 170 | CM<☺> We can get geometry information of 171 | every CI in the DOM! 172 | ---- 173 | {{img src="images/vb-text-nodes.png"}} 174 | ---- 175 | ...or even as small as CI! 176 | (text run is the undividable component of a text node 177 | which has no line breaks in it) 178 | ---- 179 | {{img src="images/vb-text-runs.png"}} 180 | ---- 181 | 182 | CM<☺> Put everything into a CI. 183 | 184 | ---- 185 | {{img src="images/cluster-arch.png"}} 186 | ---- 187 | {{img src="images/vdomwebkit-farm.png"}} 188 | ---- 189 | {{img src="images/proxy-guts2.png"}} 190 | ---- 191 | {{img src="images/prefetcher-guts.png"}} 192 | ---- 193 | {{img src="images/memcacheq-guts.png"}} 194 | ---- 195 | CM<☺> Most of the components have been CI 196 | ---- 197 | QtWebKit with CI 198 | ➥ {{http://github.com/agentzh/vdomwebkit/}} 199 | ---- 200 | vdomkit (CI utility and CI interface) 201 | ➥ {{http://github.com/agentzh/vdomkit/}} 202 | ---- 203 | VDOM Browser 204 | ➥ {{http://github.com/agentzh/vdombrowser/}} 205 | ---- 206 | VDOM.pm 207 | ➥ {{http://github.com/agentzh/vdompm/}} 208 | ---- 209 | queue-size-aware version of CI 210 | ➥ {{http://github.com/agentzh/memcacheq/}} 211 | ---- 212 | Queue::Memcached::Buffered (a CI for memcacheq) 213 | ➥ {{http://github.com/agentzh/queue-memcached-buffered/}} 214 | ---- 215 | 216 | X 217 | 218 | X<☺> haibo++ persuaded me to believe that the CI of browser 219 | rendering engines and our hunter extractors via VDOM dumping 220 | could give rise to CI of benefits. 221 | X<☺> jianingy++ effectively CI the great WebKit craze in our team. 222 | X<☺> xunxin++ CI Visual DOM extension's JavaScript VDOM dumper 223 | to qt-webkit C++ and did most of the hard work in CI. 224 | X<☺> xunxin++ CI patched sina's memcacheq to make it aware 225 | of queue sizes. 226 | X<☺> mingyou++ shared a great deal of his CI of the WebKit 227 | internals with us and also gave very good suggestions for the 228 | slides you're browsing. 229 | 230 | ---- 231 | 232 | ☺ CI? ☺ 233 | 234 | ---- 235 | 236 | -------------------------------------------------------------------------------- /template/license.html: -------------------------------------------------------------------------------- 1 | 23 | -------------------------------------------------------------------------------- /template/sporx.html: -------------------------------------------------------------------------------- 1 | [%- DEFAULT css_location='css/sporx.css' -%] 2 | [%- DEFAULT javascript_runtime='lib/sporx.js' -%] 3 | [%- DEFAULT jquery_path='lib/jquery.js' -%] 4 | [%- DEFAULT license_template='template/license.html' -%] 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 20 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | / 34 | 35 |
36 |
37 |
38 |
39 | 40 |
41 | 42 |
43 | 46 | 47 | 48 | [% INCLUDE $license_template %] 49 | 50 | --------------------------------------------------------------------------------