MediaWiki:Wikia.js

/* */

/*Loads the current source of the page "pagename" (as stored in the database) and inserts it at the cursor position*/ function doPreload(pagename) {   var loader = new ContentLoader; loader.callback = onPreloadArrival; loader.send('/index.php?title=' + pagename + '&action=raw&ctype=text/plain'); } function insertAtCursor(myField, myValue) {   //IE support if (document.selection) {       myField.focus; sel = document.selection.createRange; sel.text = myValue; }   //MOZILLA/NETSCAPE support else if(myField.selectionStart || myField.selectionStart == '0') {       var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); }   else {       myField.value += myValue; } } function onPreloadArrival {   insertAtCursor(document.getElementById('wpTextbox1'), this.text); } /*   end preload code /* Template Preloads * Original by User:Grunny * Source - w:c:starwars:MediaWiki:Wikia.js * Altered to replace Wiki'a template preloads by runescape wiki */ function customPreloadTemplates { if ( ( mw.config.get( 'wgAction' ) !== 'edit' && mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'CreatePage' ) || !$( 'div.module_content' ).length ) { return; }	var	preloadOptionsHtml = '', $preloadOptionsList, preloadBaseHtml = ' Standard preloads: '	$( 'span.cke_buttons.cke_toolbar_templates' ).replaceWith( preloadBaseHtml ); $.get( mw.config.get( 'wgScript' ), { title: 'Template:Stdpreloads', action: 'raw', ctype: 'text/plain' }, function( data ) {		var lines = data.split( '\n' );		for( var i = 0; i < lines.length; i++ ) {			var value = ( lines[i].indexOf( '-- ' ) === 0 ) ? lines[i].substring(3) : "";			preloadOptionsHtml += '' + lines[i] + ' ';		}		$preloadOptionsList = $( ' ' ).attr( 'id', 'stdSummaries' ).html( preloadOptionsHtml ).change( function { var value = $( this ).val; if ( value !== '' ) { value = 'Template:' + value + '/preload'; value = value.replace( ' ', '_' ); $.get( mw.config.get( 'wgScript' ), { title: value, action: 'raw', ctype: 'text/plain' }, function( data ) {					insertAtCursor( document.getElementById( 'wpTextbox1' ), data );				} ); }		} );		$( 'div#lf-preload' ).append( $preloadOptionsList );	} ); $( '#lf-preload-pagename-w' ).html( '' ); } $( customPreloadTemplates ); function doCustomPreloadOasis { var value = $( '#lf-preload-pagename-w > input' ).val; value = value.replace( ' ', '_' ); $.get( mw.config.get( 'wgScript' ), { title: value, action: 'raw', ctype: 'text/plain' }, function( data ) {		insertAtCursor( document.getElementById( 'wpTextbox1' ), data );	} ); }

/*Auto-refreshing recent changes*/ ajaxPages = ["Special:WikiActivity","Special:RecentChanges","Special:Watchlist","Special:Log","Special:Contributions"]; AjaxRCRefreshText = 'Auto-refresh'; AjaxRCRefreshHoverText = 'Automatically refresh the page'; importScriptPage('AjaxRC/code.js', 'dev');

/*Automatically scrolling field; credits to http://jsfiddle.net/mcknz/jEGex/*/ $(function {   var ele = $('#scroll');    var speed = 60,        scroll = 1,        top = 0,        maxTop = 500,        scrolling;

ele.mouseleave(function {       scrolling = window.setInterval(function { top = top === maxTop ? 0 : ele.scrollTop + scroll; ele.scrollTop(top); $('#scrollTop').text(top); }, speed);   });

ele.mouseenter(function {       if (scrolling) {            window.clearInterval(scrolling);            scrolling = false;        }    }); ele.mouseleave; });

//link to converter; thanks to UltimateSupreme with helping to put it for visual editors as well w:c:Thread:608344 $(function converter { converticon="  Convert "; $('.cke_button.RTEImageButton.cke_button_big').append(converticon);       if (window.CKEDITOR) {            CKEDITOR.on("instanceReady", function  { $(converter); });      } });

//add some guidelines $(function guide { guidelines=" Policies (see Tutorial) Birthday, RL info: Add references Songtitles: Romaji in &#8220;&#8220;; Translation in [1] Images: Name properly; No .jpg [2] Reprints: Needs link to NND original [3]  "; $('.module.module_page_controls').append(guidelines); });

//UtaWCB winner spotlight var mySpot0; var mySpot1; var mySpot2; var mySpot3; var mySpot4; var mySpot5; var mySpot6; var mySpot7; var mySpot8;

function myFunction { mySpot0 = setTimeout(function {        document.getElementById('spotlight9').style.display = "none";        document.getElementById('spotlight1').style.display = "block";    }, 1000); mySpot1 = setTimeout(function {        document.getElementById('spotlight1').style.display = "none";        document.getElementById('spotlight2').style.display = "block";    }, 2000); mySpot2 = setTimeout(function {        document.getElementById('spotlight2').style.display = "none";        document.getElementById('spotlight3').style.display = "block";    }, 3000); mySpot3 = setTimeout(function {        document.getElementById('spotlight3').style.display = "none";        document.getElementById('spotlight4').style.display = "block";    }, 4000); mySpot4 = setTimeout(function {        document.getElementById('spotlight4').style.display = "none";        document.getElementById('spotlight5').style.display = "block";    }, 5000); mySpot5 = setTimeout(function {        document.getElementById('spotlight5').style.display = "none";        document.getElementById('spotlight6').style.display = "block";    }, 6000); mySpot6 = setTimeout(function {        document.getElementById('spotlight6').style.display = "none";        document.getElementById('spotlight7').style.display = "block";    }, 7000); mySpot7 = setTimeout(function {        document.getElementById('spotlight7').style.display = "none";        document.getElementById('spotlight8').style.display = "block";    }, 8000); mySpot8 = setTimeout(function {        document.getElementById('spotlight8').style.display = "none";        document.getElementById('spotlight9').style.display = "block";    }, 9000); myStopFunction; myFunction; };

myFunction;

function myStopFunction { clearTimeout(mySpot0); clearTimeout(mySpot1); clearTimeout(mySpot2); clearTimeout(mySpot3); clearTimeout(mySpot4); clearTimeout(mySpot5); clearTimeout(mySpot6); clearTimeout(mySpot7); clearTimeout(mySpot8); };

var button = document.getElementById('1'); button.onclick = function { var div = document.getElementById('spotlight1'); div.style.display = 'block'; var div = document.getElementById('spotlight2'); div.style.display = 'none'; var div = document.getElementById('spotlight3'); div.style.display = 'none'; var div = document.getElementById('spotlight4'); div.style.display = 'none'; var div = document.getElementById('spotlight5'); div.style.display = 'none'; var div = document.getElementById('spotlight6'); div.style.display = 'none'; var div = document.getElementById('spotlight7'); div.style.display = 'none'; var div = document.getElementById('spotlight8'); div.style.display = 'none'; var div = document.getElementById('spotlight9'); div.style.display = 'none'; myStopFunction; };

var button = document.getElementById('2'); button.onclick = function { var div = document.getElementById('spotlight1'); div.style.display = 'none'; var div = document.getElementById('spotlight2'); div.style.display = 'block'; var div = document.getElementById('spotlight3'); div.style.display = 'none'; var div = document.getElementById('spotlight4'); div.style.display = 'none'; var div = document.getElementById('spotlight5'); div.style.display = 'none'; var div = document.getElementById('spotlight6'); div.style.display = 'none'; var div = document.getElementById('spotlight7'); div.style.display = 'none'; var div = document.getElementById('spotlight8'); div.style.display = 'none'; var div = document.getElementById('spotlight9'); div.style.display = 'none'; myStopFunction; };

var button = document.getElementById('3'); button.onclick = function { var div = document.getElementById('spotlight1'); div.style.display = 'none'; var div = document.getElementById('spotlight2'); div.style.display = 'none'; var div = document.getElementById('spotlight3'); div.style.display = 'block'; var div = document.getElementById('spotlight4'); div.style.display = 'none'; var div = document.getElementById('spotlight5'); div.style.display = 'none'; var div = document.getElementById('spotlight6'); div.style.display = 'none'; var div = document.getElementById('spotlight7'); div.style.display = 'none'; var div = document.getElementById('spotlight8'); div.style.display = 'none'; var div = document.getElementById('spotlight9'); div.style.display = 'none'; myStopFunction; };

var button = document.getElementById('4'); button.onclick = function { var div = document.getElementById('spotlight1'); div.style.display = 'none'; var div = document.getElementById('spotlight2'); div.style.display = 'none'; var div = document.getElementById('spotlight3'); div.style.display = 'none'; var div = document.getElementById('spotlight4'); div.style.display = 'block'; var div = document.getElementById('spotlight5'); div.style.display = 'none'; var div = document.getElementById('spotlight6'); div.style.display = 'none'; var div = document.getElementById('spotlight7'); div.style.display = 'none'; var div = document.getElementById('spotlight8'); div.style.display = 'none'; var div = document.getElementById('spotlight9'); div.style.display = 'none'; myStopFunction; };

var button = document.getElementById('5'); button.onclick = function { var div = document.getElementById('spotlight1'); div.style.display = 'none'; var div = document.getElementById('spotlight2'); div.style.display = 'none'; var div = document.getElementById('spotlight3'); div.style.display = 'none'; var div = document.getElementById('spotlight4'); div.style.display = 'none'; var div = document.getElementById('spotlight5'); div.style.display = 'block'; var div = document.getElementById('spotlight6'); div.style.display = 'none'; var div = document.getElementById('spotlight7'); div.style.display = 'none'; var div = document.getElementById('spotlight8'); div.style.display = 'none'; var div = document.getElementById('spotlight9'); div.style.display = 'none'; myStopFunction; };

var button = document.getElementById('6'); button.onclick = function { var div = document.getElementById('spotlight1'); div.style.display = 'none'; var div = document.getElementById('spotlight2'); div.style.display = 'none'; var div = document.getElementById('spotlight3'); div.style.display = 'none'; var div = document.getElementById('spotlight4'); div.style.display = 'none'; var div = document.getElementById('spotlight5'); div.style.display = 'none'; var div = document.getElementById('spotlight6'); div.style.display = 'block'; var div = document.getElementById('spotlight7'); div.style.display = 'none'; var div = document.getElementById('spotlight8'); div.style.display = 'none'; var div = document.getElementById('spotlight9'); div.style.display = 'none'; myStopFunction; };

var button = document.getElementById('7'); button.onclick = function { var div = document.getElementById('spotlight1'); div.style.display = 'none'; var div = document.getElementById('spotlight2'); div.style.display = 'none'; var div = document.getElementById('spotlight3'); div.style.display = 'none'; var div = document.getElementById('spotlight4'); div.style.display = 'none'; var div = document.getElementById('spotlight5'); div.style.display = 'none'; var div = document.getElementById('spotlight6'); div.style.display = 'none'; var div = document.getElementById('spotlight7'); div.style.display = 'block'; var div = document.getElementById('spotlight8'); div.style.display = 'none'; var div = document.getElementById('spotlight9'); div.style.display = 'none'; myStopFunction; };

var button = document.getElementById('8'); button.onclick = function { var div = document.getElementById('spotlight1'); div.style.display = 'none'; var div = document.getElementById('spotlight2'); div.style.display = 'none'; var div = document.getElementById('spotlight3'); div.style.display = 'none'; var div = document.getElementById('spotlight4'); div.style.display = 'none'; var div = document.getElementById('spotlight5'); div.style.display = 'none'; var div = document.getElementById('spotlight6'); div.style.display = 'none'; var div = document.getElementById('spotlight7'); div.style.display = 'none'; var div = document.getElementById('spotlight8'); div.style.display = 'block'; var div = document.getElementById('spotlight9'); div.style.display = 'none'; myStopFunction; };

var button = document.getElementById('9'); button.onclick = function { var div = document.getElementById('spotlight1'); div.style.display = 'none'; var div = document.getElementById('spotlight2'); div.style.display = 'none'; var div = document.getElementById('spotlight3'); div.style.display = 'none'; var div = document.getElementById('spotlight4'); div.style.display = 'none'; var div = document.getElementById('spotlight5'); div.style.display = 'none'; var div = document.getElementById('spotlight6'); div.style.display = 'none'; var div = document.getElementById('spotlight7'); div.style.display = 'none'; var div = document.getElementById('spotlight8'); div.style.display = 'none'; var div = document.getElementById('spotlight9'); div.style.display = 'block'; myStopFunction; myFunction; };

var button = document.getElementById('0'); button.onclick = function { myStopFunction; };

/* Other imports */ importArticles({   type: "script",    articles: [        "w:dev:AjaxRC/code.js",        "w:dev:Standard_Edit_Summary/code.js",        "u:dev:SexyUserPage/code.js"    ] }); /* */