User:Godisme/global.js

function AddRecentChanges { $('div.buttons').css({'width': '310px'}); $('a[data-id="wikiactivity"]').after('Recent Changes'); }

addOnloadHook(AddRecentChanges);

/* kill image popups - 3/30/11 */ function changeimagelinks {

if (window.skin == 'oasis') { var article = $('#WikiaArticle, .LatestPhotosModule, #article-comments'); }   else { var article = $('#bodyContent'); }

article.unbind('click.lightbox');

var a = document.getElementsByTagName("a"); for ( var t = 0; t < a.length; ++t ) { var a2 = a[t]; var img = a2.getElementsByTagName("img"); if ( img[0] != null ) { if ( a2.href.indexOf("images.wikia.com") != -1 ) { var link = wgServer + '/wiki/File:' + a2.href.substring(a2.href.lastIndexOf('/') + 1); a2.setAttribute('href',link); }       }    } }

addOnloadHook(changeimagelinks);

//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 = 20000; 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(' ' + refreshText + ':   '); $('#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;	} });

/* get all personal code files in chat */ /* Important: you must click the chat button in the rail for this to work. */   /* Very important: Chat is still a beta feature. Chat hacks may break as the feature is changed and updated, as it is a work in progress. */   $(setTimeout('ChatCheck', 200)); function ChatCheck { if($('.chat-join button').length != 0) { $('.chat-join button').replaceWith('Join the Chat'); } else { setTimeout('ChatCheck', 200); }   }    function OpenChatWindow { window.chatwindow = window.open('/index.php?title=Special:Chat&useskin=wikia'); window.chatwindow.onload = function { //addOnloadHook, importScript, and importStylesheet window.chatwindow.$('body').prepend(' \nfunction importScript(b){var a=wgScript+"?title="+encodeURIComponent(b.replace(/ /g,"_")).replace(/%2F/ig,"/").replace(/%3A/ig,":")+"&action=raw&ctype=text/javascript";return importScriptURI(a)}\nfunction importScriptURI(a){var b=document.createElement("script");b.setAttribute("src",a);b.setAttribute("type","text/javascript");document.getElementsByTagName("head")[0].appendChild(b);return b}\nfunction importScriptPage(b,d){var a="/index.php?title="+encodeURIComponent(b.replace(/ /g,"_")).replace("%2F","/").replace("%3A",":")+"&action=raw&ctype=text/javascript";if(typeof d=="string"){if(d.indexOf("://")==-1){a="http://"+d+".wikia.com"+a}else{a=d+a}}return importScriptURI(a)}\nfunction importStylesheet(a){return importStylesheetURI(wgScript+"?action=raw&ctype=text/css&title="+encodeURIComponent(a.replace(/ /g,"_")))}\nfunction importStylesheetURI(b,d){var a=document.createElement("link");a.type="text/css";a.rel="stylesheet";a.href=b;if(d){a.media=d}document.getElementsByTagName("head")[0].appendChild(a);return a}\nfunction importStylesheetPage(b,d){var a="/index.php?title="+encodeURIComponent(b.replace(/ /g,"_")).replace("%2F","/").replace("%3A",":")+"&action=raw&ctype=text/css";if(typeof d=="string"){if(d.indexOf("://")==-1){a="http://"+d+".wikia.com"+a}else{a=d+a}}return importStylesheetURI(a)}\n//This isn\'t the same as the regular addOnloadHook, because the regular one runs from a script tag in the body that I don\'t feel like appending. It\'s easier to just make it $(function), which is essentially equivalent\nfunction addOnloadHook(func) {$(func);}\n ');                   //global.js                    window.chatwindow.importScriptURI('http://community.wikia.com/index.php?title=User:' + wgUserName + '/global.js&action=raw&ctype=text/javascript');                    //wikia.js                    window.chatwindow.importScriptURI(wgServer + '/index.php?title=User:' + wgUserName + '/wikia.js&action=raw&ctype=text/javascript');                    //global.css                    window.chatwindow.importStylesheetURI('http://community.wikia.com/index.php?title=User:' + wgUserName + '/global.css&action=raw&ctype=text/css');                    //wikia.css                    window.chatwindow.importStylesheetURI(wgServer + '/index.php?title=User:' + wgUserName + '/wikia.css&action=raw&ctype=text/css');                    //These are my chat hacks. If you don't want them, you can delete this line. window.chatwindow.importScriptURI('http://community.wikia.com/index.php?title=User:Monchoman45/ChatHacks.js&action=raw&ctype=text/javascript'); }   } function CustomRollbacks { var Buttons = [{ //Your buttons go here. You can copy and paste this to make more than three text: 'spam', title: 'Revert spam', summary: 'spam' }, {		text: 'vandalism', title: 'Revert vandalism', summary: 'vandalism' }, {	       text: 'bad edit', title: 'Revert bad edit', summary: 'bad edit' }, {		text: 'null', title: 'Revert with no summary', summary: ' &bot=1' //This one has no summary, and flags it as a bot edit

}];

var list = document.getElementsByTagName('span'); for(i in list) { if(list[i].className == 'mw-rollback-link') { var link = list[i]; var rollback = link.innerHTML; for(j in Buttons) { var customlink = document.createElement('span'); customlink.innerHTML = rollback; customlink.className = 'customrollback'; //we do this to avoid an infinite loop, because when we insert a into the DOM, the list variable includes it				customlink.getElementsByTagName('a')[0].title = Buttons[j].title; customlink.getElementsByTagName('a')[0].href += '&summary=' + Buttons[j].summary; customlink.getElementsByTagName('a')[0].innerHTML = Buttons[j].text; if(urlQuery('action') == 'history') { link.parentElement.insertBefore(customlink, link.nextSibling); customlink.outerHTML = ' | ' + customlink.outerHTML; }				else { link.parentElement.appendChild(customlink); customlink.outerHTML = ' ' + customlink.outerHTML; }			}		}	}	for(i in list) { //why another one of these? we're fixing the class that we set to avoid an infinite loop if(list[i].className == 'customrollback') { list[i].className = 'mw-rollback-link'; }	} }

addOnloadHook(CustomRollbacks);

function urlQuery(quer) { for(i in location.href.split('?')) { for(j in location.href.split('?')[i].split('&')) { if(location.href.split('?')[i].split('&')[j].split('=')[0] == quer) { return location.href.split('?')[i].split('&')[j].split('=')[1]; }		}	}	return ''; }