home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / Install / program files / Borland / BDS / 3.0 / Welcomepage / JS / xmlDoc.js < prev   
Encoding:
JavaScript  |  2004-10-22  |  3.5 KB  |  172 lines

  1. /*
  2.     BDS Welcome Page XML routines
  3.  
  4.     Copyright (c) 2004 Borland Software Corporation
  5.  
  6.     Co-written by Daniel Wischnewski.
  7.     Co-Admin of www.delphipraxis.net -- The German Delphi Community
  8.     Email: dwischnewski@gatenetwork.com
  9. */
  10.  
  11. var appPath = external.Application.ExeName;
  12. appPath = appPath.substr(0, appPath.lastIndexOf('\\') + 1);
  13.  
  14. function getItemValue(item, tag)
  15. {
  16.     var valueItem;
  17.     
  18.     if (item != null)
  19.     {
  20.         valueItem = item.selectSingleNode(tag);
  21.         if (valueItem != null)
  22.         {
  23.             return valueItem.text;
  24.         } else {
  25.             return "";
  26.         }
  27.     } else {
  28.         return "";
  29.     }
  30. }
  31.  
  32. function getDateItemValue(item, tag)
  33. {
  34.     var datevalue;
  35.     var utcdate;
  36.  
  37.     datevalue = getItemValue(item, tag);
  38.     if (datevalue != "")
  39.     {
  40.         utcdate = new Date(Date.parse(datevalue));
  41.         return utcdate.toLocaleString();
  42.     }
  43.     return datevalue;
  44. }
  45.  
  46. function getXmlDoc()
  47. {
  48.     var xmlDoc;
  49.     
  50.     xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  51.     xmlDoc.async = false;
  52.     return xmlDoc;
  53. }
  54.  
  55. function getXmlHttpDoc()
  56. {
  57.     var xmlDoc;
  58.  
  59.     xmlDoc = new ActiveXObject("Msxml2.ServerXMLHTTP.4.0");
  60.     if (clientUsesProxy && clientProxyString != "")
  61.     {
  62.         xmlDoc.setProxy(2, clientProxyString);
  63.     }
  64.     return xmlDoc;
  65. }
  66.  
  67. function loadXmlDoc(fileName)
  68. {
  69.     var xmlDoc;
  70.  
  71.     xmlDoc = getXmlDoc();
  72.     xmlDoc.load(fileName);
  73.     if (xmlDoc.parseError.errorCode != 0)
  74.     {
  75.         xmlDoc.loadXML('<rss version="2.0" />');
  76.     }
  77.     return xmlDoc;
  78. }
  79.  
  80. function loadLanguageStringsXml()
  81. {
  82.     var languageSettingsFile;
  83.  
  84.     languageSettingsFile = appPath + '..\\Welcomepage\\xml\\languageStrings.xml';
  85.     return loadXmlDoc(languageSettingsFile);
  86. }
  87.  
  88. function loadMenuBarXml()
  89. {
  90.     var menuBarFile;
  91.  
  92.     menuBarFile = appPath + '..\\Welcomepage\\xml\\menuBar.xml';
  93.     return loadXmlDoc(menuBarFile);
  94. }
  95.  
  96. function loadDBWebDemosMenuBarXml()
  97. {
  98.     var menuBarFile;
  99.     loadLanguageStrings();
  100.     menuBarFile = appPath + '..\\demos\\delphi.net\\dbweb\\menuBar.xml';
  101.     return loadXmlDoc(menuBarFile);
  102. }
  103.  
  104. function loadDefaultProviders()
  105. {
  106.     var providersFile;
  107.     
  108.     providersFile = appPath + '..\\Welcomepage\\xml\\defaultProviders.xml';
  109.     return loadXmlDoc(providersFile);
  110. }
  111.  
  112. function loadPersonalSettings()
  113. {
  114.     var settingsFile;
  115.     
  116.     settingsFile = clientAppDataFolder + '\\welcomePageSettings.xml';
  117.     return loadXmlDoc(settingsFile);
  118. }
  119.  
  120. function savePersonalSettings(xmlPersonal)
  121. {
  122.     var settingsFile;
  123.  
  124.     settingsFile = clientAppDataFolder + '\\welcomePageSettings.xml';
  125.     xmlPersonal.save(settingsFile);
  126. }
  127.  
  128. function getSubNode(xmlNode, nodeName)
  129. {
  130.     var subNode;
  131.  
  132.     subNode = xmlNode.selectSingleNode(nodeName);
  133.     if (subNode == null)
  134.   {
  135.         subNode = xmlNode.appendChild(xmlNode.ownerDocument.createNode(1, nodeName, ""));
  136.     }
  137.     return subNode;
  138. }
  139.  
  140. function getSubNodeEx(xmlNode, nodeName, attrName, attrValue)
  141. {
  142.     var subNode;
  143.   var attr;
  144.   var XSL;
  145.  
  146.   XSL = nodeName + "[@" + attrName + '="' + attrValue + '"]';
  147.     subNode = xmlNode.selectSingleNode(XSL);
  148.     if (subNode == null)
  149.   {
  150.         subNode = xmlNode.appendChild(xmlNode.ownerDocument.createNode(1, nodeName, ""));
  151.     attr = xmlNode.ownerDocument.createNode(2, attrName, "");
  152.     attr.text = attrValue;
  153.     subNode.attributes.setNamedItem(attr);
  154.     }
  155.     return subNode;
  156. }
  157.  
  158. function setAttrValue(xmlNode, attrName, attrValue)
  159. {
  160.   var attr;
  161.  
  162.   attr = xmlNode.ownerDocument.createNode(2, attrName, "");
  163.   attr.text = attrValue;
  164.   xmlNode.attributes.setNamedItem(attr);
  165. }
  166.  
  167. function getSettingsNode(xmlDoc)
  168. {
  169.     return getSubNode(xmlDoc.documentElement, "settings");
  170. }
  171.  
  172.