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); insertAtCursor($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source')[0], this.text);

} /*   end preload code /* Template Preloads * Original by User:Grunny * Source - w:c:starwars:MediaWiki:Wikia.js * Altered to replace Wiki's 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 );                                       insertAtCursor($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source')[0], data);				} ); }		} );		$( 'div#lf-preload' ).append( $preloadOptionsList );	} ); $( '#lf-preload-pagename-w' ).html( '' ); $( '#lf-preload-button-w' ).html( '' ); } $( customPreloadTemplates ); $(function {       if (window.CKEDITOR) {            CKEDITOR.on("instanceReady", function  { $( 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 );		insertAtCursor($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source')[0], data);	} ); }

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

/*Custom YT player*/ $(function ytloader {   if (document.querySelector('.ytsample') !== null) {        $('.ytsample').ready(function{ var ytid=document.querySelector('.ytsample').title; var yttemplate1="<div style='width: 202px; overflow: hidden; height: 21px; margin-top: 5px; margin-bottom: 5px; margin-right: 5px; position:relative; top:0; border: 3px solid #0f0f0f; border-radius:10px'><iframe width='417' height='23' src='http://www.youtube.com/embed/"; var yttemplate2="?version=3&hl=en_US&theme=dark&color=white&loop=1&showinfo=0&autohide=0&disablekb=1&autoplay=0' frameborder='0' allowfullscreen=0> "; $('.ytsample').append(yttemplate1+ytid+yttemplate2); });   } });

/*Custom TMbox player*/ $(function tmloader {   if (document.querySelector('.tmsample') !== null) {        $('.tmsample').ready(function{ var tmid=document.querySelector('.tmsample').title; var tmtemplate1=" "; $('.tmsample').append(tmtemplate1+tmid+tmtemplate2); });   } });

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

switch (mw.config.get('wgPageName')) { case 'Sandbox':

$(document).ready(function {	var step = 0;	var info = [{		triggerlocation:'.WikiaMenuElement li a.createpage',		locations:['.wikia-menu-button.contribute.secondary.combined'],		message:"Welcome to the Utaite Wiki editing tutorial! Learn editing and the syntax on our wiki at your own pace in an interactive way! This tutorial focuses on source code editing. If you're ready, go ahead and click the \"Contribute\" button above! For bug reports, please contact BLUEBIRD</a>",		margins:'30px 10px 10px -200px'	},	{		triggerlocation:'button.button.normal.primary',		locations:['#CreatePageDialogFormatContainer', '#wpCreatePageDialogTitle'],		message:"Input your preferred pagename, and select \"With Tutorial\" for tutorial hints. Once you're comfortable editing without hints, check the \"Without tutorial\" option. Once selected, click the \"Add a Page\" button.", margins:'-100px 10px 10px -250px' },	{		triggerlocation:'', locations:[''], message:"", margins:'' }];		//$('ul.wds-global-footer__links-list li:first-child').html("Asdfjkl"); if (step==0) { (function {			for (var i=0; i< info[step].locations.length; i++) {				$(info[step].locations[i]).addClass("activestep");			};			$(info[step].triggerlocation).addClass("activestep");			$(info[step].locations[0]).append( ' '+info[step].message+' ' )			$('.tutorialtooltip').css({'margin' : info[step].margins});		}); };

if ($('#CreatePageModalDialog').length) { console.log("Qwert"); } else {console.log("Orz")}

//$(info[step].locations[0]).click(	$(info[step].triggerlocation).click( function { console.log("Testing 123"); var intervalID = setInterval(function{				console.log("Waiting orz");				if ($('#CreatePageModalDialog').length) {					console.log("Ready");					clearInterval(intervalID);				}			}, 3000); console.log("Welp");

$('ul#CreatePageDialogChoices #CreatePageDialogFormatContainer label').html("With tutorial<img src='http://slot1.images.wikia.nocookie.net/__cb1480701179/common/extensions/wikia/CreatePage/images/thumbnail_format_video.png'>"); $('ul#CreatePageDialogChoices #CreatePageDialogBlankContainer label').html("Without tutorial<img src='http://slot1.images.wikia.nocookie.net/__cb1480701179/common/extensions/wikia/CreatePage/images/thumbnail_format_video.png'>"); $('.tutorialtooltip').remove; for (var i=0; i< info[step].locations.length; i++) { $(info[step].locations[i]).removeClass("activestep"); };				$(info[step].triggerlocation).removeClass("activestep"); step++; for (var i=0; i< info[step].locations.length; i++) { $(info[step].locations[i]).addClass("activestep"); };				$(info[step].triggerlocation).addClass("activestep"); $(info[step].locations[0]).append(					' '+info[step].message+' '				); $('.tutorialtooltip').css({'margin' : info[step].margins}); }	); })

break; }

/* */