User talk:Eleazaros/npctooltip.js
Jump to navigation
Jump to search
saving off the old code for rewrite testing... // from http://www.wowwiki.com/User:Pcj/npctooltip.js /*
*/ function parseNPCText() { //Check to see if the XmlHttpRequests state is finished. if (getRequest.readyState == 4) { rawText = getRequest.responseText; var tip = document.getElementById('tfb'); tip.innerHTML = ttError("NPC"); if (rawText) { rawName = ""; rawIcon = ""; rawPicture = ""; rawTitle = ""; rawLevel = ""; rawLoc = ""; rawText = rawText.replace(crlf, ""); nameHTML = new RegExp('<div class="npcname">.*?</div>'); rawNameM = nameHTML.exec(rawText); if (rawNameM) { reName = new RegExp('.*<div class="npcname">(.*?)</div>.*'); rawName = rawNameM[0].replace(reName, "$1"); } iconHTML = new RegExp('<div class="npcicon">.*?</div>'); rawIconM = iconHTML.exec(rawText); if (rawIconM) { reIcon = new RegExp('.*<div class="npcicon">(.*?)</div>.*'); rawIcon = '<div style="float:left;">' + rawIconM[0].replace(reIcon, "$1") + '</div>'; } pictureHTML = new RegExp('<div[^>]*?class="npcpic">.*?</div>'); rawPictureM = pictureHTML.exec(rawText); if (rawPictureM) { rePicture = new RegExp('.*<div[^>]*?class="npcpic">.*?<img[^>]*src="(.*?)".*?</div>.*'); rawPicture = '<img src="' + rawPictureM[0].replace(rePicture, "$1") + '" alt="' + rawName + '" height="300"></div><div align="center">'; } titleHTML = new RegExp('<div class="npctitle">.*?</div>'); rawTitleM = titleHTML.exec(rawText); if (rawTitleM) { reTitle = new RegExp('.*<div class="npctitle">(.*?)</div>.*'); rawTitle = "<br />" + rawTitleM[0].replace(reTitle, "$1"); } levelHTML = new RegExp('<div class="npclevel">.*?</div>'); rawLevelM = levelHTML.exec(rawText); if (rawLevelM) { reLevel = new RegExp('.*<div class="npclevel">(.*?)</div>.*'); rawLevel = '<br />Level: ' + rawLevelM[0].replace(reLevel, "$1"); } locHTML = new RegExp('<div class="npcloc">.*?</div>'); rawLocM = locHTML.exec(rawText); if (rawLocM) { reLoc = new RegExp('.*<div class="npcloc">(.*?)</div>.*'); rawLoc = "<br />" + rawLocM[0].replace(reLoc, "$1"); } tooltip = rawPicture + rawIcon + rawName + rawTitle + rawLevel + rawLoc; if (tooltip != null && tooltip != "") { tip.innerHTML = ttHTMLStart + '<div align="center">' + tooltip + '</div>'; } } displayTip(); } } function showNPCTip(i) { if (tooltipsOn) { var Span = document.getElementById( "npctt" + i ); var ttLink = Span.parentNode; if (ttLink.getAttribute("class") != "selflink") { Span.setAttribute("title", ""); if (ttLink.getAttribute("title")) { npcname = ttLink.getAttribute("title"); ttLink.setAttribute("title", ""); newSpan = document.createElement("span"); newSpan.setAttribute("title", npcname); ttLink.appendChild(newSpan); } else { npcname = ttLink.lastChild.getAttribute("title"); } getInfo(npcname, 5); } } } function nttMouseOver() { var Spans = document.getElementsByTagName( "span" ); for ( var i = 0; i < Spans.length; i++ ) { if ( hasClass( Spans[i], "npclink" ) ) { Spans[i].setAttribute("id", "npctt" + i); Spans[i].onmouseover = showNPCTip.bind(Spans[i],i); Spans[i].onmouseout = hideTip.bind(Spans[i],i); Spans[i].onmousemove = moveTip; } } } nttMouseOver(); /*
- /