User:Jgjake2/global.js

/*********************************************** * Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code ***********************************************/ var bustcachevar = 1 //bust potential caching of external pages after initial request? (1=yes, 0=no) var loadedobjects = "" var rootdomain = "http://http://elderscrolls.wikia.com/index.php?title=" var urlsuffex = "&action=render"; var bustcacheparameter = ""; var ajaxContainerId = "ajaxContentArea"; //http://http://elderscrolls.wikia.com/index.php?title=

function ajaxpage(url, containerid) { var newurl = rootdomain + url.replace('\.2F','/').replace('\.27','\'').replace('\.28','(').replace('\.29',')') + urlsuffex; var page_request = false if (window.XMLHttpRequest) // if Mozilla, Safari etc page_request = new XMLHttpRequest else if (window.ActiveXObject) { // if IE       try { page_request = new ActiveXObject("Msxml2.XMLHTTP") } catch (e) { try { page_request = new ActiveXObject("Microsoft.XMLHTTP") } catch (e) {} }   } else return false page_request.onreadystatechange = function { loadpage(page_request, containerid) }   if (bustcachevar) //if bust caching of external page bustcacheparameter = (newurl.indexOf("?") != -1) ? "&" + new Date.getTime : "?" + new Date.getTime page_request.open('GET', newurl + bustcacheparameter, true) page_request.send(null) }

function addAjaxLinks{ var ajaxDivs = getElementsByClass2(document, 'div', 'ajaxLink'); for (x in ajaxDivs){ var ajaxDiv_Link = ajaxDivs[x].getElementsByTagName('a')[0]; var tURL = ajaxDivs[x].id; //ajaxDiv_Link.setAttribute('title', ''); ajaxDiv_Link.setAttribute('href', "javascript:ajaxpage('" + tURL + "', '" + ajaxContainerId + "');"); } } addOnloadHook(addAjaxLinks);

function getElementsByClass2(elementName, tagname, tclass){ var itemsfound = new Array; var elements = elementName.getElementsByTagName(tagname); for(var i=0;i<elements.length;i++){ if(hasClass(elements[i], tclass)){ itemsfound.push(elements[i]); }   }    return itemsfound; }

function loadpage(page_request, containerid) { if (page_request.readyState == 4 && (page_request.status == 200 || window.location.href.indexOf("http") == -1)) document.getElementById(containerid).innerHTML = page_request.responseText }