User:Fisker/wowwiki.js

/*

var wgBreakFrames = true; var tooltipAccessKeyRegexp = /\[(ctrl-)?(alt-)?(shift-)?(esc-)?.\]$/; var mwEditButtons = [];

/* detects which key is down */ document.onkeydown = KeyDownHandler; document.onkeyup = KeyUpHandler; var CTRL = false; var SHIFT = false; var ALT = false; var SPACE = false;

function KeyDownHandler(e) { var x = ''; if (document.all) { var evnt = window.event; x = evnt.keyCode; } else { x = e.keyCode; } DetectKeys(x, true); }

function KeyUpHandler(e) { var x = ''; if (document.all) { var evnt = window.event; x = evnt.keyCode; } else { x = e.keyCode; } DetectKeys(x, false); }

function DetectKeys(KeyCode, IsKeyDown) { if (KeyCode == '16') { SHIFT = IsKeyDown; } else if (KeyCode == '17') { CTRL = IsKeyDown; } else if (KeyCode == '18') { ALT = IsKeyDown; } else if (KeyCode == '32') { SPACE = IsKeyDown; } }

/* changes the Google search box to MediaWiki search box */ function changeSearch { document.getElementById('p-search').innerHTML = " Search    "; }

/* goes to user talk page, used in next function */ function goTalk { window.location = "http://www.wowwiki.com/User_talk:Fisker?diff=cur"; }

/* changes the personal links (at the top) to include direct links to the customized CSS and JS pages, hides the regular "You have new messages" frame and places the quest icon by the talk link when there are new messages */ function changePersonal { var divs = document.getElementsByTagName('div'); var tmlt = ""; for (i=0; i   "; } } document.getElementById('p-personal').innerHTML = " Personal tools Fisker" + tmlt + "talk<a href='/User:Fisker/wowwiki.css'>css</a></li><a href='/User:Fisker/wowwiki.js'>js</a></li><a href='/Special:Preferences'>preferences</a></li><a href='/Special:Userlogout'>Log out</a></li></ul> "; }

/* changes "navigation" links */ function changeNavigation { document.getElementById('p-navigation').innerHTML = " navigation <ul><a href='/Main_Page'>Main Page</a></li><a href='/index.php?title=Special:Recentchanges&limit=100'>Recent changes</a></li><a href='/Special:Random'>Random page</a></li><a href='/Special:Wantedpages'>Wanted pages</a></li></ul> "; }

/* changes "popular" links to more convenient personal favorites */ function changePopular { document.getElementById('p-popular').innerHTML = " personal favorites <ul><a href='/WW:GOUS'>User styles</a></li><a href='/Karazhan'>Karazhan</a></li><a href='/WW:KV'>Known vandals</a></li><a href='/Server:Maelstrom_US'>Maelstrom</a></li><a href='/Coming_Soon'>Coming Soon</a></li></ul> "; }

/* goes to the edit page, used in next function */ function goToEditPage { if (CTRL) { pageName = document.getElementsByTagName('h1')[0].firstChild.nodeValue.replace(" ", "_"); window.location = "http://www.wowwiki.com/index.php?title=" + pageName + "&action=edit"; } }

/* fixes the problem with the preference "double click to edit" when you can't edit a given page */ function fixViewSource { if (document.getElementById('ca-viewsource')) { if (document.getElementById('ca-viewsource').className != 'selected') { document.body.onclick = goToEditPage; } } }

/* previews submission, used in next function */ function goToPreview { document.editform.wpPreview.click; }

/* bypasses Preview access key glitch */ function fixPreview { if (document.getElementById('ca-edit')) { if (document.getElementById('ca-edit').className == 'selected') { document.body.ondblclick = goToPreview; } } }

/* refreshes the page */ function refreshPage { window.location.reload; }

/* refreshes non-editable pages on double-click */ function refreshRC { if (!(document.getElementById('ca-edit') || (document.getElementById('ca-viewsource')))) { document.body.ondblclick = refreshPage; } }

/* used in next function */ function editPageFromWhatLinksHere { pageName = document.getElementsByTagName('h1')[0].firstChild.nodeValue.replace(" ", "_"); if (!(CTRL)) { window.location = "http://www.wowwiki.com/index.php?title=" + pageName + "&action=edit"; } }

/* edits page on single click of a "what links here" page, useful in marking something for speedy deletion when nothing links to it */ function whatLinksHereEdit { if (document.URL.indexOf('Special:Whatlinkshere') != -1) { document.body.onclick = editPageFromWhatLinksHere; } }

/* adds text to top of edit box */ function addEditTextToTop(addtext, summary) { document.editform.wpTextbox1.value = addtext + "\n\n" + document.editform.wpTextbox1.value; document.editform.wpSummary.value = summary; document.editform.wpSave.click; }

/* adds text to bottom of edit box */ function addEditTextToBottom(addtext, summary) { document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + "\n\n" + addtext; document.editform.wpSummary.value = summary; document.editform.wpSave.click; }

/* replaces text */ function replaceText(replacetxt, summary) { document.editform.wpTextbox1.value = replacetxt; document.editform.wpSummary.value = summary; document.editform.wpSave.click; } /* add welcome tab on User talk pages */ function welcomeUser { if ((window.location.href.indexOf('User_talk') != -1) && (window.location.href.indexOf('action=edit') != -1)) { if (document.editform.wpTextbox1.value == "") { addPortletLink('p-cactions', 'javascript:addEditTextToTop("{' + '{' + 'sub' + 'st::User:Fisker/w' + '}' + '}", "Welcome!");', 'welcome', 'ca-welcome', 'Welcome User', ''); } } }

/* add laurlybot tab */ function laurlybot { if (document.getElementById('ca-edit')) { if ((window.location.href.indexOf('User') == -1) && (window.location.href.indexOf('User_talk') == -1) && (window.location.href.indexOf('Talk') == -1) && (window.location.href.indexOf('action=edit') != -1)) { if (window.location.href.indexOf('Quest') == -1) { addPortletLink('p-cactions', 'javascript:addEditTextToTop("{' + '{' +  + ':User:Laurlybot/Donpc' + '}' + '}", "Tagging for LaurlyBot");', 'laurlybot', 'ca-lbot', 'Tag page for LaurlyBot', ); } else { addPortletLink('p-cactions', 'javascript:addEditTextToTop("{' + '{' +  + ':User:Laurlybot/Doquests' + '}' + '}", "Tagging for LaurlyBot");', 'laurlybot', 'ca-lbot', 'Tag page for LaurlyBot', ); } } } }

/* add foxbot tab */ function foxbot { if (document.getElementById('ca-edit')) { if ((window.location.href.indexOf('User') == -1) && (window.location.href.indexOf('User_talk') == -1) && (window.location.href.indexOf('Talk') == -1) && (window.location.href.indexOf('Quest') == -1) && (window.location.href.indexOf('action=edit') != -1)) { addPortletLink('p-cactions', 'javascript:addEditTextToTop("{' + '{' +  + ':User:Fisker/f' + '}' + '}", "Tagging for Foxbot");', 'foxbot', 'ca-fbot', 'Tag page for Foxbot', ); } } }

/* handles SD request */ function doSD { reason = prompt("Reason for sd", "") if (reason) { addEditTextToTop("", "Speedydelete - " + reason); } }

/* add speedydelete tab */ function speedydelete { if (document.getElementById('ca-edit')) { if ((window.location.href.indexOf('User') == -1) && (window.location.href.indexOf('User_talk') == -1) && (window.location.href.indexOf('Talk') == -1) && (window.location.href.indexOf('action=edit') != -1)) { addPortletLink('p-cactions', 'javascript:doSD;', 'sd', 'ca-sd', 'Mark for speedy deletion', ''); } } }

/* does everything */ function doStuff { changePersonal; changeNavigation; changePopular; changeSearch; fixViewSource; fixPreview; refreshRC; whatLinksHereEdit; welcomeUser; laurlybot; foxbot; speedydelete; }

/* makes the page wait until it's loaded before it does everything, otherwise it won't be able to access the parts of the page which haven't loaded yet */ addOnloadHook(doStuff);

/* including other pages */ document.write('<script type="text/javascript" src=" \ http://www.wowwiki.com/index.php?title=User:Pcj/autoedit.js \ &action=raw&ctype=text/javascript&dontcountme=s"> ');

/* pcj tooltip stuff */ document.write('<script type="text/javascript" src=" \ http://www.wowwiki.com/index.php?title=User:Pcj/itemtooltip.js \ &action=raw&ctype=text/javascript&dontcountme=s"> '); /*