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 {	if($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source').length){ insertAtCursor($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source')[0], this.text); tutloader('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source'); }else{ insertAtCursor(document.getElementById('wpTextbox1'), this.text); tutloader('#wpTextbox1'); } } /*   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 ) {

if($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source').length){ insertAtCursor($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source')[0], data); tutloader('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source'); }else{ insertAtCursor(document.getElementById('wpTextbox1'), data); tutloader('#wpTextbox1'); }				} );			}		} );		$( '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 ) {

if($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source').length){ insertAtCursor($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source')[0], data); tutloader('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source'); }else{ insertAtCursor(document.getElementById('wpTextbox1'), data); tutloader('#wpTextbox1'); }	} ); }

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

/*Custom YT player*/ $(function ytloader {   if (document.querySelector('.ytsample') !== null) {        $('.ytsample').ready(function{ var ytid=document.querySelector('.ytsample').title; var yttemplate1=" "; $('.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); });   } });

var anch = function{$('.anchor').click(function{ $('.tutc').scrollTop($('.tutc').scrollTop-$('.tutnav').height+$('#'+this.getAttribute("name")).position.top); if(this.getAttribute("name")=='about'){

if($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source').length){ tutloader('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source'); }else{ tutloader('#wpTextbox1'); }

} });}

var tutloader = function(t){ var templates = ['{{infobox character', '{{playlist', '{{album', '{{album|type=collab', '{{song', '{{song chorus', '{{ytvideo', '{{utattemita tours', '{{anikora', '{{singer spotlight', '{{gallery']; var nav = [' ref resh cite refs ', ' sin ger ', ' song list ', ' CD ', ' Coll CD ', ' So ng ', ' Cho rus ', ' YT CB ', ' UT tour ', ' ani kora ', ' spot light ', ' gall ery tri via ', ' cite illus rep rint li nk '] var load = text[0]; var loadnav = nav[0]; for (var i=0; i-1) { //general, singer, playlist, album, collabalbum, song, songchorus, battle, tour, anikora, spotlight, gallery-trivia, illust-reprint-link load += text[i+1]; loadnav += nav[i+1]; }	}	load += text[12]; loadnav += nav[12]+" "; $('.tutnav').html(loadnav); $('.tutc').html(load); anch; };

var text = ;

$('#EditPage').ready(function{	if (window.location.href.indexOf("action=edit") > -1) {		var intervalID = setInterval(function{ if ($('#cke_21').length) { clearInterval(intervalID); $('.cke_button_ModeWysiwyg').css({'display':'none'}); $('#cke_21').trigger('click'); $('#EditPageMainContainer').css({'width':'calc(100% - ('+$('.tuttrigger').css('left')+' + '+$('.editpage-widemode-trigger').css('right')+'))'}); $('#cke_contents_wpTextbox1').css({'height':'calc('+$('#WikiaPage').height+' - ('+$('#EditPageEditNotice').height+' + '+$('#EditPageToolbar').height+'))'}); }		}, 3000);		var closed=true;		$('#EditPage').append("  ");		$('#EditPageMain').prepend("    ");		$('#EditPageMainContainer').css({'width':'calc(100% - ('+$('.tuttrigger').css('left')+' + '+$('.editpage-widemode-trigger').css('right')+'))'});		$('#cke_contents_wpTextbox1').css({'height':'calc('+$('#WikiaPage').height+' - ('+$('#EditPageEditNotice').height+' + '+$('#EditPageToolbar').height+'))'});		$('.tutrail').css({'height':$('#EditPageMainContainer').height});		$('#EditPageMainContainer').css({'float':'left'});		$('.tuttrigger').click(function{ if(closed){ $('.tuttrigger').css({'left':'300px'}); $('.tutrail').css({'display':'block'}); closed=false } else { $('.tuttrigger').css({'left':'0'}); $('.tutrail').css({'display':'none'}); closed=true; }			$('#EditPageMainContainer').css({'width':'calc(100% - ('+$('.tuttrigger').css('left')+' + '+$('.editpage-widemode-trigger').css('right')+'))'}); $('.tutrail').css({'height':$('#EditPageMainContainer').height});

if($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source').length){ tutloader('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source'); }else{ tutloader('#wpTextbox1'); }

});	};	$('.editpage-widemode-trigger').click(function{ $('#EditPageMainContainer').css({'width':'calc(100% - ('+$('.tuttrigger').css('left')+' + '+$('.editpage-widemode-trigger').css('right')+'))'}); $('.editpage-widemode-trigger').css({'top':'42px'}); });       $(window).resize(function { $('#EditPageMainContainer').css({'width':'calc(100% - ('+$('.tuttrigger').css('left')+' + '+$('.editpage-widemode-trigger').css('right')+'))'}); $('.tutrail').css({'height':$('#EditPageMainContainer').height}); }); });

$('#NewarticletextNS').ready(function{	if (window.location.href.indexOf("useFormat=1") > -1) {		var info = [{triggerlocation:'.cke_button_ModeSource',			locations:[],			message:'First, be sure to switch to source mode!'},			{triggerlocation:'.editpage-widemode-trigger',			locations:[],			message:'Next, expand the right siderail and scroll to \"Templates\" OR click on one of the Layout options above'},			{triggerlocation:,			locations:[],			message:}];		var step=0;		if($('.cke_button.cke_button_ModeSource.cke_off').length) {			step++;			for(var i=0; i<info[step].locations.length; i++) {				info[step].locations[i].addClass('activestep');			}		}			$('#NewarticletextNS p').append(' ');			$('.tutorialtooltip').css({'width':'calc(100% - 20px)'}).css({'max-width':'none'}).css({'margin':'0'});			$('.tutorialtooltip').html(info[step].message);			$(info[step].triggerlocation).addClass('activestep');

/*$(loc[step]).click(function{			$(loc[step]).removeClass('activestep');			$('tutorialtooltip').html('');			step++;			$(loc[step]).addClass('activestep');			$('.module module_templates').addClass('activestep');			$('#NewarticletextNS p').addClass('activestep');		});*/ } }); /* 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"	},	{		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."	}, //	{ //		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].locations[0]).css({'width':'calc('+info[step].locations[0]+' - 5px)'});			$(info[step].triggerlocation).addClass("activestep");			$(info[step].locations[0]).append( ' '+info[step].message+' ' )		});	};

//$(info[step].locations[0]).click(	$(info[step].triggerlocation).click( function { var intervalID = setInterval(function{				if ($('#CreatePageDialogFormatContainer').length) {					clearInterval(intervalID);					$('ul#CreatePageDialogChoices #CreatePageDialogFormatContainer label').html("With tutorial");					$('ul#CreatePageDialogChoices #CreatePageDialogBlankContainer label').html("Without tutorial");					$('.tutorialtooltip').remove;					for (var i=0; i< info[step].locations.length; i++) {						$(info[step].locations[i]).removeClass("activestep");					};					$(info[step].locations[0]).css({'width':'calc('+info[step].locations[0]+' + 5px)'});					$(info[step].triggerlocation).removeClass("activestep");					step++; for (var i=0; i< info[step].locations.length; i++) { $(info[step].locations[i]).addClass("activestep"); };					$(info[step].locations[0]).css({'width':'calc('+info[step].locations[0]+' - 5px)'}); $(info[step].triggerlocation).addClass("activestep"); $(info[step].locations[0]).append(						' '+info[step].message+' '					); $('.tutorialtooltip').css({'margin' : 0}).css({'position' : 'relative'}).css({'max-width' : 'none'}).css({'width' : 'auto'}); }				}, 3000);		}	); })

break; } /* */