home *** CD-ROM | disk | FTP | other *** search
/ Mundo do CD-ROM 118 / cdrom118.iso / internet / webaroo / WebarooSetup.exe / Webaroo.msi / _C764F55961624CB89F8E21EC12A3BDEC < prev    next >
Encoding:
Text File  |  2006-03-20  |  5.4 KB  |  241 lines

  1. ∩╗┐// i18n - issue
  2. // Error Message
  3. var xml_get_problem="Problem retrieving Data from the Server";
  4. var xml_set_problem="Problem updating Data on the Server";
  5. var dummy_data = "dummy=dummy";
  6. // Global Variables to read the XML response files from server
  7. // The XML Object used for the Request
  8. var xmlDoc;
  9. // The XML Content
  10. var xmlContent;
  11.  
  12. //Function that downloads the XML Data. Uses POST to avoid caching.
  13. function processXMLData(url)
  14. {
  15.     // code for Mozilla, etc.
  16.     if (window.XMLHttpRequest)
  17.     {
  18.         xmlDoc=new XMLHttpRequest()
  19.         //Need this if this is to be done asynchronously
  20.         //xmlDoc.onreadystatechange=loadXMLData;
  21.         xmlDoc.open("POST",url,false)
  22.         xmlDoc.send("dummy")
  23.         loadXMLData();
  24.     }
  25.     // code for IE
  26.     else if (window.ActiveXObject)
  27.     {
  28.         xmlDoc=new ActiveXObject("Microsoft.XMLHTTP")
  29.         if (xmlDoc)
  30.         {
  31.             //Need this if this is to be done asynchronously
  32.             //xmlDoc.onreadystatechange=loadXMLData;
  33.             xmlDoc.open("POST",url,false)
  34.             xmlDoc.send("dummy")
  35.             loadXMLData();
  36.         }
  37.     }
  38. }
  39.  
  40. //Function that Loads the XML Data
  41. function loadXMLData()
  42. {
  43.     // Once Data is Downloaded...
  44.     if (xmlDoc.readyState==4)
  45.     {
  46.     // if "OK"
  47.         if (xmlDoc.status==200)
  48.         {
  49.             xmlContent = xmlDoc.responseXML;
  50.         }
  51.         else
  52.         {
  53.             alert(xml_get_problem)
  54.         }
  55.     }
  56. }
  57.  
  58. //Function that Sends the XML Data to the Server
  59. function sendXMLData(url, data)
  60. {
  61.     // code for Mozilla, etc.
  62.     if (window.XMLHttpRequest)
  63.     {
  64.         xmlDoc=new XMLHttpRequest()
  65.         //Need this if this is to be done asynchronously
  66.         //xmlDoc.onreadystatechange=loadXMLData;
  67.         xmlDoc.open("POST",url,false)
  68.         xmlDoc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  69.         xmlDoc.send((data != "") ? data : dummy_data)
  70.         loadXMLData();
  71.     }
  72.     // code for IE
  73.     else if (window.ActiveXObject)
  74.     {
  75.         xmlDoc=new ActiveXObject("Microsoft.XMLHTTP")
  76.         if (xmlDoc)
  77.         {
  78.             //Need this if this is to be done asynchronously
  79.             //xmlDoc.onreadystatechange=loadXMLData;
  80.             xmlDoc.open("POST",url,false)
  81.             xmlDoc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  82.             xmlDoc.send((data != "") ? data : dummy_data)
  83.             loadXMLData();
  84.         }
  85.     }
  86. }
  87.  
  88. //Function that downloads the XML Data
  89. function processXMLDataUsingGet()
  90. {
  91.     // code for Mozilla, etc.
  92.     if (window.XMLHttpRequest)
  93.     {
  94.         xmlDoc=new XMLHttpRequest()
  95.         //Need this if this is to be done asynchronously
  96.         //xmlDoc.onreadystatechange=loadXMLData;
  97.         xmlDoc.open("GET",url,false)
  98.         xmlDoc.send(null)
  99.         loadXMLData();
  100.     }
  101.     // code for IE
  102.     else if (window.ActiveXObject)
  103.     {
  104.         xmlDoc=new ActiveXObject("Microsoft.XMLHTTP")
  105.         if (xmlDoc)
  106.         {
  107.             //Need this if this is to be done asynchronously
  108.             //xmlDoc.onreadystatechange=loadXMLData;
  109.             xmlDoc.open("GET",url,false)
  110.             xmlDoc.send()
  111.             loadXMLData();
  112.         }
  113.     }
  114. }
  115.  
  116. function SendAsynchornousRequest(url, postData, callback, info)
  117. {
  118.     var asyncDoc;
  119.     var data = info;
  120.     
  121.     // inner function.
  122.     function CheckDataArrived()
  123.     {
  124.         // Once Data is Downloaded...
  125.         if (asyncDoc.readyState==4)
  126.         {
  127.         // if "OK"
  128.             if (asyncDoc.status==200)
  129.             {
  130.                 callback(asyncDoc.responseXML, data);
  131.             }
  132.         }
  133.     }
  134.     
  135.     // code for Mozilla, etc.
  136.     if (window.XMLHttpRequest)
  137.     {
  138.         asyncDoc=new XMLHttpRequest();
  139.         //Need this if this is to be done asynchronously
  140.         asyncDoc.onreadystatechange=CheckDataArrived;
  141.         asyncDoc.open("POST",url,true);
  142.         asyncDoc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  143.         asyncDoc.send((postData != "") ? postData : dummy_data)
  144.     }
  145.     // code for IE
  146.     else if (window.ActiveXObject)
  147.     {
  148.         asyncDoc=new ActiveXObject("Microsoft.XMLHTTP");
  149.         if(asyncDoc)
  150.         {
  151.             //Need this if this is to be done asynchronously
  152.             asyncDoc.onreadystatechange=CheckDataArrived;
  153.             asyncDoc.open("POST",url,true);
  154.             asyncDoc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  155.             asyncDoc.send((postData != "") ? postData : dummy_data)
  156.         }
  157.     }
  158.     
  159.     return asyncDoc;
  160. }
  161.  
  162. function SendSynchornousRequest(url, callback, info)
  163. {
  164.     var syncDoc;
  165.     var data = info;
  166.     
  167.     // code for Mozilla, etc.
  168.     if (window.XMLHttpRequest)
  169.     {
  170.         syncDoc=new XMLHttpRequest();
  171.         syncDoc.open("POST",url,false);
  172.         syncDoc.send("dummy");
  173.     }
  174.     // code for IE
  175.     else if (window.ActiveXObject)
  176.     {
  177.         syncDoc=new ActiveXObject("Microsoft.XMLHTTP");
  178.         if(syncDoc)
  179.         {
  180.             syncDoc.open("POST",url,false);
  181.             syncDoc.send("dummy");
  182.         }
  183.     }
  184.     if (syncDoc.readyState==4)
  185.     {
  186.     // if "OK"
  187.         if (syncDoc.status==200)
  188.         {
  189.             callback(syncDoc.responseXML, data);
  190.         }
  191.         else
  192.         {
  193.             alert(xml_get_problem)
  194.         }
  195.     }
  196. }
  197.  
  198.  
  199. /*  OLD FUNCTIONs:
  200. function sendXMLDataUsingGet()
  201. {
  202.     // code for Mozilla, etc.
  203.     if (window.XMLHttpRequest)
  204.     {
  205.         xmlDoc=new XMLHttpRequest()
  206.         //Need this if this is to be done asynchronously
  207.         //xmlDoc.onreadystatechange=checkXMLDataLoaded;
  208.         xmlDoc.open("GET",url,false)
  209.         xmlDoc.send(null)
  210.         checkXMLDataLoaded();
  211.     }
  212.     // code for IE
  213.     else if (window.ActiveXObject)
  214.     {
  215.         xmlDoc=new ActiveXObject("Microsoft.XMLHTTP")
  216.         if (xmlDoc)
  217.         {
  218.             //Need this if this is to be done asynchronously
  219.             //xmlDoc.onreadystatechange=checkXMLDataLoaded;
  220.             xmlDoc.open("GET",url,false)
  221.             xmlDoc.send()
  222.             checkXMLDataLoaded();
  223.         }
  224.     }
  225. }
  226.  
  227. //Check the uploaded XML
  228. function checkXMLDataLoaded()
  229. {
  230.     // Once Data is Downloaded...
  231.     if (xmlDoc.readyState==4)
  232.     {
  233.     // if "OK"
  234.         if (xmlDoc.status!=200)
  235.         {
  236.             alert(xml_set_problem)
  237.         }
  238.     }
  239. }
  240. */
  241.