Diferencia entre revisiones de «MediaWiki:Common.js»
Sin resumen de edición |
Sin resumen de edición |
||
| Línea 47: | Línea 47: | ||
* Based on http://www.mediawiki.org/wiki/Manual:Collapsible_tables#Common.js_script_.28before_1.18.29 | * Based on http://www.mediawiki.org/wiki/Manual:Collapsible_tables#Common.js_script_.28before_1.18.29 | ||
*/ | */ | ||
/ Collapsible tables / | |||
if ( wgIsArticle || window.location.href.indexOf( 'action=submit' ) > -1 ) | |||
{ | |||
var script = document.createElement( 'script' ); | |||
script.src = '/index.php?title=MediaWiki:CollapsibleTables.js&action=raw&ctype=text/javascript'; | |||
script.type = 'text/javascript'; | |||
document.getElementsByTagName( 'head' )[0].appendChild( script ); | |||
hookEvent( 'load', function() | |||
{ | |||
new CollapsibleTables(); | |||
} ); | |||
} | |||
/** | |||
* Frame parser (for [[Template:Grid]]) | |||
* | |||
* Requests the urls for all the animated grids on a page in 2 | |||
* API requests (due to a bug, 1 API request when it is fixed) | |||
* and appends them to the correct location. | |||
*/ | |||
var baseURL = '/', wikiURL = '/wiki/', $grids = $( '.grid' ), titles = [], titleCount = 0, section = 0; | |||
if ( $grids.length ) { | |||
$grids.each( function() { | |||
var imgs = $( this ).data( 'imgs' ), mod = $( this ).data( 'mod' ); | |||
if ( !imgs ) { | |||
return true; | |||
} | |||
imgs = imgs.split( ';' ); | |||
imgs.shift(); | |||
$.each( imgs, function() { | |||
if ( !this.trim() ) { | |||
return true; | |||
} | |||
if ( titleCount === 50 ) { | |||
titleCount = 0; | |||
section++; | |||
} | |||
if ( !titles[section] ) { | |||
titles[section] = ''; | |||
} | |||
if ( this.indexOf( ':' ) > -1 ) { | |||
this.replace( /([^:]*):?([^,]*)/, function( $, mod, name ) { | |||
if ( mod.trim().toLowerCase() === 'v' || mod.trim().toLowerCase() === 'vanilla' ) { | |||
if ( titles[section].indexOf( 'File:Grid ' + name.trim() + '.png' ) < 0 ) { | |||
titles[section] += 'File:Grid ' + name.trim() + '.png|'; | |||
titleCount++; | |||
} | |||
} else { | |||
if ( titles[section].indexOf( 'File:Grid ' + name.trim() + ' (' + mod.trim() + ').png' ) < 0 ) { | |||
titles[section] += 'File:Grid ' + name.trim() + ' (' + mod.trim() + ').png|'; | |||
titleCount++; | |||
} | |||
} | |||
} ); | |||
} else { | |||
this.replace( /([^,]*)/, function( $, name ) { | |||
if ( !mod || mod.trim().toLowerCase() === 'v' || mod.trim().toLowerCase() === 'vanilla' ) { | |||
if ( titles[section].indexOf( 'File:Grid ' + name.trim() + '.png' ) < 0 ) { | |||
titles[section] += 'File:Grid ' + name.trim() + '.png|'; | |||
titleCount++; | |||
} | |||
} else { | |||
if ( titles[section].indexOf( 'File:Grid ' + name.trim() + ' (' + mod.trim() + ').png' ) < 0 ) { | |||
titles[section] += 'File:Grid ' + name.trim() + ' (' + mod.trim() + ').png|'; | |||
titleCount++; | |||
} | |||
} | |||
} ); | |||
} | |||
} ); | |||
} ); | |||
mcw.makeCollapsible = function( $content ) { | mcw.makeCollapsible = function( $content ) { | ||
if ( $content === undefined ) { | if ( $content === undefined ) { | ||