User:Azuris/wikia.js

/*** code from http://runescape.wikia.com/wiki/User:Rwojy/autorefresh.js ***/ var enableAjaxRC = false; ajaxPages = new Array("Special:RecentChanges", "Special:Watchlist", "Special:Log", "Special:Contributions", "Forum:War_Room"); 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 getXmlHttpRequestObject { if (window.XMLHttpRequest) { return new XMLHttpRequest; //Not Internet Explorer } else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); //Internet Explorer } else { //fail silently } } getRCDataRO = getXmlHttpRequestObject; var cr = new RegExp("\r", "gm"); var lf = new RegExp("\n", "gm"); var endText = new RegExp(' [\t\s]*?[\t\s]*? ', "mi"); var rcTimer; var rcRefresh = 8000; function preloadAJAXRC { if (skin == "monaco") { s = 1; } else { s = 0; } ajaxRCCookie = (getCookie("ajaxload-"+wgPageName)=="on") ? true:false; $('h1:first,#user_masthead_head h2').append(' Auto-refresh '); document.getElementById("ajaxRCtoggle").checked = ajaxRCCookie; if (getCookie("ajaxload-"+wgPageName)=="on") loadRCData; } function toggleRC { if (document.getElementById("ajaxRCtoggle").checked == true) { setCookie("ajaxload-"+wgPageName, "on", 30); loadRCData; } else { setCookie("ajaxload-"+wgPageName, "off", 30); clearTimeout(rcTimer); } } function loadRCData { if (getRCDataRO.readyState == 4 || getRCDataRO.readyState == 0) { getRCDataRO.open("GET", document.location.href, true); getRCDataRO.onreadystatechange = parseRCdata; getRCDataRO.send(null); } } function parseRCdata { if (getRCDataRO.readyState == 4) { textFilter = new RegExp(' .*? [\t\s]*?[\t\s]*? ', "i"); rawRCdata = getRCDataRO.responseText.replace(cr, "").replace(lf, ""); filteredRCdata = textFilter.exec(rawRCdata); updatedText = filteredRCdata[0].replace(' ', "").replace(endText, ""); document.getElementById("bodyContent").innerHTML = updatedText; rcTimer = setTimeout("loadRCData;", rcRefresh); } } if (wgAction == 'view' || wgAction == 'history') { $(document).ready(preloadAJAXRC); }

/* */ /***Restore blog comment links begin ***/

function fixBlogLinks { if (wgPageName == "Special:RecentChanges") $("#bodyContent ul.special li:contains('article-comments-rc-blog-comment')").each(function (i) { oldHTML = $(this).html; lnk = $(this).find("a:contains('hist')").attr("href"); if (typeof(lnk) != "undefined") { rawID = lnk.replace(/.*curid=(.*?)&.*/,"$1"); bLink = "/wiki/User_blog:" + lnk.replace(/.*User_blog_comment:(.*?\/.*?)\/.*/,"$1") + "?showall=1#comm-" + rawID; newHTML = oldHTML.replace("&lt;article-comments-rc-blog-comment&gt;","(Blog comment) "); $(this).html(newHTML); } }); } function fbl { fixBlogLinks; $("#bodyContent").bind("ajaxPageLoad",fixBlogLinks); } addOnloadHook(fbl);

/*** -end- ***/

if (wgAction == "edit" || wgAction == "submit") {

/***** Custom edit buttons *****/ if (mwCustomEditButtons) {

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/__cb20100501203037/callofduty/images/1/17/Button_Ssig.jpg", "speedTip": "Signature", "tagOpen": "-- ~"+""+"", "tagClose": "", "sampleText": ""};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images1.wikia.nocookie.net/__cb20100501203037/callofduty/images/8/8b/Button_Vvandal.jpg", "speedTip": "Vandalism Template (CE)", "tagOpen": "", "sampleText": "PAGE"};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/__cb20100522190829/callofduty/images/e/e8/Button-W-CE.jpg", "speedTip": "Welcome (CE)", "tagOpen": "CodExpert", "sampleText": ""};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/__cb20100708142061/callofduty/images/b/b9/Button_Bblock.jpg", "speedTip": "Block", "tagOpen": "", "sampleText": "BLOCKDURATION"};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/__cb20100807154327/callofduty/images/f/f5/Button_Bblockindefinate.jpg", "speedTip": "Block/Indefinitely", "tagOpen": "", "tagClose": "", "sampleText": ""};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/__cb20100807154332/callofduty/images/0/03/Button_Bblocksock.jpg", "speedTip": "Block/Sockpuppet", "tagOpen": "", "tagClose": "", "sampleText": ""};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/__cb20100726151151/callofduty/images/6/67/Button_DDD.jpg", "speedTip": "DDD", "tagOpen": "", "tagClose": "", "sampleText": ""};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images4.wikia.nocookie.net/__cb20100806124144/callofduty/images/1/17/Button_Ttalktextreg.jpg", "speedTip": "Talk box", "tagOpen": "", "sampleText": "TEXT"}; } } /* */