MediaWiki:Common.js

function initVisibility { var page = window.pageName.replace(/\W/g,'_'); var show = localStorage.getItem('infoboxshow-' + page);

if( show == 'false' ) { infoboxToggle; }

var hidables = getElementsByClass('hidable');

for(var i = 0; i < hidables.length; i++) { show = localStorage.getItem('hidableshow-' + i + '_' + page);

if( show == 'false' ) { var content = getElementsByClass('hidable-content', hidables[i]); var button = getElementsByClass('hidable-button', hidables[i]);

if( content != null && content.length > 0 &&				button != null && button.length > 0 && content[0].style.display != 'none' ) {				button[0].onclick('bypass'); }		} else if( show == 'true' ) { var content = getElementsByClass('hidable-content', hidables[i]); var button = getElementsByClass('hidable-button', hidables[i]);

if( content != null && content.length > 0 &&				button != null && button.length > 0 && content[0].style.display == 'none' ) {				button[0].onclick('bypass'); }		}	} }

function onArticleNavClick { var div = document.getElementById('mp3-nav');

if( div.style.display == 'block' ) div.style.display = 'none'; else div.style.display = 'block'; }

function addHideButtons { var hidables = getElementsByClass('hidable');

for( var i = 0; i < hidables.length; i++ ) { var box = hidables[i]; var button = getElementsByClass('hidable-button', box, 'span');

if( button != null && button.length > 0 ) { button = button[0];

button.onclick = toggleHidable; button.appendChild( document.createTextNode('[Hide]') );

if( new ClassTester('start-hidden').isMatch(box) ) button.onclick('bypass'); }	} }

function toggleHidable(bypassStorage) { var parent = getParentByClass('hidable', this); var content = getElementsByClass('hidable-content', parent); var nowShown;

if( content != null && content.length > 0 ) { content = content[0];

if( content.style.display == 'none' ) { content.style.display = content.oldDisplayStyle; this.firstChild.nodeValue = '[Hide]'; nowShown = true; } else { content.oldDisplayStyle = content.style.display; content.style.display = 'none'; this.firstChild.nodeValue = '[Show]'; nowShown = false; }

if( window.storagePresent && ( typeof( bypassStorage ) == 'undefined' || bypassStorage != 'bypass' ) ) { var page = window.pageName.replace(/\W/g, '_'); var items = getElementsByClass('hidable'); var item = -1;

for( var i = 0; i < items.length; i++ ) { if( items[i] == parent ) { item = i;					break; }			}

if( item == -1 ) { return; }

localStorage.setItem('hidableshow-' + item + '_' + page, nowShown); }	} }

function setupUploadForm{ if ( wpLicense.length && window.location.search.indexOf('wpForReUpload=1') == -1){ $('#mw-htmlform-description').addClass('hidable start-hidden');

// Add new required rows rows.eq(1).after(' Source:  '); $('#mw-htmlform-description').append(' '); var tbody1 = $('#mw-htmlform-description').children('tbody').eq(0); tbody1.append(' Description:  '); tbody1.append(' Optional fields  '); }	} }