User:Calua/global.js

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

/* Creates Back To Top Button In Footer */ importScriptPage('BackToTopButton/code.js', 'dev'); var Speed = 50;

/* Special:Chat Extension */

importScriptPage('User:Monchoman45/ChatHacks.js', 'c'); importScriptPage('User:Joeytje50/ChatPMs.js', 'c');

/* Purge button */ PurgeButtonText = 'purge'; importScriptPage('PurgeButton/code.js', 'dev'); /* Custom edit buttons * Original by User:Grunny */ mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images1.wikia.nocookie.net/central/images/7/73/Button_code_nowiki.png?1", "speedTip": "code+nowiki", "tagOpen": " ", "sampleText": "Insert code here"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images1.wikia.nocookie.net/central/images/2/29/Button_user.png?1", "speedTip": "Global user template", "tagOpen": "", "tagClose": "", "sampleText": ""}; /* Chat modifications */ importScriptPage('User:ToaMeiko/chat-global.js', 'c'); /* Roranoa's chat hacks */ /* Originally by Monchoman45*/ /* change wiki activity to recent changes - 2/1/11 */ function WikiActivity2RecentChanges { $('a.wikia-button[data-id$="wikiactivity"]').replaceWith('Recent Changes'); } addOnloadHook(WikiActivity2RecentChanges); /*Roranoa's chat hacks*/ importScriptURI('http://monchbox.wikia.com/index.php?title=MediaWiki:APIQuery.js&action=raw&ctype=text/javascript'); importScriptURI('http://monchbox.wikia.com/index.php?title=MediaWiki:B3.js&action=raw&ctype=text/javascript'); importScriptURI('http://monchbox.wikia.com/index.php?title=MediaWiki:WhamAPI.js&action=raw&ctype=text/javascript'); importScriptURI('http://c.wikia.com/index.php?title=User:Monchoman45/ChatHacks.js&action=raw&ctype=text/javascript'); /* Chat options */ var chatOptionsLoaded; if (chatOptionsLoaded != 1){ chatOptionsLoaded = 1; importScriptPage('MediaWiki:Chat.js/options.js','cod'); } /* Block Chat Messages */ if (mw.config.get('wgPageName') === 'Special:Chat') { $(function {        "use strict";        function createUl(blockee) {            var isBlocked = $("#WikiChatList>li[data-user='"+blockee+"']").hasClass("blockee");            if (isBlocked === false) {                $('.regular-actions').after('  Block Messages ');            } else {                $('.regular-actions').after('  Allow Messages ');            }	            $("li.ignore").click(function { ignore(blockee); });        }        function ignore(blockee) {            var blockStyle;			var blockee = blockee;            var isBlocked = $("#WikiChatList>li[data-user='"+blockee+"']").hasClass("blockee");            var isMod = $("#WikiChatList>li[data-user='"+blockee+"']").hasClass("chat-mod");            if (isMod === false) {                if (isBlocked === false) {                    $("li.ignore").addClass("blue");                    blockStyle = document.createElement("style"); blockStyle.innerHTML = ("li[data-user='"+blockee+"']:not(.User){display: none;}"); blockStyle.setAttribute("id", "blockStyle-"+blockee); document.head.appendChild(blockStyle); $("#WikiChatList>li[data-user='"+blockee+"']").addClass("blockee"); $(".UserStatsMenu li.ignore>span.label").replaceWith(" Allow Messages "); } else { $("li.ignore").removeClass("blue"); blockStyle = document.getElementById("blockStyle-"+blockee); blockStyle.parentNode.removeChild(blockStyle); $("#WikiChatList>li[data-user='"+blockee+"']").removeClass("blockee"); $(".UserStatsMenu li.ignore>span.label").replaceWith(" Block Messages "); }           } else { var lastMsg = $('.Chat>ul>li:last-child'); var lastMsgIsAlert = lastMsg.hasClass("inline-alert"); if (lastMsgIsAlert === true) { lastMsg.after("You cannot block chat moderators, administrators, or Wikia staff members."); } else { lastMsg.after("You cannot block chat moderators, administrators, or Wikia staff members."); }           }        }        function createUlCall { var blockee = $(this).attr('data-user'); setTimeout(function { createUl(blockee); }, 0); }       $("#WikiChatList").on("click", "li.User", createUlCall); var messageBlockerStyle = document.createElement("style"); messageBlockerStyle.innerHTML = ".UserStatsMenu .actions li.ignore .icon { background-image: url('http://images.wikia.com/dzy/images/8/81/Sprite-chat-ignore.png'); } .UserStatsMenu .actions li.ignore .icon { background-position: -0px 0; } .UserStatsMenu .actions li.ignore:hover .icon { background-position: -31px 0; } .UserStatsMenu .actions li.ignore.blue .icon { background-position: -67px 0; } .UserStatsMenu .actions li.ignore.blue:hover .icon { background-position: -98px 0; } #WikiChatList>li.blockee { background: #FFE6D8; !important } .ignore span.label { position: relative; bottom: 5px; left: 3px; }"; document.head.appendChild(messageBlockerStyle); }); } /* cookie init */ function CheckCookie {	if(readCookie('globalJS') == null) {		createCookie('globalJS', 'true', 99999);	}	if(skin == 'oasis') {$('#AccountNavigation').prepend(' JS </a></li>');} } addOnloadHook(CheckCookie); function ToggleGlobalJSCookie {	if(readCookie('globalJS') == 'true') {		createCookie('globalJS', 'false', 99999);		$('#GlobalJSText').html('Off');	}	else {		createCookie('globalJS', 'true', 99999);		$('#GlobalJSText').html('On');	}	window.location.reload(true); } //ajax RecentChanges from dev.wikia /* * ADVANCED AJAX AUTO-REFRESHING ARTICLES * Code courtesy of "pcj" of Wowpedia. */ var indicator = 'http://images2.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif'; if (!window.ajaxPages) ajaxPages = new Array('Special:RecentChanges'); var ajaxTimer; var ajaxRefresh = 30000; var refreshText = 'Auto Refresh'; if(typeof AjaxRCRefreshText == 'string') { refreshText = AjaxRCRefreshText; } var refreshHover = 'Enable auto-refreshing page loads'; if(typeof AjaxRCRefreshHoverText == 'string') { refreshHover = AjaxRCRefreshHoverText; } var doRefresh = true; function setCookie(c_name, value, expiredays) { var exdate = new Date exdate.setDate(exdate.getDate + expiredays) document.cookie = c_name + '=' + escape(value) + ((expiredays==null) ? '' : ';expires=' + exdate.toGMTString) } function getCookie(c_name) { if (document.cookie.length>0) { c_start = document.cookie.indexOf(c_name + '='); if (c_start != -1) { c_start = c_start + c_name.length+1; c_end = document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start, c_end)); } 	}	return ""; } function preloadAJAXRL { ajaxRLCookie = (getCookie('ajaxload-' + wgPageName) == 'on') ? true : false; appTo = ($('#WikiaPageHeader').length) ? $('#WikiaPageHeader') : $('.firstHeading'); appTo.append(' <span style="border-bottom: 1px dotted; cursor: help;" id="ajaxToggleText" title="' + refreshHover + '">' + refreshText + ': <input type="checkbox" style="margin-bottom: 0;" id="ajaxToggle"> <img src="' + indicator + '" style="vertical-align: baseline;" border="0" alt="Refreshing page" /> '); $('#ajaxLoadProgress').ajaxSend(function (event, xhr, settings){		if (location.href == settings.url) $(this).show;	}).ajaxComplete (function (event, xhr, settings){		if (location.href == settings.url) $(this).hide;	}); $('#ajaxToggle').click(toggleAjaxReload); $('#ajaxToggle').attr('checked', ajaxRLCookie); if (getCookie('ajaxload-' + wgPageName) == 'on') loadPageData; } function toggleAjaxReload { if ($('#ajaxToggle').attr('checked') == true) { setCookie('ajaxload-' + wgPageName, 'on', 30); doRefresh = true; loadPageData; }	else { setCookie('ajaxload-' + wgPageName, 'off', 30); doRefresh = false; clearTimeout(ajaxTimer); } } function loadPageData { cC = ($('#WikiaArticle').length) ? '#WikiaArticle' : '#bodyContent'; $(cC).load(location.href + ' ' + cC + ' > *', function (data) { 		if (doRefresh) ajaxTimer = setTimeout('loadPageData;', ajaxRefresh);	}); } addOnloadHook(function { 	for (i in ajaxPages) {		if (wgPageName == ajaxPages[i] && $('#ajaxToggle').length == 0) preloadAJAXRL;	} }); /* change wiki activity to recent changes - 2/1/11 */ function WikiActivity2RecentChanges { $('a.wikia-button[data-id$="wikiactivity"]').replaceWith('<a data-id="recentchanges" class="wikia-button secondary" accesskey="g" title="Special:RecentChanges" href="/wiki/Special:RecentChanges"><img height="0" width="0" class="sprite activity" src="http://images1.wikia.nocookie.net/common/skins/common/blank.gif">Recent Changes</a>'); } addOnloadHook(WikiActivity2RecentChanges); /* add contribs to user menu*/ function UserContribsMenuItem { $('ul.AccountNavigation li:first-child ul.subnav li:first-child').after('<a href="/wiki/Special:Contributions/'+ encodeURIComponent (wgUserName) +'">Contributions</a></li>'); } addOnloadHook(UserContribsMenuItem); // ============================================================ // Standard edit summaries // ============================================================ $(function {	var $label = $('#wpSummaryLabel');	if (!$label.size) {		return;	}	$combo = $(' ').attr('id', 'stdSummaries').change(function { var val = $(this).val; if (val != '') { $('#wpSummaryEnhanced,#wpSummary').val(val); }	});	$label.prepend(' ').prepend($combo).prepend('Summaries: ');	$.ajax({ 'dataType': 'text', 'data': { 'title': 'Template:Stdsummaries', 'action': 'raw', 'ctype': 'text/plain' },		'url': wgScript, 'success': function(data) { var lines = data.split("\n"); for (var i in lines) { var val = (lines[i].indexOf('-- ') == 0) ? lines[i].substring(3) : ''; var $opt = $(' ').val(val).text(lines[i]); $combo.append($opt); }		}	}); }); /*My blogs!*/ function UserBlogsMenuItem { $('.AccountNavigation li:first-child .subnav li:first-child').after('<a href="/wiki/User_blog:' + wgUserName + '">Blogs</a></li>'); } addOnloadHook(UserBlogsMenuItem); //Recent Changes Module importScriptURI('https://raw.github.com/PrincessPlatinum/Wikia-User-Scripts/master/Wikia-Recent-Module'); //template placer importScriptURI('https://raw.github.com/PrincessPlatinum/Wikia-User-Scripts/master/AjaxTemplate.js'); importArticles({   type: "script",    articles: [        "u:dev:ListFiles/code.js" // ListFiles from Dev Wiki    ] }); importScriptPage('MessageBlocker_2/code.js', 'dev'); importArticles({ type: 'script', articles: [    'u:dev:Standard_Edit_Summary/code.js' ]});