User:Toranosuke/questtooltip.js

// from http://www.wowwiki.com/User:Pcj/questtooltip.js /*

function parseQuestText { //Check to see if the XmlHttpRequests state is finished. if (getRequest.readyState == 4) { rawText = getRequest.responseText; var tip = document.getElementById('tfb'); tip.innerHTML = ttError("quest"); if (rawText) { rawName = ""; rawIcon = ""; rawStart = ""; rawEnd = ""; rawLevel = ""; rawXP = ""; rawRewards = ""; rawText = rawText.replace(crlf, ""); nameHTML = new RegExp(']*class="questname">.*? '); rawNameM = nameHTML.exec(rawText); if (rawNameM) { reName = new RegExp('.*]*class="questname">(.*?) .*'); rawName = rawNameM[0].replace(reName, "$1"); } iconHTML = new RegExp(']*class="questicon">.*? '); rawIconM = iconHTML.exec(rawText); if (rawIconM) { reIcon = new RegExp('.*]*class="questicon">(.*?) .*'); rawIcon = ' ' + rawIconM[0].replace(reIcon, "$1") + ' '; } startHTML = new RegExp(' .*? '); rawStartM = startHTML.exec(rawText); if (rawStartM) { reStart = new RegExp('.* (.*?) .*'); rawStart = "  " + rawStartM[0].replace(reStart, "$1"); } endHTML = new RegExp(' .*? '); rawEndM = endHTML.exec(rawText); if (rawEndM) { reEnd = new RegExp('.* (.*?) .*'); rawEnd = "  " + rawEndM[0].replace(reEnd, "$1"); } levelHTML = new RegExp(' .*? '); rawLevelM = levelHTML.exec(rawText); if (rawLevelM) { reLevel = new RegExp('.* (.*?) .*'); rawLevel = " Level: " + rawLevelM[0].replace(reLevel, "$1"); } xpHTML = new RegExp(' .*? '); rawXPM = xpHTML.exec(rawText); if (rawXPM) { reXP = new RegExp('.* (.*?) .*'); rawXP = " XP: " + rawXPM[0].replace(reXP, "$1"); } rewardsHTML = new RegExp(' .*? '); rawRewardsM = rewardsHTML.exec(rawText); if (rawRewardsM) { reRewards = new RegExp('.* (.*?) .*'); rawRewards = " Rewards: " + rawRewardsM[0].replace(reRewards, "$1"); } tooltip = rawIcon + rawName + rawLevel + rawStart + rawEnd + rawXP + rawRewards; if (tooltip != null && tooltip != "") { tip.innerHTML = ttHTMLStart + ' ' + tooltip + ' '; } } displayTip; } }

function showQuestTip(i) { if (tooltipsOn) { var Span = document.getElementById( "qtt" + i ); var ttLink = Span.parentNode; if (ttLink.getAttribute("class") != "selflink") { Span.setAttribute("title", ""); if (ttLink.getAttribute("title")) { questname = ttLink.getAttribute("title"); ttLink.setAttribute("title", ""); newSpan = document.createElement("span"); newSpan.setAttribute("title", questname); ttLink.appendChild(newSpan); } else { questname = ttLink.lastChild.getAttribute("title"); } getInfo(questname, 4); } } }

function qttMouseOver { var Spans = document.getElementsByTagName( "span" ); for ( var i = 0; i < Spans.length; i++ ) { if ( hasClass( Spans[i], "questlink" ) ) { Spans[i].setAttribute("id", "qtt" + i); Spans[i].onmouseover = showQuestTip.bind(Spans[i],i); Spans[i].onmouseout = hideTip.bind(Spans[i],i); Spans[i].onmousemove = moveTip; } } }

qttMouseOver;

/*