ConfigManager.min.js 1.6 KB

1
  1. function ConfigManger(configPath){var m_configPath="";var m_xmlDoc=null;if(configPath!=null&&configPath!="")m_configPath=configPath;else m_configPath="config_local.xml";if(m_configPath==null||m_configPath=="")return null;var xmlHelper=new XmlHelper;var m_xmlDoc=xmlHelper.loadFileXml(m_configPath);if(m_xmlDoc==null)return null;this.GetConfigValue=function(keyName){if(m_xmlDoc==null)return null;var data=m_xmlDoc.getElementsByTagName(keyName);var xmlHelper=new XmlHelper;var value=xmlHelper.getNodeValue(data[0]);return value}}var xmlUtil;var xmlDoc;function GetConfigData(){xmlUtil=new XMLUtil;xmlDoc=xmlUtil.loadXmlFromFile(getRootPath_dc()+"/config/config_local.xml")}function GetConfigValueByTagName(tagName){if(isEmptyValue(xmlUtil))GetConfigData();var configNode=xmlDoc.getElementsByTagName(tagName);var stringUrl=xmlUtil.getNodeValue(configNode[0]);return stringUrl}function getRootPath_web(){var curWwwPath=window.document.location.href;var pathName=window.document.location.pathname;var pos=curWwwPath.indexOf(pathName);var localhostPaht=curWwwPath.substring(0,pos);var projectName=pathName.substring(0,pathName.substr(1).indexOf("/")+1);return localhostPaht+projectName}function getRootPath_dc(){var pathName=window.location.pathname.substring(1);var webName=pathName==""?"":pathName.substring(0,pathName.indexOf("/"));if(webName==""){return window.location.protocol+"//"+window.location.host}else{return window.location.protocol+"//"+window.location.host+"/"+webName}}function GetConfigDataByName(nodeName){var nodeXml=xmlDoc.getElementsByTagName(nodeName);var nodeValue=xmlUtil.getNodeValue(nodeXml[0]);return nodeValue}