|
6 | 6 | * http://alexgorbatchev.com/SyntaxHighlighter/donate.html |
7 | 7 | * |
8 | 8 | * @version |
9 | | - * 3.0.83 (July 02 2010) |
10 | | - * |
| 9 | + * 3.0.83 (Wed, 16 Apr 2014 03:56:09 GMT) |
| 10 | + * |
11 | 11 | * @copyright |
12 | | - * Copyright (C) 2004-2010 Alex Gorbatchev. |
| 12 | + * Copyright (C) 2004-2013 Alex Gorbatchev. |
13 | 13 | * |
14 | 14 | * @license |
15 | 15 | * Dual licensed under the MIT and GPL licenses. |
16 | 16 | */ |
17 | | -eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(2(){1 h=5;h.I=2(){2 n(c,a){4(1 d=0;d<c.9;d++)i[c[d]]=a}2 o(c){1 a=r.H("J"),d=3;a.K=c;a.M="L/t";a.G="t";a.u=a.v=2(){6(!d&&(!8.7||8.7=="F"||8.7=="z")){d=q;e[c]=q;a:{4(1 p y e)6(e[p]==3)B a;j&&5.C(k)}a.u=a.v=x;a.D.O(a)}};r.N.R(a)}1 f=Q,l=h.P(),i={},e={},j=3,k=x,b;5.T=2(c){k=c;j=q};4(b=0;b<f.9;b++){1 m=f[b].w?f[b]:f[b].S(/\\s+/),g=m.w();n(m,g)}4(b=0;b<l.9;b++)6(g=i[l[b].E.A]){e[g]=3;o(g)}}})();',56,56,'|var|function|false|for|SyntaxHighlighter|if|readyState|this|length|||||||||||||||||true|document||javascript|onload|onreadystatechange|pop|null|in|complete|brush|break|highlight|parentNode|params|loaded|language|createElement|autoloader|script|src|text|type|body|removeChild|findElements|arguments|appendChild|split|all'.split('|'),0,{})) |
| 17 | +(function() { |
| 18 | + |
| 19 | +var sh = SyntaxHighlighter; |
| 20 | + |
| 21 | +/** |
| 22 | + * Provides functionality to dynamically load only the brushes that a needed to render the current page. |
| 23 | + * |
| 24 | + * There are two syntaxes that autoload understands. For example: |
| 25 | + * |
| 26 | + * SyntaxHighlighter.autoloader( |
| 27 | + * [ 'applescript', 'Scripts/shBrushAppleScript.js' ], |
| 28 | + * [ 'actionscript3', 'as3', 'Scripts/shBrushAS3.js' ] |
| 29 | + * ); |
| 30 | + * |
| 31 | + * or a more easily comprehendable one: |
| 32 | + * |
| 33 | + * SyntaxHighlighter.autoloader( |
| 34 | + * 'applescript Scripts/shBrushAppleScript.js', |
| 35 | + * 'actionscript3 as3 Scripts/shBrushAS3.js' |
| 36 | + * ); |
| 37 | + */ |
| 38 | +sh.autoloader = function() |
| 39 | +{ |
| 40 | + var list = arguments, |
| 41 | + elements = sh.findElements(), |
| 42 | + brushes = {}, |
| 43 | + scripts = {}, |
| 44 | + all = SyntaxHighlighter.all, |
| 45 | + allCalled = false, |
| 46 | + allParams = null, |
| 47 | + i |
| 48 | + ; |
| 49 | + |
| 50 | + SyntaxHighlighter.all = function(params) |
| 51 | + { |
| 52 | + allParams = params; |
| 53 | + allCalled = true; |
| 54 | + }; |
| 55 | + |
| 56 | + function addBrush(aliases, url) |
| 57 | + { |
| 58 | + for (var i = 0; i < aliases.length; i++) |
| 59 | + brushes[aliases[i]] = url; |
| 60 | + }; |
| 61 | + |
| 62 | + function getAliases(item) |
| 63 | + { |
| 64 | + return item.pop |
| 65 | + ? item |
| 66 | + : item.split(/\s+/) |
| 67 | + ; |
| 68 | + } |
| 69 | + |
| 70 | + // create table of aliases and script urls |
| 71 | + for (i = 0; i < list.length; i++) |
| 72 | + { |
| 73 | + var aliases = getAliases(list[i]), |
| 74 | + url = aliases.pop() |
| 75 | + ; |
| 76 | + |
| 77 | + addBrush(aliases, url); |
| 78 | + } |
| 79 | + |
| 80 | + // dynamically add <script /> tags to the document body |
| 81 | + for (i = 0; i < elements.length; i++) |
| 82 | + { |
| 83 | + var url = brushes[elements[i].params.brush]; |
| 84 | + |
| 85 | + if(url && scripts[url] === undefined) |
| 86 | + { |
| 87 | + if(elements[i].params['html-script'] === 'true') |
| 88 | + { |
| 89 | + if(scripts[brushes['xml']] === undefined) { |
| 90 | + loadScript(brushes['xml']); |
| 91 | + scripts[url] = false; |
| 92 | + } |
| 93 | + } |
| 94 | + |
| 95 | + scripts[url] = false; |
| 96 | + loadScript(url); |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + function loadScript(url) |
| 101 | + { |
| 102 | + var script = document.createElement('script'), |
| 103 | + done = false |
| 104 | + ; |
| 105 | + |
| 106 | + script.src = url; |
| 107 | + script.type = 'text/javascript'; |
| 108 | + script.language = 'javascript'; |
| 109 | + script.onload = script.onreadystatechange = function() |
| 110 | + { |
| 111 | + if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) |
| 112 | + { |
| 113 | + done = true; |
| 114 | + scripts[url] = true; |
| 115 | + checkAll(); |
| 116 | + |
| 117 | + // Handle memory leak in IE |
| 118 | + script.onload = script.onreadystatechange = null; |
| 119 | + script.parentNode.removeChild(script); |
| 120 | + } |
| 121 | + }; |
| 122 | + |
| 123 | + // sync way of adding script tags to the page |
| 124 | + document.body.appendChild(script); |
| 125 | + }; |
| 126 | + |
| 127 | + function checkAll() |
| 128 | + { |
| 129 | + for(var url in scripts) |
| 130 | + if (scripts[url] == false) |
| 131 | + return; |
| 132 | + |
| 133 | + if (allCalled) |
| 134 | + SyntaxHighlighter.highlight(allParams); |
| 135 | + }; |
| 136 | +}; |
| 137 | + |
| 138 | +})(); |
0 commit comments