// cms function cms(applyTo) { this.id = document.uniqueID; window[this.id] = this; // call by template this.applyTo = applyTo; this.apply = function (id) { if (id == null && this.applyTo != null) { id = this.applyTo; } else { this.applyTo = id; } var html = this.xmlDoc.documentElement.transformNode(this.xslDoc.documentElement); document.getElementById(id).innerHTML = html; }; this.applyByDoc = function (doc,id) { if (id == null && this.applyTo != null) { id = this.applyTo; } else { this.applyTo = id; } var html = doc.documentElement.transformNode(this.xslDoc.documentElement); document.getElementById(id).innerHTML = html; }; this.applyByElement = function (element,id) { if (id == null && this.applyTo != null) { id = this.applyTo; } else { this.applyTo = id; } var html = element.transformNode(this.xslDoc.documentElement); document.getElementById(id).innerHTML = html; }; this.trans = function (xmlText, xsltFile) { var text; if (typeof (window.ActiveXObject) != "undefined") { // is IE try { var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0"); var xslDoc = new ActiveXObject("Msxml2.DOMDocument.3.0"); xmlDoc.async = false; xslDoc.async = false; xmlDoc.load(xmlText); xslDoc.load(xsltFile); text = xmlDoc.documentElement.transformNode(xslDoc.documentElement); } catch (e) { alert(e.name + ": " + e.message); alert("Unable to do xml/xsl processing"); alert(e.name + ": " + e.message); } } else { if (document.implementation && document.implementation.createDocument) { // is Mozilla try { var oParser = new DOMParser(); var xmlDoc = oParser.parseFromString(xmlText, "text/xml"); xslDoc = document.implementation.createDocument("", "", null); xslDoc.async = false; xslDoc.load(xsltFile); var xsltProcessor = new XSLTProcessor(); xsltProcessor.importStylesheet(xslDoc); var result = xsltProcessor.transformToDocument(xmlDoc); var xmls = new XMLSerializer(); text = xmls.serializeToString(result); } catch (e) { if (isDebug) { alert(e.name + ": " + e.message); } alert("Unable to do xml/xsl processing"); } } } return text; }; this.createDocFromXml = function (xml) { var xmlDoc; if (typeof (window.ActiveXObject) != "undefined") { xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0"); xmlDoc.async = false; xmlDoc.loadXML(xml); } else { var oParser = new DOMParser(); xmlDoc = oParser.parseFromString(xml, "text/xml"); } return xmlDoc; }; this.createDoc = function (uri) { var xmlDoc; if (typeof (window.ActiveXObject) != "undefined") { xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0"); xmlDoc.async = false; xmlDoc.setProperty("ServerHTTPRequest", true); var ret = xmlDoc.load(uri); var xmlError = xmlDoc.parseError; if (ret == false && xmlError != null) { var error = xmlError.errorCode + " " + xmlError.reason + " " + uri; alert(error); } } return xmlDoc; }; this.setParam = function(name,value){ var node = this.xslDoc.selectSingleNode("xsl:stylesheet/xsl:param[@name='" + name + "']"); if (node != null) { node.text = value; } }; this.init = function() { }; this.dyniframesize = function(controlID) { var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1] //extra height in px to add to iframe in FireFox 1.0+ browsers var FFextraHeight=getFFVersion>=0.1? 16 : 0 var pTar = null; if (document.getElementById) { pTar = document.getElementById(controlID); } else { eval('pTar = ' + controlID + ';'); } if (pTar && !window.opera) { //begin resizing iframe //pTar.style.display="block" var h1=0, h2=0, h3=0; if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight)//如果用戶的瀏覽器是NetScape { //ns6 syntax h1 = pTar.contentDocument.body.offsetHeight+FFextraHeight; } else if(document.body) { h3=document.body.scrollHeight; } else if (pTar.Document && pTar.Document.body.scrollHeight)//如果用戶的瀏覽器是IE { //ie5+ syntax //alert(pTar.Document.body.scrollHeight) // pTar.height = pTar.Document.body.scrollHeight; h2=document.documentElement.scrollHeight; // pTar.height = screen.availHeight; // alert(pTar.height); } var h=Math.max(h1, h2); h=Math.max(h, h3); if(document.all) {h += 4;} if(window.opera) {h += 1;} pTar.height = h-132; //pTar.height = screen.availHeight-150; //alert(pTar.height); } }; } // tools function cms_tools() { cms.call(this); cms_tools.prototype = new cms(); this.xmlDoc = this.createDoc("https://first-aviva.com.tw:80/eventipa/resources/xml/tools/index.xml"); this.xmlDoc.setProperty("SelectionLanguage", "XPath"); this.xslDoc = this.createDoc("https://first-aviva.com.tw:80/eventipa/resources/xml/tools/index.xsl"); }