3434// | | | google-code-prettify/source/ | |
3535// | | | browse/trunk/styles | |
3636// +------------------+---------------+------------------------------+--------+
37- // | namespace= | dotted ident | Attaches prettyPrint and | none |
38- // | | | related functions to the | |
39- // | | | global object at that path | |
40- // | | | so they are accessible to | |
41- // | | | client code. | |
42- // +------------------+---------------+------------------------------+--------+
4337// | callback= | JS identifier | When "prettyPrint" finishes | none |
4438// | | | window.exports[js_ident] is | |
4539// | | | called. | |
5852// stylesheet.
5953// A gallery of stylesheets is available at
6054// https://google-code-prettify.googlecode.com/svn/trunk/styles/index.html
61- // http://google-code-prettify.googlecode.com/svn/trunk/styles/index.html
6255// 3. Since autorun=false is not specified, calls prettyPrint() on page load.
6356
6457
@@ -86,29 +79,29 @@ var IN_GLOBAL_SCOPE = false;
8679 pre = doc . addEventListener ? '' : 'on' ,
8780
8881 init = function ( e ) {
89- if ( e . type == 'readystatechange' && doc . readyState != 'complete' ) {
82+ if ( e . type == 'readystatechange' && doc . readyState != 'complete' ) {
9083 return ;
9184 }
92- ( e . type == 'load' ? win : doc ) [ rem ] ( pre + e . type , init , false ) ;
93- if ( ! done && ( done = true ) ) { callback . call ( win , e . type || e ) ; }
94- } ,
85+ ( e . type == 'load' ? win : doc ) [ rem ] ( pre + e . type , init , false ) ;
86+ if ( ! done && ( done = true ) ) { callback . call ( win , e . type || e ) ; }
87+ } ,
9588
9689 poll = function ( ) {
97- try {
90+ try {
9891 root . doScroll ( 'left' ) ;
9992 } catch ( e ) {
10093 setTimeout ( poll , 50 ) ;
10194 return ;
10295 }
103- init ( 'poll' ) ;
104- } ;
96+ init ( 'poll' ) ;
97+ } ;
10598
10699 if ( doc . readyState == 'complete' ) {
107100 callback . call ( win , 'lazy' ) ;
108101 } else {
109102 if ( doc . createEventObject && root . doScroll ) {
110- try { top = ! win . frameElement ; } catch ( e ) { }
111- if ( top ) { poll ( ) ; }
103+ try { top = ! win . frameElement ; } catch ( e ) { }
104+ if ( top ) { poll ( ) ; }
112105 }
113106 doc [ add ] ( pre + 'DOMContentLoaded' , init , false ) ;
114107 doc [ add ] ( pre + 'readystatechange' , init , false ) ;
@@ -160,7 +153,6 @@ var IN_GLOBAL_SCOPE = false;
160153 var autorun = true ;
161154 var langs = [ ] ;
162155 var skins = [ ] ;
163- var namespaces = [ ] ;
164156 var callbacks = [ ] ;
165157 scriptQuery . replace (
166158 / [ ? & ] ( [ ^ & = ] + ) = ( [ ^ & ] + ) / g,
@@ -170,31 +162,30 @@ var IN_GLOBAL_SCOPE = false;
170162 if ( name == 'autorun' ) { autorun = ! / ^ [ 0 f n ] / i. test ( value ) ; } else
171163 if ( name == 'lang' ) { langs . push ( value ) ; } else
172164 if ( name == 'skin' ) { skins . push ( value ) ; } else
173- if ( name == 'namespace' ) { namespaces . push ( value ) ; } else
174165 if ( name == 'callback' ) { callbacks . push ( value ) ; }
175166 } ) ;
176167
177168 // Use https to avoid mixed content warnings in client pages and to
178169 // prevent a MITM from rewrite prettify mid-flight.
179170 // This only works if this script is loaded via https : something
180171 // over which we exercise no control.
181- var PRETTIFY_CODE_HOME =
182- 'https://google-code-prettify.googlecode.com/svn/trunk ' ;
172+ var LOADER_BASE_URL =
173+ 'https://google-code-prettify.googlecode.com/svn/loader ' ;
183174
184175 for ( var i = 0 , n = langs . length ; i < n ; ++ i ) {
185176 var script = doc . createElement ( 'script' ) ;
186177 script . type = 'text/javascript' ;
187- script . src = PRETTIFY_CODE_HOME
188- + '/src/ lang-' + encodeURIComponent ( langs [ i ] ) + '.js' ;
178+ script . src = LOADER_BASE_URL
179+ + '/lang-' + encodeURIComponent ( langs [ i ] ) + '.js' ;
189180 head . appendChild ( script ) ;
190181 }
191182
192183 var skinUrls = [ ] ;
193184 for ( var i = 0 , n = skins . length ; i < n ; ++ i ) {
194- skinUrls . push ( PRETTIFY_CODE_HOME
195- + '/styles /' + encodeURIComponent ( skins [ i ] ) + '.css' ) ;
185+ skinUrls . push ( LOADER_BASE_URL
186+ + '/skins /' + encodeURIComponent ( skins [ i ] ) + '.css' ) ;
196187 }
197- skinUrls . push ( PRETTIFY_CODE_HOME + '/src /prettify.css' ) ;
188+ skinUrls . push ( LOADER_BASE_URL + '/prettify.css' ) ;
198189 loadStylesheetsFallingBack ( skinUrls ) ;
199190
200191 var prettyPrint = ( function ( ) {
@@ -1798,19 +1789,6 @@ var IN_GLOBAL_SCOPE = false;
17981789 } ) ;
17991790 }
18001791 } ) ( ) ;
1801- for ( var i = 0 , n = namespaces . length ; i < n ; ++ i ) {
1802- var namespace = namespaces [ i ] ;
1803- var namespaceObj = win ;
1804- if ( namespace ) {
1805- var parts = namespace . split ( '.' ) ;
1806- for ( var j = 0 , nParts = parts . length ; j < nParts ; ++ j ) {
1807- var part = parts [ j ] ;
1808- namespaceObj = ( namespaceObj [ part ] || ( namespaceObj [ part ] = { } ) ) ;
1809- }
1810- }
1811- namespaceObj [ 'prettyPrint' ] = prettyPrint ;
1812- namespaceObj [ 'prettyPrintOne' ] = prettyPrintOne ;
1813- }
18141792 return prettyPrint ;
18151793 } ) ( ) ;
18161794
0 commit comments