User:Michael von Preußen/monaco.js

function purge { if(wgAction == "purge") { window.location = wgServer+"/wiki/"+wgPageName; } }

addOnloadHook(purge);

// Main Page function mainPageRenameNamespaceTab { try { var Node = document.getElementById( 'ca-nstab-main' ).firstChild; if ( Node.textContent ) {     // Per DOM Level 3 Node.textContent = 'Clannad'; } else if ( Node.innerText ) { // IE doesn't handle .textContent Node.innerText = 'Clannad'; } else {                      // Fallback Node.replaceChild( Node.firstChild, document.createTextNode( 'Clannad Wiki' ) ); }	} catch(e) { // bailing out! } }

if ( wgTitle == 'Main Page' && ( wgNamespaceNumber == 0 || wgNamespaceNumber == 1 ) ) { addOnloadHook( mainPageRenameNamespaceTab ); }

// Disable popups on newpage- and image-click var wgEnableImageLightboxExt = false; var WikiaEnableNewCreatepage = false; var vet_enabled = false;

// Add CreatePage prompt

function npage { var newp=prompt("Please enter a title for the new article.",""); if (newp==null) { var newq = ''; } else { var newq = newp; }; document.getElementById('dynamic-links-write-article-link').setAttribute('href', 'http://clannad.wikia.com/index.php?title='+newq+'&action=create'); }

function pnp { document.getElementById('dynamic-links-write-article-link').setAttribute('onClick', 'npage'); }

addOnloadHook(pnp);

// tab index of search

function searchtab { document.getElementById("search_field").tabIndex = 1; }

addOnloadHook(searchtab);

function watchlist { var us = wgCanonicalNamespace; if((us == "User") || (us == "User_talk") || (us == "User_blog")) { if (wgTitle.indexOf(wgUserName) != -1) { document.getElementById('user_masthead_tab_following').getElementsByTagName('a')[0].innerHTML = 'Watchlist'; document.getElementById('user_masthead_tab_following').getElementsByTagName('a')[0].setAttribute('href', '/wiki/Special:Watchlist'); } } }

YAHOO.util.Event.onContentReady('user_masthead_tab_following', watchlist);

///////////////////////////////////////////////////////////////////////////////////////////////////////////

// ADVANCED AJAX AUTO-REFRESHING ARTICLES // Code courtesy of "pcj" of WoWWiki.

///////////////////////////////////////////////////////////////////////////////////////////////////////////

ajaxPages = ["Special:RecentChanges"];

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 = 60000; function preloadAJAXRC { if (skin == "monaco") { s = 1; } else { s = 0; } ajaxRCCookie = (getCookie("ajaxload-"+wgPageName)=="on") ? true:false; document.getElementsByTagName("h1")[0].innerHTML += ' Automatically 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) { if (location.href.indexOf("/wiki/")) { rcURL = "http://" + location.hostname + "/wiki/" + wgPageName + location.search; } else { rcURL = "http://" + location.hostname + "/" + wgPageName + location.search; } getRCDataRO.open("GET", rcURL, 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); } }

for (x in ajaxPages) { if (wgPageName == ajaxPages[x]) addOnloadHook(preloadAJAXRC); }

///////////////////////////////////////////////////////////////////////////////////////////////////////////

// END OF AJAX AUTO-REFRESH

///////////////////////////////////////////////////////////////////////////////////////////////////////////

//