Files
Bachelor-Thesis/PCSurvey/PCstatic/js/external/tracklib.min.js
Andreas Wilms 78481ca337 init
python
2025-09-09 19:40:44 +02:00

2 lines
5.4 KiB
JavaScript

/*! evtrack -- Lib module */
;var TrackLib=window.TrackLib||{};TrackLib.XPath={queryXPath:function(a,b){var c;if(typeof a.evaluate==="function"){c=a.evaluate(b,a.documentElement,null,XPathResult.ANY_TYPE,null)}else{try{a.setProperty("SelectionLanguage","XPath");c=a.selectNodes(b)}catch(d){c=false}}return c},getXPathNodes:function(b,c){var d=this.queryXPath(b,c);var a=[];var e=d.iterateNext();while(e){a.push(e);e=d.iterateNext()}return a},getXPath:function(h,j){var g=(h.ownerDocument instanceof HTMLDocument),d=this.getNodePath(h,j),e=[];for(var f in d){var c=d[f],a;if(c.nodeType==1){if(f==0&&!j&&c.hasAttribute("id")){e.push("/*[@id='"+c.getAttribute("id")+"']")}else{var b=c.tagName;if(g){b=b.toLowerCase()}a=this.getNodeIndex(c);if(a!=null){e.push(b+"["+a+"]")}else{e.push(b)}}}else{if(c.nodeType==3){a=this.getTextNodeIndex(c);if(a!=null){e.push("text()["+a+"]")}else{e.push("text()")}}}}return"/"+e.join("/")},getNodeIndex:function(b){if(b.nodeType!=1||b.parentNode==null){return null}var c=this.getChildNodesWithTagName(b.parentNode,b.tagName);if(c.length==1&&c[0]==b){return null}for(var a=0;a<c.length;a++){if(c[a]==b){return a+1}}throw new Error("couldn't find node in parent's list: "+b.tagName)},getTextNodeIndex:function(b){var c=this.getChildTextNodes(b.parentNode);if(c.length==1&&c[0]==b){return null}for(var a=0;a<c.length;a++){if(c[a]==b){return a+1}}throw new Error("couldn't find node in parent's list: "+b.tagName)},getChildNodesWithTagName:function(c,b){var a=[],d=c.firstChild;while(d!=null){if(d.tagName&&d.tagName==b){a.push(d)}d=d.nextSibling}return a},getChildTextNodes:function(b){var a=[],c=b.firstChild;while(c!=null){if(c.nodeType==3){a.push(c)}c=c.nextSibling}return a},getNodePath:function(b,c){var a=[];while(b.nodeType==1||b.nodeType==3){a.unshift(b);if(b.nodeType==1&&b.hasAttribute("id")&&!c){return a}b=b.parentNode}return a},getNodeValues:function(b){var a=[];for(var c in b){a.push(b[c].nodeValue)}return a}};TrackLib.XHR={createXMLHTTPObject:function(){var b=false;var c=[function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}];for(var a=0;a<c.length;++a){try{b=c[a]()}catch(d){continue}break}return b},sendAjaxRequest:function(a){var d=a.xmlhttp?a.xmlhttp:this.createXMLHTTPObject();var e=!TrackLib.Util.sameDomain(window.location.href,a.url);if(e&&window.XDomainRequest){d=new XDomainRequest()}if(!d){return false}var f=a.postdata?"POST":"GET";var b=a.hasOwnProperty("async")?a.async:true;d.open(f,a.url,b);var c=window.XDomainRequest&&(d instanceof XDomainRequest);if(a.postdata&&!c){d.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}if(c){d.onload=function(){if(typeof a.callback==="function"){a.callback(d)}}}else{d.onreadystatechange=function(){if(d.readyState==4&&typeof a.callback==="function"){a.callback(d)}}}d.send(a.postdata)}};TrackLib.Events={add:function(c,b,a){if(!c){return false}if(c.addEventListener){c.addEventListener(b,a,false)}else{if(c.attachEvent){c.attachEvent("on"+b,a)}else{c[b+a]=function(){a(window.event)}}}},remove:function(c,b,a){if(!c){return false}if(c.removeEventListener){c.removeEventListener(b,a,false)}else{if(c.detachEvent){c.detachEvent("on"+b,a)}else{c[b+a]=null}}},fix:function(a){a=a||window.event;if(!a.target){a.target=a.srcElement||document}if(a.target.nodeType==3){a.target=a.target.parentNode}if(typeof a.metaKey==="undefined"){a.metaKey=a.ctrlKey}a.id=a.identifier||0;return a},domReady:function(c){if(document.addEventListener){document.addEventListener("DOMContentLoaded",c,false)}else{if(document.attachEvent){try{document.write("<script id=__ie_onload defer=true src=//:><\/script>");var a=document.getElementById("__ie_onload");a.onreadystatechange=function(){if(this.readyState==="complete"){c()}}}catch(b){}}else{TrackLib.Events.add(window,"load",c)}}}};TrackLib.Dimension={getWindowSize:function(){var c=document;var a=(window.innerWidth)?window.innerWidth:(c.documentElement&&c.documentElement.clientWidth)?c.documentElement.clientWidth:(c.body&&c.body.clientWidth)?c.body.clientWidth:0;var b=(window.innerHeight)?window.innerHeight:(c.documentElement&&c.documentElement.clientHeight)?c.documentElement.clientHeight:(c.body&&c.body.clientHeight)?c.body.clientHeight:0;return{width:a,height:b}},getDocumentSize:function(){var c=document;var a=(window.innerWidth&&window.scrollMaxX)?window.innerWidth+window.scrollMaxX:(c.body&&c.body.scrollWidth>c.body.offsetWidth)?c.body.scrollWidth:(c.body&&c.body.offsetWidth)?c.body.offsetWidth:0;var b=(window.innerHeight&&window.scrollMaxY)?window.innerHeight+window.scrollMaxY:(c.body&&c.body.scrollHeight>c.body.offsetHeight)?c.body.scrollHeight:(c.body&&c.body.offsetHeight)?c.body.offsetHeight:0;return{width:a,height:b}},getPageSize:function(){var d=this.getWindowSize(),c=this.getDocumentSize();var a=(c.width<d.width)?d.width:c.width;var b=(c.height<d.height)?d.height:c.height;return{width:a,height:b}}};TrackLib.Util={sameDomain:function(){var d,b=true;for(var c=0,a=arguments.length;c<a;++c){if(c>0){b=(this.getDomain(d)==this.getDomain(arguments[c]))}d=arguments[c]}return b},getDomain:function(a){var c,b=document.createElement("a");b.href=a;c=b.hostname;b=null;return c},serializeAttrs:function(c){var e={};if(c&&c.attributes){e[c.nodeName]={};for(var b=0,a=c.attributes.length;b<a;b++){var d=c.attributes[b];if(d.specified){e[c.nodeName][d.name]=d.value}}}return JSON.stringify(e)}};