MediaWiki:Common.js
Izskats
Piezīme: Lai redzētu izmaiņas, pēc publicēšanas var nākties iztīrīt sava pārlūka kešatmiņu.
- Firefox / Safari: Pieturi Shift un klikšķini uz Pārlādēt vai nospied Ctrl-F5 vai Ctrl-R (⌘-R uz Mac)
- Google Chrome: Nospied Ctrl-Shift-R (⌘-Shift-R uz Mac)
- Internet Explorer / Edge: Pieturi Ctrl un klikšķini uz Pārlādēt vai nospied Ctrl-F5
- Opera: Nospied Ctrl-F5.
importMW = function (name) { mw.loader.load( '/w/index.php?title=MediaWiki:'+name+'.js&action=raw&ctype=text/javascript' ); };
//Messages
var listFA = {
fa:'Itys rakstīņs irā vierteigs',
fl:'Itys saroksts ci portals irā vierteigs',
ga:'Itys rakstīņs irā lobs'}
var textFA = ' cytā volūdys izdolā';
var zeroSectionTip = 'Pataiseit īvodu';
var NavigationBarHide = '[nūglobuot]':
var NavigationBarShow = '[ruodeit]';
var NavigationBarShowDefault = 2;
function LinkFA(){
var ll, s
$('#p-lang li').each( function(i, iw){
ll = iw.className.split(' ')[0] + '-'
for( var s in listFA )
if( document.getElementById(ll + s) && !$( iw ).hasClass( 'badge-featuredarticle' ) && !$( iw ).hasClass( 'badge-goodarticle' ) && !$( iw ).hasClass( 'badge-featuredlist' ) )
$( iw )
.addClass( s.toUpperCase() )
.attr( 'title', listFA[s] + textFA )
})
}
//Collapsiblе: [[:en:Wikipedia:NavFrame]]
function collapsibleTables(){
var Table, HRow, HCell, btn, a, tblIdx = 0, colTables = []
var allTables = document.getElementsByTagName('table')
for (var i=0; Table = allTables[i]; i++){
if (!$(Table).hasClass( 'collapsible')) continue
if (!(HRow=Table.rows[0])) continue
if (!(HCell=HRow.getElementsByTagName('th')[0])) continue
Table.id = 'collapsibleTable' + tblIdx
btn = document.createElement('span')
btn.style.cssText = 'float:right; font-weight:normal; font-size:smaller'
a = document.createElement('a')
a.id = 'collapseButton' + tblIdx
a.href = 'javascript:collapseTable(' + tblIdx + ');'
a.style.color = HCell.style.color
a.appendChild(document.createTextNode(NavigationBarHide))
btn.appendChild(a)
HCell.insertBefore(btn, HCell.childNodes[0])
colTables[tblIdx++] = Table
}
for (var i=0; i < tblIdx; i++)
if ((tblIdx > NavigationBarShowDefault && $(colTables[i]).hasClass( 'autocollapse')) || $(colTables[i]).hasClass( 'collapsed'))
collapseTable(i)
}
function collapseTable (idx){
var Table = document.getElementById('collapsibleTable' + idx)
var btn = document.getElementById('collapseButton' + idx)
if (!Table || !btn) return false
var Rows = Table.rows
var isShown = (btn.firstChild.data == NavigationBarHide)
btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide
var disp = isShown ? 'none' : Rows[0].style.display
for (var i=1; i < Rows.length; i++)
Rows[i].style.display = disp
}
function collapsibleDivs(){
var navIdx = 0, colNavs = [], i, NavFrame
var divs = document.getElementById('content').getElementsByTagName('div')
for (i=0; NavFrame = divs[i]; i++) {
if (!$(NavFrame).hasClass( 'NavFrame')) continue
NavFrame.id = 'NavFrame' + navIdx
var a = document.createElement('a')
a.className = 'NavToggle'
a.id = 'NavToggle' + navIdx
a.href = 'javascript:collapseDiv(' + navIdx + ');'
a.appendChild(document.createTextNode(NavigationBarHide))
for (var j=0; j < NavFrame.childNodes.length; j++)
if ($(NavFrame.childNodes[j]).hasClass( 'NavHead'))
NavFrame.childNodes[j].appendChild(a)
colNavs[navIdx++] = NavFrame
}
for (i=0; i < navIdx; i++)
if ((navIdx > NavigationBarShowDefault && !$(colNavs[i]).hasClass( 'expanded')) || $(colNavs[i]).hasClass( 'collapsed'))
collapseDiv(i)
}
function collapseDiv(idx) {
var div = document.getElementById('NavFrame' + idx)
var btn = document.getElementById('NavToggle' + idx)
if (!div || !btn) return false
var isShown = (btn.firstChild.data == NavigationBarHide)
btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide
var disp = isShown ? 'none' : 'block'
for (var child = div.firstChild; child != null; child = child.nextSibling)
if ($(child).hasClass( 'NavPic') || $(child).hasClass( 'NavContent'))
child.style.display = disp
}
//Execution
if (mw.config.get('wgCanonicalNamespace') == 'Special'){
if (/^(Search)/i.test(mw.config.get('wgCanonicalSpecialPageName')))
importMW(mw.config.get('wgCanonicalSpecialPageName'))
} else {
$(collapsibleDivs)
$(collapsibleTables)
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400')
switch( mw.config.get('wgNamespaceNumber') ){
case 0: case 100:
$(LinkFA)
if( mw.config.get('wgArticleId') == 4401 ) importMW('Mainpage')
break
}
}
if (mw.config.get('wgUserGroups')){
if (mw.config.get('wgNamespaceNumber')==2 && mw.config.get('wgTitle').indexOf(mw.config.get('wgUserName'))==0 && mw.config.get('wgArticleId')==0 && /\/skin\.(js|css)$/.test(mw.config.get('wgTitle')))
location.href = location.href.replace(/skin\.(css|js)$/, skin+'.$1')
}
//extra scripts
var withJS = document.URL.match(/[&?]withjs=((mediawiki:)?([^&#]+))/i)
if (withJS) importScript('MediaWiki:'+withJS[3])
var execJS = document.getElementById('executeJS')
mw.loader.using('mediawiki.util',function () {
if (!mw.config.get('wgUserName')) mw.util.addCSS('#mw-fr-revisiontag {display:none}');
})