MediaWiki:Wynn.js

/** * Wynn Dorvan code - fork of MediaWiki:Jax.js * @author Pinky * @author Splarka * @author Jack Phoenix */

/** * Convert a number to have commas in it * from mredkj.com */ function addCommas( nStr ){ nStr += ''; // make it a string x = nStr; var rgx = /(\d+)(\d{3})/; while( rgx.test( x ) ) { x = x.replace(rgx, '$1' + ',' + '$2'); }	return x; }

// special random page if( wgPageName.toLowerCase == 'special:randomwynn' ) { var rand = Math.floor(Math.random*170000); // 1 number above the maximum window.location = wgServer + wgScript + '?title=Wynn_Dorvan_' + addCommas( rand ); }

// Make it show if the article doesn't exist if( wgTitle.match(/Wynn Dorvan \d+/) && wgArticleId == 0 ) { appendCSS('.noarticletext {display:none;} #p-cactions li.selected a {color:#002bb8;} #contentSub2 {display:none;} .mw-warning-with-logexcerpt {display:none;} .mw-newarticletext {display:none;}'); addOnloadHook(function { 		var content = document.getElementById('bodyContent');		content.innerHTML += '      This article is about the Coruscanti individual named Wynn Dorvan. You may be looking for one of the 170,000 others.        Wynn Dorvan was one of the 170,000 individuals named Wynn Dorvan on Coruscant.  Category:&#32; Notable individuals named Wynn Dorvan   ';		var mainbutton = document.getElementById('ca-nstab-main'); mainbutton.className = 'selected'; // make the article link blue // Monaco skin is a special case if ( skin == 'monaco' ) { var href = mainbutton.getAttribute('href', 2); mainbutton.setAttribute( 'href', href.replace(/\&action\=edit/, '') ); } else { var mblink = mainbutton.getElementsByTagName('a')[0]; var href = mblink.getAttribute('href', 2); mblink.setAttribute( 'href', href.replace(/\&action\=edit/, '') ); // link to article and not &action=edit }		var editbutton = document.getElementById('ca-edit'); editbutton.innerHTML = editbutton.innerHTML.replace(/Create/, 'Edit this page'); // change create->edit }); }

// Make the default edit text "" if( wgTitle.match(/Wynn Dorvan \d+/) && wgArticleId == 0 && wgAction == 'edit' ) { addOnloadHook(function {		var content = document.getElementById('wpTextbox1');		content.appendChild( document.createTextNode( '' ) );	}); }

// Make redlinks turn blue // Hopefully doesn't slow down pageloads too much addOnloadHook(function {	var a = getElementsByClassName(document, 'a', 'new');	for( var i = 0; i< a.length; i++ ) {		var href = a[i].getAttribute('href', 2);		if( href.indexOf( wgScript + '?title=Wynn_Dorvan_' ) == 0 ) {			a[i].setAttribute( 'href', href.replace(/\&action\=edit(\&redlink\=1)?/, ) );			var title = a[i].getAttribute('title', 2);			a[i].setAttribute( 'title', title.replace(/ \(page does not exist\)/, ) );			a[i].className = '';		}	} });