You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
8.3 KiB
JavaScript

!function(){var e={prefix:"jugl",namespaceURI:null,loadTemplate:function(e){o(e.url,(function(t){var n,o;if(!t.status||t.status>=200&&t.status<300){try{n=t.responseXML,o=new r(n.documentElement)}catch(e){(n=document.createElement("div")).innerHTML=t.responseText,o=new r(n.firstChild)}e.callback&&e.callback.call(e.scope,o)}else e.failure&&e.failure.call(e.scope,t)}))}},t=function(e,t){for(var n in e=e||{},t=t||{})e[n]=t[n];return e},n=function(e,t){var n,o,i,r,s;if("string"==typeof e){if(!(n=document.getElementById(e)))throw Error("Element id not found: "+e);e=n}if("string"==typeof t){if(!(n=document.getElementById(t)))throw Error("Element id not found: "+t);t=n}if(t.namespaceURI&&t.xml)for((o=document.createElement("div")).innerHTML=t.xml,r=0,s=(i=o.childNodes).length;r<s;++r)e.appendChild(i[r]);else e.ownerDocument&&e.ownerDocument.importNode&&e.ownerDocument!==t.ownerDocument&&(t=e.ownerDocument.importNode(t,!0)),e.appendChild(t);return t},o=function(e,t,n){var o;if("undefined"!=typeof XMLHttpRequest)o=new XMLHttpRequest;else{if("undefined"==typeof ActiveXObject)throw new Error("XMLHttpRequest not supported");o=new ActiveXObject("Microsoft.XMLHTTP")}o.open("GET",e),o.onreadystatechange=function(){4===o.readyState&&t.call(n,o)},o.send(null)},i=function(e,t){this.template=e,this.node=t,this.scope={},this.scope.repeat={}};t(i.prototype,{clone:function(){var e=this.node.cloneNode(!0);e.removeAttribute("id");var n=new i(this.template,e);return t(n.scope,this.scope),n},getAttribute:function(t){var n;return 1===this.node.nodeType&&(n=this.template.usingNS?this.node.getAttributeNodeNS(e.namespaceURI,t):this.node.getAttributeNode(e.prefix+":"+t))&&!n.specified&&(n=!1),n?new s(this,n,t):n},setAttribute:function(e,t){this.node.setAttribute(e,t)},removeAttributeNode:function(e){this.node.removeAttributeNode(e.node)},getChildNodes:function(){for(var e,n=this.node.childNodes.length,o=new Array(n),r=0;r<n;++r)(e=new i(this.template,this.node.childNodes[r])).scope=t({},this.scope),o[r]=e;return o},removeChildNodes:function(){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.firstChild)},removeChild:function(e){return this.node.removeChild(e.node),node},removeSelf:function(){this.node.parentNode.removeChild(this.node)},importNode:function(e){this.node.ownerDocument&&this.node.ownerDocument.importNode&&e.node.ownerDocument!==this.node.ownerDocument&&(e.node=this.node.ownerDocument.importNode(e.node,!0))},appendChild:function(e){this.importNode(e),this.node.appendChild(e.node)},insertAfter:function(e){this.importNode(e);var t=this.node.parentNode,n=this.node.nextSibling;n?t.insertBefore(e.node,n):t.appendChild(e.node)},insertBefore:function(e){this.importNode(e),this.node.parentNode.insertBefore(e.node,this.node)},process:function(){for(var e,t=["define","condition","repeat"],n=0,o=t.length;n<o;++n)if((e=this.getAttribute(t[n]))&&!e.process())return;var i=this.getAttribute("content");if(i)i.process();else{var r=this.getAttribute("replace");r&&r.process()}var s=this.getAttribute("attributes");s&&s.process(),i||r||this.processChildNodes();var l=this.getAttribute("omit-tag");l&&l.process();var d=this.getAttribute("reflow");d&&d.process()},processChildNodes:function(){for(var e=this.getChildNodes(),t=0,n=e.length;t<n;++t)e[t].process()}});var r=function(e){if("string"!=typeof(e=e||{})&&1!==e.nodeType||(e={node:e}),"string"==typeof e.node&&(e.node=document.getElementById(e.node),!e.node))throw Error("Element id not found: "+e.node);e.node?(this.node=e.node,this.loaded=!0):e.url&&this.load({url:e.url,callback:e.callback,scope:e.scope})};t(r.prototype,{node:null,usingNS:!1,xmldom:window.ActiveXObject?new ActiveXObject("Microsoft.XMLDOM"):null,trimSpace:/^\s*(\w+)\s+(.*?)\s*$/,loaded:!1,loading:!1,process:function(o){var r,s;return o=t({context:null,clone:!1,string:!1},o),this.usingNS=this.node.getAttributeNodeNS&&e.namespaceURI,r=new i(this,this.node),(o.clone||o.string)&&(r=r.clone()),o.context&&(r.scope=o.context),r.process(),o.string?s=r.node.innerHTML?r.node.innerHTML:this.xmldom?r.node.xml:(new XMLSerializer).serializeToStri