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: ' +			' Custom preload pagename: '	$( '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( '' ); $( '#lf-preload-button-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 );	} ); }

/* ================  Other imports ================ */

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

/* 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');

/* notebar; 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

if (window.WikiaEditor.getInstance('wpTextbox1').ck.document) { // Visual RTE RTE.getInstance.on("wysiwygModeReady", ""); } else { // Source RTE $(function converter { converticon=" Convert "; $('.cke_button.RTEImageButton.cke_button_big').append(converticon); }); }

/* */