| 1 | | var dp={sh:{Toolbar:{},Utils:{},RegexLib:{},Brushes:{},Strings:{},Version:"1.4.0"}};dp.sh.Strings={AboutDialog:"<html><head><title>About...</title></head><body class=\"dp-about\"><table cellspacing=\"0\"><tr><td class=\"copy\"><p class=\"title\">dp.SyntaxHighlighter</div><div class=\"para\">Version: {V}</p><p><a href=\"http://www.dreamprojections.com/syntaxhighlighter/?ref=about\" target=\"_blank\">http://www.dreamprojections.com/SyntaxHighlighter</a></p>©2004-2005 Alex Gorbatchev. All right reserved.</td></tr><tr><td class=\"footer\"><input type=\"button\" class=\"close\" value=\"OK\" onClick=\"window.close()\"/></td></tr></table></body></html>"};dp.SyntaxHighlighter=dp.sh;dp.sh.Toolbar.Commands={ExpandSource:{label:"+ expand source",check:function(_1){return _1.collapse;},func:function(_2,_3){_2.parentNode.removeChild(_2);_3.div.className=_3.div.className.replace("collapsed","");}},ViewSource:{label:"view plain",func:function(_4,_5){var _6=_5.originalCode.replace(/</g,"<");var _7=window.open("","_blank","width=750, height=400, location=0, resizable=1, menubar=0, scrollbars=1");_7.document.write("<textarea style=\"width:99%;height:99%\">"+_6+"</textarea>");_7.document.close();}},CopyToClipboard:{label:"copy to clipboard",check:function(){return window.clipboardData!=null;},func:function(_8,_9){window.clipboardData.setData("text",_9.originalCode);alert("The code is in your clipboard now");}},PrintSource:{label:"print",func:function(_a,_b){var _c=document.createElement("IFRAME");var _d=null;_c.style.cssText="position:absolute;width:0px;height:0px;left:-500px;top:-500px;";document.body.appendChild(_c);_d=_c.contentWindow.document;dp.sh.Utils.CopyStyles(_d,window.document);_d.write("<div class=\""+_b.div.className.replace("collapsed","")+" printing\">"+_b.div.innerHTML+"</div>");_d.close();_c.contentWindow.focus();_c.contentWindow.print();alert("Printing...");document.body.removeChild(_c);}},About:{label:"?",func:function(_e){var _f=window.open("","_blank","dialog,width=300,height=150,scrollbars=0");var doc=_f.document;dp.sh.Utils.CopyStyles(doc,window.document);doc.write(dp.sh.Strings.AboutDialog.replace("{V}",dp.sh.Version));doc.close();_f.focus();}}};dp.sh.Toolbar.Create=function(_11){var div=document.createElement("DIV");div.className="tools";for(var _13 in dp.sh.Toolbar.Commands){var cmd=dp.sh.Toolbar.Commands[_13];if(cmd.check!=null&&!cmd.check(_11)){continue;}div.innerHTML+="<a href=\"#\" onclick=\"dp.sh.Toolbar.Command('"+_13+"',this);return false;\">"+cmd.label+"</a>";}return div;};dp.sh.Toolbar.Command=function(_15,_16){var n=_16;while(n!=null&&n.className.indexOf("dp-highlighter")==-1){n=n.parentNode;}if(n!=null){dp.sh.Toolbar.Commands[_15].func(_16,n.highlighter);}};dp.sh.Utils.CopyStyles=function(_18,_19){var _1a=_19.getElementsByTagName("link");for(var i=0;i<_1a.length;i++){if(_1a[i].rel.toLowerCase()=="stylesheet"){_18.write("<link type=\"text/css\" rel=\"stylesheet\" href=\""+_1a[i].href+"\"></link>");}}};dp.sh.RegexLib={MultiLineCComments:new RegExp("/\\*[\\s\\S]*?\\*/","gm"),SingleLineCComments:new RegExp("//.*$","gm"),SingleLinePerlComments:new RegExp("#.*$","gm"),DoubleQuotedString:new RegExp("\"(?:\\.|(\\\\\\\")|[^\\\"\"])*\"","g"),SingleQuotedString:new RegExp("'(?:\\.|(\\\\\\')|[^\\''])*'","g")};dp.sh.Match=function(_1c,_1d,css){this.value=_1c;this.index=_1d;this.length=_1c.length;this.css=css;};dp.sh.Highlighter=function(){this.addGutter=true;this.addControls=true;this.collapse=false;this.tabsToSpaces=true;this.wrapColumn=80;this.showColumns=true;};dp.sh.Highlighter.SortCallback=function(m1,m2){if(m1.index<m2.index){return -1;}else{if(m1.index>m2.index){return 1;}else{if(m1.length<m2.length){return -1;}else{if(m1.length>m2.length){return 1;}}}}return 0;};dp.sh.Highlighter.prototype.CreateElement=function(_21){var _22=document.createElement(_21);_22.highlighter=this;return _22;};dp.sh.Highlighter.prototype.GetMatches=function(_23,css){var _25=0;var _26=null;while((_26=_23.exec(this.code))!=null){this.matches[this.matches.length]=new dp.sh.Match(_26[0],_26.index,css);}};dp.sh.Highlighter.prototype.AddBit=function(str,css){if(str==null||str.length==0){return;}var _29=this.CreateElement("SPAN");str=str.replace(/&/g,"&");str=str.replace(/ /g," ");str=str.replace(/</g,"<");str=str.replace(/\n/gm," <br>");if(css!=null){var _2a=new RegExp("<br>","gi");if(_2a.test(str)){var _2b=str.split(" <br>");str="";for(var i=0;i<_2b.length;i++){_29=this.CreateElement("SPAN");_29.className=css;_29.innerHTML=_2b[i];this.div.appendChild(_29);if(i+1<_2b.length){this.div.appendChild(this.CreateElement("BR"));}}}else{_29.className=css;_29.innerHTML=str;this.div.appendChild(_29);}}else{_29.innerHTML=str;this.div.appendChild(_29);}};dp.sh.Highlighter.prototype.IsInside=function(_2d){if(_2d==null||_2d.length==0){return false;}for(var i=0;i<this.matches.length;i++){var c=this.matches[i];if(c==null){continue;}if((_2d.index>c.index)&&(_2d.index<c.index+c.length)){return true;}}return false;};dp.sh.Highlighter.prototype.ProcessRegexList=function(){for(var i=0;i<this.regexList.length;i++){this.GetMatches(this.regexList[i].regex,this.regexList[i].css);}};dp.sh.Highlighter.prototype.ProcessSmartTabs=function(_31){var _32=_31.split("\n");var _33="";var _34=4;var tab="\t";function InsertSpaces(_36,pos,_38){var _39=_36.substr(0,pos);var _3a=_36.substr(pos+1,_36.length);var _3b="";for(var i=0;i<_38;i++){_3b+=" ";}return _39+_3b+_3a;}function ProcessLine(_3d,_3e){if(_3d.indexOf(tab)==-1){return _3d;}var pos=0;while((pos=_3d.indexOf(tab))!=-1){var _40=_3e-pos%_3e;_3d=InsertSpaces(_3d,pos,_40);}return _3d;}for(var i=0;i<_32.length;i++){_33+=ProcessLine(_32[i],_34)+"\n";}return _33;};dp.sh.Highlighter.prototype.SwitchToList=function(){var _42=this.div.innerHTML.replace(/<(br)\/?>/gi,"\n");var _43=_42.split("\n");if(this.addControls==true){this.bar.appendChild(dp.sh.Toolbar.Create(this));}if(this.showColumns){var div=this.CreateElement("div");var _45=this.CreateElement("div");var _46=10;var i=1;while(i<=150){if(i%_46==0){div.innerHTML+=i;i+=(i+"").length;}else{div.innerHTML+="·";i++;}}_45.className="columns";_45.appendChild(div);this.bar.appendChild(_45);}for(var i=0,lineIndex=this.firstLine;i<_43.length-1;i++,lineIndex++){var li=this.CreateElement("LI");var _4a=this.CreateElement("SPAN");li.className=(i%2==0)?"alt":"";_4a.innerHTML=_43[i]+" ";li.appendChild(_4a);this.ol.appendChild(li);}this.div.innerHTML="";};dp.sh.Highlighter.prototype.Highlight=function(_4b){function Trim(str){return str.replace(/^\s*(.*?)[\s\n]*$/g,"$1");}function Chop(str){return str.replace(/\n*$/,"").replace(/^\n*/,"");}function Unindent(str){var _4f=str.split("\n");var _50=new Array();var _51=new RegExp("^\\s*","g");var min=1000;for(var i=0;i<_4f.length&&min>0;i++){if(Trim(_4f[i]).length==0){continue;}var _54=_51.exec(_4f[i]);if(_54!=null&&_54.length>0){min=Math.min(_54[0].length,min);}}if(min>0){for(var i=0;i<_4f.length;i++){_4f[i]=_4f[i].substr(min);}}return _4f.join("\n");}function Copy(_56,_57,_58){return _56.substr(_57,_58-_57);}var pos=0;this.originalCode=_4b;this.code=Chop(Unindent(_4b));this.div=this.CreateElement("DIV");this.bar=this.CreateElement("DIV");this.ol=this.CreateElement("OL");this.matches=new Array();this.div.className="dp-highlighter";this.div.highlighter=this;this.bar.className="bar";this.ol.start=this.firstLine;if(this.CssClass!=null){this.ol.className=this.CssClass;}if(this.collapse){this.div.className+=" collapsed";}if(this.tabsToSpaces==true){this.code=this.ProcessSmartTabs(this.code);}this.ProcessRegexList();if(this.matches.length==0){this.AddBit(this.code,null);this.SwitchToList();this.div.appendChild(this.ol);return;}this.matches=this.matches.sort(dp.sh.Highlighter.SortCallback);for(var i=0;i<this.matches.length;i++){if(this.IsInside(this.matches[i])){this.matches[i]=null;}}for(var i=0;i<this.matches.length;i++){var _5c=this.matches[i];if(_5c==null||_5c.length==0){continue;}this.AddBit(Copy(this.code,pos,_5c.index),null);this.AddBit(_5c.value,_5c.css);pos=_5c.index+_5c.length;}this.AddBit(this.code.substr(pos),null);this.SwitchToList();this.div.appendChild(this.bar);this.div.appendChild(this.ol);};dp.sh.Highlighter.prototype.GetKeywords=function(str){return "\\b"+str.replace(/ /g,"\\b|\\b")+"\\b";};dp.sh.HighlightAll=function(_5e,_5f,_60,_61,_62,_63){function FindValue(){var a=arguments;for(var i=0;i<a.length;i++){if(a[i]==null){continue;}if(typeof (a[i])=="string"&&a[i]!=""){return a[i]+"";}if(typeof (a[i])=="object"&&a[i].value!=""){return a[i].value+"";}}return null;}function IsOptionSet(_66,_67){for(var i=0;i<_67.length;i++){if(_67[i]==_66){return true;}}return false;}function GetOptionValue(_69,_6a,_6b){var _6c=new RegExp("^"+_69+"\\[(\\w+)\\]$","gi");var _6d=null;for(var i=0;i<_6a.length;i++){if((_6d=_6c.exec(_6a[i]))!=null){return _6d[1];}}return _6b;}var _6f=document.getElementsByName(_5e);var _70=null;var _71=new Object();var _72="value";if(_6f==null){return;}for(var _73 in dp.sh.Brushes){var _74=dp.sh.Brushes[_73].Aliases;if(_74==null){continue;}for(var i=0;i<_74.length;i++){_71[_74[i]]=_73;}}for(var i=0;i<_6f.length;i++){var _77=_6f[i];var _78=FindValue(_77.attributes["class"],_77.className,_77.attributes["language"],_77.language);var _79="";if(_78==null){continue;}_78=_78.split(":");_79=_78[0].toLowerCase();if(_71[_79]==null){continue;}_70=new dp.sh.Brushes[_71[_79]]();_77.style.display="none";_70.addGutter=(_5f==null)?!IsOptionSet("nogutter",_78):_5f;_70.addControls=(_60==null)?!IsOptionSet("nocontrols",_78):_60;_70.collapse=(_61==null)?IsOptionSet("collapse",_78):_61;_70.showColumns=(_63==null)?IsOptionSet("showcolumns",_78):_63;_70.firstLine=(_62==null)?parseInt(GetOptionValue("firstline",_78,1)):_62;_70.Highlight(_77[_72]);_77.parentNode.insertBefore(_70.div,_77);}}; |
| | 1 | var dp={sh:{Toolbar:{},Utils:{},RegexLib:{},Brushes:{},Strings:{AboutDialog:"<html><head><title>About...</title></head><body class=\"dp-about\"><table cellspacing=\"0\"><tr><td class=\"copy\"><p class=\"title\">dp.SyntaxHighlighter</div><div class=\"para\">Version: {V}</p><p><a href=\"http://www.dreamprojections.com/syntaxhighlighter/?ref=about\" target=\"_blank\">http://www.dreamprojections.com/syntaxhighlighter</a></p>©2004-2007 Alex Gorbatchev.</td></tr><tr><td class=\"footer\"><input type=\"button\" class=\"close\" value=\"OK\" onClick=\"window.close()\"/></td></tr></table></body></html>"},ClipboardSwf:null,Version:"1.5"}}; |
| | 2 | dp.SyntaxHighlighter=dp.sh; |
| | 3 | dp.sh.Toolbar.Commands={ExpandSource:{label:"+ expand source",check:function(_1){ |
| | 4 | return _1.collapse; |
| | 5 | },func:function(_2,_3){ |
| | 6 | _2.parentNode.removeChild(_2); |
| | 7 | _3.div.className=_3.div.className.replace("collapsed",""); |
| | 8 | }},ViewSource:{label:"view plain",func:function(_4,_5){ |
| | 9 | var _6=_5.originalCode.replace(/</g,"<"); |
| | 10 | var _7=window.open("","_blank","width=750, height=400, location=0, resizable=1, menubar=0, scrollbars=0"); |
| | 11 | _7.document.write("<textarea style=\"width:99%;height:99%\">"+_6+"</textarea>"); |
| | 12 | _7.document.close(); |
| | 13 | }},CopyToClipboard:{label:"copy to clipboard",check:function(){ |
| | 14 | return window.clipboardData!=null||dp.sh.ClipboardSwf!=null; |
| | 15 | },func:function(_8,_9){ |
| | 16 | var _a=_9.originalCode; |
| | 17 | if(window.clipboardData){ |
| | 18 | window.clipboardData.setData("text",_a); |
| | 19 | }else{ |
| | 20 | if(dp.sh.ClipboardSwf!=null){ |
| | 21 | var _b=_9.flashCopier; |
| | 22 | if(_b==null){ |
| | 23 | _b=document.createElement("div"); |
| | 24 | _9.flashCopier=_b; |
| | 25 | _9.div.appendChild(_b); |
| | 26 | } |
| | 27 | _b.innerHTML="<embed src=\""+dp.sh.ClipboardSwf+"\" FlashVars=\"clipboard="+encodeURIComponent(_a)+"\" width=\"0\" height=\"0\" type=\"application/x-shockwave-flash\"></embed>"; |
| | 28 | } |
| | 29 | } |
| | 30 | alert("The code is in your clipboard now"); |
| | 31 | }},PrintSource:{label:"print",func:function(_c,_d){ |
| | 32 | var _e=document.createElement("IFRAME"); |
| | 33 | var _f=null; |
| | 34 | _e.style.cssText="position:absolute;width:0px;height:0px;left:-500px;top:-500px;"; |
| | 35 | document.body.appendChild(_e); |
| | 36 | _f=_e.contentWindow.document; |
| | 37 | dp.sh.Utils.CopyStyles(_f,window.document); |
| | 38 | _f.write("<div class=\""+_d.div.className.replace("collapsed","")+" printing\">"+_d.div.innerHTML+"</div>"); |
| | 39 | _f.close(); |
| | 40 | _e.contentWindow.focus(); |
| | 41 | _e.contentWindow.print(); |
| | 42 | alert("Printing..."); |
| | 43 | document.body.removeChild(_e); |
| | 44 | }},About:{label:"?",func:function(_10){ |
| | 45 | var wnd=window.open("","_blank","dialog,width=300,height=150,scrollbars=0"); |
| | 46 | var doc=wnd.document; |
| | 47 | dp.sh.Utils.CopyStyles(doc,window.document); |
| | 48 | doc.write(dp.sh.Strings.AboutDialog.replace("{V}",dp.sh.Version)); |
| | 49 | doc.close(); |
| | 50 | wnd.focus(); |
| | 51 | }}}; |
| | 52 | dp.sh.Toolbar.Create=function(_13){ |
| | 53 | var div=document.createElement("DIV"); |
| | 54 | div.className="tools"; |
| | 55 | for(var _15 in dp.sh.Toolbar.Commands){ |
| | 56 | var cmd=dp.sh.Toolbar.Commands[_15]; |
| | 57 | if(cmd.check!=null&&!cmd.check(_13)){ |
| | 58 | continue; |
| | 59 | } |
| | 60 | div.innerHTML+="<a href=\"#\" onclick=\"dp.sh.Toolbar.Command('"+_15+"',this);return false;\">"+cmd.label+"</a>"; |
| | 61 | } |
| | 62 | return div; |
| | 63 | }; |
| | 64 | dp.sh.Toolbar.Command=function(_17,_18){ |
| | 65 | var n=_18; |
| | 66 | while(n!=null&&n.className.indexOf("dp-highlighter")==-1){ |
| | 67 | n=n.parentNode; |
| | 68 | } |
| | 69 | if(n!=null){ |
| | 70 | dp.sh.Toolbar.Commands[_17].func(_18,n.highlighter); |
| | 71 | } |
| | 72 | }; |
| | 73 | dp.sh.Utils.CopyStyles=function(_1a,_1b){ |
| | 74 | var _1c=_1b.getElementsByTagName("link"); |
| | 75 | for(var i=0;i<_1c.length;i++){ |
| | 76 | if(_1c[i].rel.toLowerCase()=="stylesheet"){ |
| | 77 | _1a.write("<link type=\"text/css\" rel=\"stylesheet\" href=\""+_1c[i].href+"\"></link>"); |
| | 78 | } |
| | 79 | } |
| | 80 | }; |
| | 81 | dp.sh.RegexLib={MultiLineCComments:new RegExp("/\\*[\\s\\S]*?\\*/","gm"),SingleLineCComments:new RegExp("//.*$","gm"),SingleLinePerlComments:new RegExp("#.*$","gm"),DoubleQuotedString:new RegExp("\"(?:\\.|(\\\\\\\")|[^\\\"\"])*\"","g"),SingleQuotedString:new RegExp("'(?:\\.|(\\\\\\')|[^\\''])*'","g")}; |
| | 82 | dp.sh.Match=function(_1e,_1f,css){ |
| | 83 | this.value=_1e; |
| | 84 | this.index=_1f; |
| | 85 | this.length=_1e.length; |
| | 86 | this.css=css; |
| | 87 | }; |
| | 88 | dp.sh.Highlighter=function(){ |
| | 89 | this.noGutter=false; |
| | 90 | this.addControls=true; |
| | 91 | this.collapse=false; |
| | 92 | this.tabsToSpaces=true; |
| | 93 | this.wrapColumn=80; |
| | 94 | this.showColumns=true; |
| | 95 | }; |
| | 96 | dp.sh.Highlighter.SortCallback=function(m1,m2){ |
| | 97 | if(m1.index<m2.index){ |
| | 98 | return -1; |
| | 99 | }else{ |
| | 100 | if(m1.index>m2.index){ |
| | 101 | return 1; |
| | 102 | }else{ |
| | 103 | if(m1.length<m2.length){ |
| | 104 | return -1; |
| | 105 | }else{ |
| | 106 | if(m1.length>m2.length){ |
| | 107 | return 1; |
| | 108 | } |
| | 109 | } |
| | 110 | } |
| | 111 | } |
| | 112 | return 0; |
| | 113 | }; |
| | 114 | dp.sh.Highlighter.prototype.CreateElement=function(_23){ |
| | 115 | var _24=document.createElement(_23); |
| | 116 | _24.highlighter=this; |
| | 117 | return _24; |
| | 118 | }; |
| | 119 | dp.sh.Highlighter.prototype.GetMatches=function(_25,css){ |
| | 120 | var _27=0; |
| | 121 | var _28=null; |
| | 122 | while((_28=_25.exec(this.code))!=null){ |
| | 123 | this.matches[this.matches.length]=new dp.sh.Match(_28[0],_28.index,css); |
| | 124 | } |
| | 125 | }; |
| | 126 | dp.sh.Highlighter.prototype.AddBit=function(str,css){ |
| | 127 | if(str==null||str.length==0){ |
| | 128 | return; |
| | 129 | } |
| | 130 | var _2b=this.CreateElement("SPAN"); |
| | 131 | str=str.replace(/ /g," "); |
| | 132 | str=str.replace(/</g,"<"); |
| | 133 | str=str.replace(/\n/gm," <br>"); |
| | 134 | if(css!=null){ |
| | 135 | if((/br/gi).test(str)){ |
| | 136 | var _2c=str.split(" <br>"); |
| | 137 | for(var i=0;i<_2c.length;i++){ |
| | 138 | _2b=this.CreateElement("SPAN"); |
| | 139 | _2b.className=css; |
| | 140 | _2b.innerHTML=_2c[i]; |
| | 141 | this.div.appendChild(_2b); |
| | 142 | if(i+1<_2c.length){ |
| | 143 | this.div.appendChild(this.CreateElement("BR")); |
| | 144 | } |
| | 145 | } |
| | 146 | }else{ |
| | 147 | _2b.className=css; |
| | 148 | _2b.innerHTML=str; |
| | 149 | this.div.appendChild(_2b); |
| | 150 | } |
| | 151 | }else{ |
| | 152 | _2b.innerHTML=str; |
| | 153 | this.div.appendChild(_2b); |
| | 154 | } |
| | 155 | }; |
| | 156 | dp.sh.Highlighter.prototype.IsInside=function(_2e){ |
| | 157 | if(_2e==null||_2e.length==0){ |
| | 158 | return false; |
| | 159 | } |
| | 160 | for(var i=0;i<this.matches.length;i++){ |
| | 161 | var c=this.matches[i]; |
| | 162 | if(c==null){ |
| | 163 | continue; |
| | 164 | } |
| | 165 | if((_2e.index>c.index)&&(_2e.index<c.index+c.length)){ |
| | 166 | return true; |
| | 167 | } |
| | 168 | } |
| | 169 | return false; |
| | 170 | }; |
| | 171 | dp.sh.Highlighter.prototype.ProcessRegexList=function(){ |
| | 172 | for(var i=0;i<this.regexList.length;i++){ |
| | 173 | this.GetMatches(this.regexList[i].regex,this.regexList[i].css); |
| | 174 | } |
| | 175 | }; |
| | 176 | dp.sh.Highlighter.prototype.ProcessSmartTabs=function(_32){ |
| | 177 | var _33=_32.split("\n"); |
| | 178 | var _34=""; |
| | 179 | var _35=4; |
| | 180 | var tab="\t"; |
| | 181 | function InsertSpaces(_37,pos,_39){ |
| | 182 | var _3a=_37.substr(0,pos); |
| | 183 | var _3b=_37.substr(pos+1,_37.length); |
| | 184 | var _3c=""; |
| | 185 | for(var i=0;i<_39;i++){ |
| | 186 | _3c+=" "; |
| | 187 | } |
| | 188 | return _3a+_3c+_3b; |
| | 189 | } |
| | 190 | function ProcessLine(_3e,_3f){ |
| | 191 | if(_3e.indexOf(tab)==-1){ |
| | 192 | return _3e; |
| | 193 | } |
| | 194 | var pos=0; |
| | 195 | while((pos=_3e.indexOf(tab))!=-1){ |
| | 196 | var _41=_3f-pos%_3f; |
| | 197 | _3e=InsertSpaces(_3e,pos,_41); |
| | 198 | } |
| | 199 | return _3e; |
| | 200 | } |
| | 201 | for(var i=0;i<_33.length;i++){ |
| | 202 | _34+=ProcessLine(_33[i],_35)+"\n"; |
| | 203 | } |
| | 204 | return _34; |
| | 205 | }; |
| | 206 | dp.sh.Highlighter.prototype.SwitchToList=function(){ |
| | 207 | var _43=this.div.innerHTML.replace(/<(br)\/?>/gi,"\n"); |
| | 208 | var _44=_43.split("\n"); |
| | 209 | if(this.addControls==true){ |
| | 210 | this.bar.appendChild(dp.sh.Toolbar.Create(this)); |
| | 211 | } |
| | 212 | if(this.showColumns){ |
| | 213 | var div=this.CreateElement("div"); |
| | 214 | var _46=this.CreateElement("div"); |
| | 215 | var _47=10; |
| | 216 | var i=1; |
| | 217 | while(i<=150){ |
| | 218 | if(i%_47==0){ |
| | 219 | div.innerHTML+=i; |
| | 220 | i+=(i+"").length; |
| | 221 | }else{ |
| | 222 | div.innerHTML+="·"; |
| | 223 | i++; |
| | 224 | } |
| | 225 | } |
| | 226 | _46.className="columns"; |
| | 227 | _46.appendChild(div); |
| | 228 | this.bar.appendChild(_46); |
| | 229 | } |
| | 230 | for(var i=0,lineIndex=this.firstLine;i<_44.length-1;i++,lineIndex++){ |
| | 231 | var li=this.CreateElement("LI"); |
| | 232 | var _4b=this.CreateElement("SPAN"); |
| | 233 | li.className=(i%2==0)?"alt":""; |
| | 234 | _4b.innerHTML=_44[i]+" "; |
| | 235 | li.appendChild(_4b); |
| | 236 | this.ol.appendChild(li); |
| | 237 | } |
| | 238 | this.div.innerHTML=""; |
| | 239 | }; |
| | 240 | dp.sh.Highlighter.prototype.Highlight=function(_4c){ |
| | 241 | function Trim(str){ |
| | 242 | return str.replace(/^\s*(.*?)[\s\n]*$/g,"$1"); |
| | 243 | } |
| | 244 | function Chop(str){ |
| | 245 | return str.replace(/\n*$/,"").replace(/^\n*/,""); |
| | 246 | } |
| | 247 | function Unindent(str){ |
| | 248 | var _50=str.split("\n"); |
| | 249 | var _51=new Array(); |
| | 250 | var _52=new RegExp("^\\s*","g"); |
| | 251 | var min=1000; |
| | 252 | for(var i=0;i<_50.length&&min>0;i++){ |
| | 253 | if(Trim(_50[i]).length==0){ |
| | 254 | continue; |
| | 255 | } |
| | 256 | var _55=_52.exec(_50[i]); |
| | 257 | if(_55!=null&&_55.length>0){ |
| | 258 | min=Math.min(_55[0].length,min); |
| | 259 | } |
| | 260 | } |
| | 261 | if(min>0){ |
| | 262 | for(var i=0;i<_50.length;i++){ |
| | 263 | _50[i]=_50[i].substr(min); |
| | 264 | } |
| | 265 | } |
| | 266 | return _50.join("\n"); |
| | 267 | } |
| | 268 | function Copy(_57,_58,_59){ |
| | 269 | return _57.substr(_58,_59-_58); |
| | 270 | } |
| | 271 | var pos=0; |
| | 272 | if(_4c==null){ |
| | 273 | _4c=""; |
| | 274 | } |
| | 275 | this.originalCode=_4c; |
| | 276 | this.code=Chop(Unindent(_4c)); |
| | 277 | this.div=this.CreateElement("DIV"); |
| | 278 | this.bar=this.CreateElement("DIV"); |
| | 279 | this.ol=this.CreateElement("OL"); |
| | 280 | this.matches=new Array(); |
| | 281 | this.div.className="dp-highlighter"; |
| | 282 | this.div.highlighter=this; |
| | 283 | this.bar.className="bar"; |
| | 284 | this.ol.start=this.firstLine; |
| | 285 | if(this.CssClass!=null){ |
| | 286 | this.ol.className=this.CssClass; |
| | 287 | } |
| | 288 | if(this.collapse){ |
| | 289 | this.div.className+=" collapsed"; |
| | 290 | } |
| | 291 | if(this.noGutter){ |
| | 292 | this.div.className+=" nogutter"; |
| | 293 | } |
| | 294 | if(this.tabsToSpaces==true){ |
| | 295 | this.code=this.ProcessSmartTabs(this.code); |
| | 296 | } |
| | 297 | this.ProcessRegexList(); |
| | 298 | if(this.matches.length==0){ |
| | 299 | this.AddBit(this.code,null); |
| | 300 | this.SwitchToList(); |
| | 301 | this.div.appendChild(this.ol); |
| | 302 | return; |
| | 303 | } |
| | 304 | this.matches=this.matches.sort(dp.sh.Highlighter.SortCallback); |
| | 305 | for(var i=0;i<this.matches.length;i++){ |
| | 306 | if(this.IsInside(this.matches[i])){ |
| | 307 | this.matches[i]=null; |
| | 308 | } |
| | 309 | } |
| | 310 | for(var i=0;i<this.matches.length;i++){ |
| | 311 | var _5d=this.matches[i]; |
| | 312 | if(_5d==null||_5d.length==0){ |
| | 313 | continue; |
| | 314 | } |
| | 315 | this.AddBit(Copy(this.code,pos,_5d.index),null); |
| | 316 | this.AddBit(_5d.value,_5d.css); |
| | 317 | pos=_5d.index+_5d.length; |
| | 318 | } |
| | 319 | this.AddBit(this.code.substr(pos),null); |
| | 320 | this.SwitchToList(); |
| | 321 | this.div.appendChild(this.bar); |
| | 322 | this.div.appendChild(this.ol); |
| | 323 | }; |
| | 324 | dp.sh.Highlighter.prototype.GetKeywords=function(str){ |
| | 325 | return "\\b"+str.replace(/ /g,"\\b|\\b")+"\\b"; |
| | 326 | }; |
| | 327 | dp.sh.HighlightAll=function(_5f,_60,_61,_62,_63,_64){ |
| | 328 | function FindValue(){ |
| | 329 | var a=arguments; |
| | 330 | for(var i=0;i<a.length;i++){ |
| | 331 | if(a[i]==null){ |
| | 332 | continue; |
| | 333 | } |
| | 334 | if(typeof (a[i])=="string"&&a[i]!=""){ |
| | 335 | return a[i]+""; |
| | 336 | } |
| | 337 | if(typeof (a[i])=="object"&&a[i].value!=""){ |
| | 338 | return a[i].value+""; |
| | 339 | } |
| | 340 | } |
| | 341 | return null; |
| | 342 | } |
| | 343 | function IsOptionSet(_67,_68){ |
| | 344 | for(var i=0;i<_68.length;i++){ |
| | 345 | if(_68[i]==_67){ |
| | 346 | return true; |
| | 347 | } |
| | 348 | } |
| | 349 | return false; |
| | 350 | } |
| | 351 | function GetOptionValue(_6a,_6b,_6c){ |
| | 352 | var _6d=new RegExp("^"+_6a+"\\[(\\w+)\\]$","gi"); |
| | 353 | var _6e=null; |
| | 354 | for(var i=0;i<_6b.length;i++){ |
| | 355 | if((_6e=_6d.exec(_6b[i]))!=null){ |
| | 356 | return _6e[1]; |
| | 357 | } |
| | 358 | } |
| | 359 | return _6c; |
| | 360 | } |
| | 361 | function FindTagsByName(_70,_71,_72){ |
| | 362 | var _73=document.getElementsByTagName(_72); |
| | 363 | for(var i=0;i<_73.length;i++){ |
| | 364 | if(_73[i].getAttribute("name")==_71){ |
| | 365 | _70.push(_73[i]); |
| | 366 | } |
| | 367 | } |
| | 368 | } |
| | 369 | var _75=[]; |
| | 370 | var _76=null; |
| | 371 | var _77={}; |
| | 372 | var _78="innerHTML"; |
| | 373 | FindTagsByName(_75,_5f,"pre"); |
| | 374 | FindTagsByName(_75,_5f,"textarea"); |
| | 375 | if(_75.length==0){ |
| | 376 | return; |
| | 377 | } |
| | 378 | for(var _79 in dp.sh.Brushes){ |
| | 379 | var _7a=dp.sh.Brushes[_79].Aliases; |
| | 380 | if(_7a==null){ |
| | 381 | continue; |
| | 382 | } |
| | 383 | for(var i=0;i<_7a.length;i++){ |
| | 384 | _77[_7a[i]]=_79; |
| | 385 | } |
| | 386 | } |
| | 387 | for(var i=0;i<_75.length;i++){ |
| | 388 | var _7d=_75[i]; |
| | 389 | var _7e=FindValue(_7d.attributes["class"],_7d.className,_7d.attributes["language"],_7d.language); |
| | 390 | var _7f=""; |
| | 391 | if(_7e==null){ |
| | 392 | continue; |
| | 393 | } |
| | 394 | _7e=_7e.split(":"); |
| | 395 | _7f=_7e[0].toLowerCase(); |
| | 396 | if(_77[_7f]==null){ |
| | 397 | continue; |
| | 398 | } |
| | 399 | _76=new dp.sh.Brushes[_77[_7f]](); |
| | 400 | _7d.style.display="none"; |
| | 401 | _76.noGutter=(_60==null)?IsOptionSet("nogutter",_7e):!_60; |
| | 402 | _76.addControls=(_61==null)?!IsOptionSet("nocontrols",_7e):_61; |
| | 403 | _76.collapse=(_62==null)?IsOptionSet("collapse",_7e):_62; |
| | 404 | _76.showColumns=(_64==null)?IsOptionSet("showcolumns",_7e):_64; |
| | 405 | if(_76.Style){ |
| | 406 | document.write("<style>"+_76.Style+"</style>"); |
| | 407 | } |
| | 408 | _76.firstLine=(_63==null)?parseInt(GetOptionValue("firstline",_7e,1)):_63; |
| | 409 | _76.Highlight(_7d[_78]); |
| | 410 | _76.source=_7d; |
| | 411 | _7d.parentNode.insertBefore(_76.div,_7d); |
| | 412 | } |
| | 413 | }; |
| | 414 | |