User:Pcj/wowwiki.js
From WoWWiki
< User:Pcj
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac)
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5
- Konqueror: simply click the Reload button, or press F5
- Opera users may need to completely clear the cache in Tools→Preferences.
ajaxPages += "Special:Watchlist";
/*
{{anchor|search|changes the Google search box to MediaWiki search box}}
<pre>
*/
function changeSearch() {
$('#p-search').html("<h5><label for='searchInput'>Search</label></h5><div id='searchBody' class='pBody'><form action='/index.php?title=Special:Search' id='searchform'><div><input id='searchInput' name='search' title='Search WoWWiki [alt-shift-f]' accesskey='f' value='' type='text'><input name='go' class='searchButton' id='searchGoButton' value='Go' type='submit'> <input name='fulltext' class='searchButton' id='mw-searchButton' value='Search' type='submit'></div></form></div>");
}
/*
</pre>
{{anchor|goTalk|goes to user talk page, used in next function}}
<pre>
*/
function goTalk() {
window.location = "http://www.wowwiki.com/User_talk:Pcj?diff=cur";
}
function urchinTracker() {} //fix error caused by blocking google stuff
/*
</pre>
{{anchor|personal|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}}
<pre>
*/
function changePersonal() {
var tmlt = "";
if ($('div.usermessage').html()) tmlt = "<li id='pt-mytalkicon' onClick='goTalk();'> </li>";
$('#p-personal').html("<h5>Personal tools</h5><div class='pBody'><ul><li id='pt-userpage'><a href='/User:Pcj'>Pcj</a></li>" + tmlt + "<li id='pt-mytalk'><a href='/User_talk:Pcj'>talk</a></li><li id='pt-mycss'><a href='/User:Pcj/wowwiki.css'>css</a></li><li id='pt-myjs'><a href='/User:Pcj/JS'>js</a></li><li id='pt-projects'><a href='/User:Pcj/Projects'>projects</a></li><li id='pt-preferences'><a href='/Special:Preferences'>preferences</a></li><li id='pt-logout'><a href='/Special:Userlogout'>Log out</a></li></ul></div>");
}
/*
</pre>
{{anchor|navigation|changes "navigation" links}}
<pre>
*/
function changeNavigation() {
$('#p-navigation').html("<h5>navigation</h5><div class='pBody'><ul><li id='n-mainpage'><a href='/'>Main Page</a></li><li id='n-recentchanges'><a href='/index.php?title=Special:RecentChanges&limit=100'>Recent changes</a></li><li id='n-forums'><a href='/WW:F'>Forums</a></li><li id='n-Search-WoWWiki'><a href='/Special:Wantedpages'>Wanted pages</a></li><li id='n-Tooltips'><a href='/MediaWiki:Tooltips.js'>Tooltips</a></li><li id='n-Violations'><a href='/WW:V'>Violations</a></li><li id='n-gstubs'><a href='/WW:GS?withJS=User:Pcj/gs.js'>Guild stubs</a></li><li id='n-New-Pages'><a href='/Special:NewPages'>New pages</a></li></ul></div>");
}
/*
</pre>
{{anchor|preview|previews submission, used in next function|1}}
<pre>
*/
function goToPreview() {
$("#wpPreview").click();
}
/*
</pre>
{{anchor|preview|bypasses Preview access key glitch|2}}
<pre>
*/
function fixPreview() {
if ($('#ca-edit.selected').html()) document.body.ondblclick = goToPreview;
}
/*
</pre>
{{anchor|addtotop|adds text to top of edit box}}
<pre>
*/
function addEditTextToTop(addtext, summary) {
if (summary.indexOf("Foxbot") != -1) {
if (wgPageName.indexOf('(') != -1) {
elinksID = prompt("Item ID", "")
if (elinksID) addtext += '\n\n{' + '{elinks-item|' + elinksID + '}' + '}';
}
}
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();
}
/*
</pre>
{{anchor|wikify|add wikify tab}}
<pre>
*/
function wikify() {
if ((wgCanonicalNamespace == "") && (wgAction == "edit")) {
addPortletLink('p-cactions', 'javascript:addEditTextToTop("{" + "{wikify}" + "}", "Wikify");', 'wikify', 'ca-wikify', 'Wikify', '');
}
}
function toggleSet(i) {
var Span = document.getElementById( "set-" + i );
var list = new Array();
list[0] = Span.parentNode.nextSibling;
list[1] = list[0].nextSibling;
list[2] = list[1].nextSibling;
for (var i = 0; i < 3; i++) {
if (hasClass(list[i], "setdesc")) {
if (list[i].style.display == "none") {
list[i].style.display = "block";
} else {
list[i].style.display = "none";
}
}
}
}
function elinksTitle() {
if (wgCanonicalNamespace == "") {
document.getElementById("bodyContent").style.position = "relative";
document.getElementById("bodyContent").style.top = "15px";
var h1s = document.getElementsByTagName( "h1" );
elinksDiv = document.createElement("div");
elinksDiv.setAttribute("id", "elinksDiv");
h1s[0].parentNode.insertBefore(elinksDiv, h1s[0].nextSibling);
newdiv = document.getElementById("elinksDiv");
sQuery = wgPageName.replace("Quest:", "");
newdiv.innerHTML += ' <small><a href="http://www.wowhead.com?search=' + sQuery + '" target="_blank">ω</a> <a href="http://thottbot.com/?s=' + sQuery + '" target="_blank">τ</a> <a href="http://wow.allakhazam.com/search.html?q=' + sQuery + '" target="_blank">α</a></small>';
}
}
function monaco() {
if (wgAction == "view") {
addPortletLink('p-cactions', 'http://www.wowwiki.com/index.php?title=' + wgPageName + '&useskin=monaco&usetheme=custom', 'monaco', 'ca-mb', 'View page in monaco', '');
}
}
function doRegex() {
reprompt = new RegExp(prompt("Regular expression:", ""), "g");
retext = prompt("Replacement text:", "");
if (reprompt && retext) {
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(reprompt, retext);
document.editform.wpDiff.click();
}
}
function regex() {
if (wgAction == "edit") {
addPortletLink('p-cactions', 'javascript:doRegex();', 'regex', 'ca-regex', 'Perform a regular expression replace on text', '');
}
}
loadedExtJS = {};
function loadExtJS( URL ) {
var scriptElem = document.createElement( 'script' );
scriptElem.setAttribute( 'src' , URL );
scriptElem.setAttribute( 'type' , 'text/javascript' );
document.getElementsByTagName( 'head' )[0].appendChild( scriptElem );
}
wowItem = new Array();
function doTooltip() {
tt = prompt("Item name or ID",wgTitle).replace(/ /g,"_");
if (tt) {
wowItem[tt] = {};
loadExtJS("http://www.warcraftjs.com/?i="+tt);
setTimeout('processTooltip("'+tt+'");',2000);
}
}
function processTooltip(tt) {
if (typeof(retrieveItem) == "function") retrieveItem();
if (wowItem[tt].error) {
alert ("Error:\n"+wowItem[tt].error);
} else {
if (wowItem[tt].name.replace(/ /g,"_") == tt || wowItem[tt].itemid == tt) {
document.getElementById("wpTextbox1").value = "{{Stub/Item}}\n<onlyinclude>{{{{{tpl|tooltip}}}\n|mode={{{mode|}}}\n|arg={{{arg|}}}\n";
for (property in wowItem[tt]) {
if (property != "null") document.getElementById("wpTextbox1").value += "|"+property.replace("_","-")+"="+eval('wowItem["'+tt+'"].'+property)+"\n";
}
document.getElementById("wpTextbox1").value += "}}</onlyinclude>\n==Source==\n...\n\n==External links==\n{{sub"+"st:el}}\n{{Elinks-item|"+wowItem[tt].itemid+"}}";
retrieveItem = 0;
} else {
setTimeout('processTooltip("'+tt+'");',2000);
}
}
}
function loadTooltip() {
if (wgAction == "edit") {
addPortletLink('p-cactions', 'javascript:doTooltip();', 'tooltip', 'ca-Tooltip', 'Import an item tooltip from Wowhead', '');
}
}
/* does everything */
function doStuff() {
if (cookieValue != siteNoticeID) dismissNotice();
changePersonal();
changeNavigation();
changeSearch();
fixPreview();
wikify();
elinksTitle();
monaco();
regex();
loadTooltip();
$("#wpLeaveRedirect").removeAttr("checked");
}
if (wgPageName == "User:Pcj/Random") tooltipsOn = false;
/* 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);
/*
</pre>
[[Category:User:Pcj]][[Category:User JS|Pcj]]
*/
