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

  1. function LoadPrefsPage()
  2. {    
  3.     MM_preloadImages('/webaroo/e29f1fe6/images/webaroo_search_f2.gif','/webaroo/e29f1fe6/images/webaroo_contents_f2.gif','/webaroo/e29f1fe6/images/webaroo_prefs_f2.gif','/webaroo/e29f1fe6/images/webaroo_help_f2.gif');
  4.     // following lines for rounded corners script
  5.     if(NiftyCheck())
  6.     {
  7.         Rounded("div#leftnav","all","#FFAA44","#FFFFFF","smooth");
  8.         Rounded("div#maincontent1","all","#FFAA44","#FFFFFF","smooth");
  9.         Rounded("div#maincontent2","all","#FFAA44","#FFFFFF","smooth");
  10.         Rounded("div#prefBannerStatusDiv","all","#FFAA44","#FF0000","smooth");
  11.     }
  12.     
  13.     // initialize the DHTML History framework
  14.     dhtmlHistory.initialize();   
  15.     // add ourselves as a DHTML History listener
  16.     dhtmlHistory.addListener(GetPrefsPage);
  17.     if (dhtmlHistory.isFirstLoad()) 
  18.     {
  19.         ShowPrefsPage(0,1);
  20.     }
  21.     
  22.     // check if we are being loaded after successful save
  23.     if(String(document.location).indexOf("saved=True")!=-1)
  24.     {
  25.         SetOperationStatus('prefBanner', "Your preferences have been saved.");
  26.     }
  27. }
  28.  
  29. //making these global so that we can use them while validation
  30. var proxyName, proxyPort, proxyUser, proxyPassword, launchWebaroo, startWebaroo, autoUpdate, mysiteautoUpdate, noProxyList;
  31.  
  32.  
  33. function GetCurrentSettingsFromServer()
  34. {
  35.     var url = "/webaroo/e29f1fe6/settings?request=get";
  36.     processXMLData(url);
  37.     var listObject = xmlContent.getElementsByTagName('Response');
  38.  
  39.     for (var j=0;j<listObject.length;j++)
  40.     {
  41.         if (listObject[j].nodeType != 1) continue;
  42.         
  43.         var currentNodeObject=listObject[j];
  44.         
  45.         for (k=0;k<currentNodeObject.childNodes.length;k++)
  46.         {
  47.             if (currentNodeObject.childNodes[k].nodeType != 1) continue;
  48.             switch(currentNodeObject.childNodes[k].nodeName)
  49.             {
  50.                 case 'ProxyName':
  51.                         if(currentNodeObject.childNodes[k].firstChild != null)
  52.                         proxyName=currentNodeObject.childNodes[k].firstChild.nodeValue;
  53.                     else
  54.                         proxyName="";    
  55.                     break;
  56.                 case 'ProxyPort':
  57.                     if(currentNodeObject.childNodes[k].firstChild != null)
  58.                         proxyPort=currentNodeObject.childNodes[k].firstChild.nodeValue;
  59.                     else
  60.                         proxyPort="";
  61.                     break;
  62.                 case 'NoProxyList':
  63.                     if(currentNodeObject.childNodes[k].firstChild != null)
  64.                         noProxyList=currentNodeObject.childNodes[k].firstChild.nodeValue;
  65.                     else
  66.                         noProxyList = "";
  67.                     break;
  68.                 case 'ProxyUser':
  69.                     if(currentNodeObject.childNodes[k].firstChild != null)
  70.                         proxyUser=currentNodeObject.childNodes[k].firstChild.nodeValue;
  71.                     else
  72.                         proxyUser="";
  73.                     break;
  74.                 case 'ProxyPassword':
  75.                     if(currentNodeObject.childNodes[k].firstChild != null)
  76.                         proxyPassword=currentNodeObject.childNodes[k].firstChild.nodeValue;
  77.                     else
  78.                         proxyPassword="";
  79.                     break;
  80.                 case 'LaunchWebaroo':
  81.                     if(currentNodeObject.childNodes[k].firstChild != null)
  82.                         launchWebaroo=currentNodeObject.childNodes[k].firstChild.nodeValue;
  83.                     else
  84.                         launchWebaroo = "false";    
  85.                     break;
  86.                 case 'StartWebaroo':
  87.                     if(currentNodeObject.childNodes[k].firstChild != null)
  88.                         startWebaroo=currentNodeObject.childNodes[k].firstChild.nodeValue;
  89.                     else
  90.                         startWebaroo="true";
  91.                     break;
  92.                 case 'AutoUpdate':
  93.                     if(currentNodeObject.childNodes[k].firstChild != null)
  94.                         autoUpdate=currentNodeObject.childNodes[k].firstChild.nodeValue;
  95.                     else
  96.                         autoUpdate="true";
  97.                     break;
  98.                 case 'MySitesAutoUpdate':
  99.                     if(currentNodeObject.childNodes[k].firstChild != null)
  100.                         mysiteautoUpdate=currentNodeObject.childNodes[k].firstChild.nodeValue;
  101.                     else
  102.                         mysiteautoUpdate="true";
  103.                     break;
  104.             }
  105.         }
  106.     }
  107.     
  108. }
  109. function ShowSettings()
  110. {
  111.     GetCurrentSettingsFromServer();
  112.     SetCurrentSettings();
  113. }
  114.  
  115.  
  116. function SetCurrentSettings()
  117. {
  118.     var prefForm = document.prefForm;
  119.     prefForm.proxyAddress.value = proxyName;
  120.     prefForm.proxyPort.value = (parseInt(proxyPort) != 0) ? proxyPort : "";
  121.     prefForm.proxyUser.value = proxyUser;
  122.     prefForm.proxyPassword.value = proxyPassword;
  123.     prefForm.startWebaroo.checked = (startWebaroo == "true");
  124.     var updateIndex = (autoUpdate== "true") ? 0 : 1;
  125.     prefForm.updateOption[updateIndex].checked = true;
  126.     prefForm.noProxyList.value = noProxyList;
  127.     
  128.     updateIndex = (mysiteautoUpdate == "true") ? 0 : 1;
  129.     prefForm.mysiteupdateOption[updateIndex].checked = true;
  130.     
  131. }
  132.  
  133. function UserChangedAnySetting()
  134. {
  135.     GetCurrentSettingsFromServer();
  136.     var prefForm = document.prefForm;
  137.     if ( prefForm.proxyAddress.value != proxyName ) return true;
  138.     if ( prefForm.proxyPort.value != ((parseInt(proxyPort) != 0) ? proxyPort : "") ) return true;
  139.     if ( prefForm.proxyUser.value != proxyUser ) return true;
  140.     if ( prefForm.proxyPassword.value != proxyPassword ) return true;
  141.     if ( prefForm.startWebaroo.checked != (startWebaroo == "true") ) return true;
  142.     var updateIndex = (autoUpdate== "true") ? 0 : 1;
  143.     if ( prefForm.updateOption[updateIndex].checked != true ) return true;
  144.     if ( prefForm.noProxyList.value != noProxyList ) return true;
  145.     updateIndex = (mysiteautoUpdate == "true") ? 0 : 1;
  146.     if ( prefForm.mysiteupdateOption[updateIndex].checked != true ) return true;
  147.     return false;
  148. }
  149.  
  150. // returns empty string if no errors, else a string containing error message to be displayed to user
  151. function ValidatePreferences() 
  152. {
  153.     var prefForm = document.prefForm;
  154.     var sPort = trim(prefForm.proxyPort.value);
  155.     var sServerName = trim(prefForm.proxyAddress.value);
  156.     sServerName = sServerName.replace(":\\\\","://");
  157.     prefForm.proxyAddress.value = sServerName;
  158.     var username = trim(prefForm.proxyUser.value);
  159.     var password = prefForm.proxyPassword.value;
  160.     var noProxyFor = prefForm.noProxyList.value;
  161.     var has_errors = false;
  162.     // clear all errors
  163.     document.getElementById("proxyAddressError").innerHTML = "";
  164.     document.getElementById("proxyPortError").innerHTML = "";
  165.     document.getElementById("noProxyListError").innerHTML = "";
  166.     document.getElementById("proxyUserError").innerHTML = "";
  167.     document.getElementById("proxyPasswordError").innerHTML = "";
  168.  
  169.     if ( sServerName != "" && sServerName.indexOf("http://") == -1) 
  170.     {
  171.         prefForm.proxyAddress.value = "http://" + prefForm.proxyAddress.value;
  172.         sServerName = "http://" + sServerName;
  173.     }
  174.     // first see if there is any change at all
  175.     if ( !UserChangedAnySetting() ) return "Nothing to save.";
  176.     // see if server is given
  177.     if(sServerName != "")
  178.     {
  179.         // port must be valid
  180.         if (!IsNumeric(sPort))
  181.         {
  182.             document.getElementById("proxyPortError").innerHTML = "Required.";
  183.             has_errors = true;
  184.         }
  185.     }
  186.     if ( sPort != "" )
  187.     {
  188.         if( !IsNumeric(sPort))
  189.         {
  190.             has_errors = true;
  191.             document.getElementById("proxyPortError").innerHTML = "Valid integer value required.";
  192.         }
  193.         if( sServerName == "")
  194.         {
  195.             has_errors = true;
  196.             document.getElementById("proxyAddressError").innerHTML = "Required.";
  197.         }
  198.     }
  199.     if ( noProxyFor != "" )
  200.     {
  201.         if(sServerName == "")
  202.         {
  203.             has_errors = true;
  204.             document.getElementById("proxyAddressError").innerHTML = "Required.";
  205.         }
  206.         if(!IsNumeric(sPort))
  207.         {
  208.             has_errors = true;
  209.             document.getElementById("proxyPortError").innerHTML = "Valid integer value Required.";    
  210.         }
  211.         
  212.     }
  213.  
  214.     if((username!="")||(password!="")) // Check server name is given
  215.     {
  216.         if(password == "")
  217.         {
  218.             has_errors = true;
  219.             document.getElementById("proxyPasswordError").innerHTML = "Required.";
  220.         }
  221.         if(username == "")
  222.         {
  223.             has_errors = true;
  224.             document.getElementById("proxyUserError").innerHTML = "Required.";    
  225.         }
  226.         if(sServerName == "")
  227.         {
  228.             has_errors = true;
  229.             document.getElementById("proxyAddressError").innerHTML = "Required.";
  230.         }
  231.         if(!IsNumeric(sPort))
  232.         {
  233.             has_errors = true;
  234.             document.getElementById("proxyPortError").innerHTML = "Valid integer value Required.";    
  235.         }
  236.     }
  237.     //    return validation_errors.join("<br>");
  238.     return     has_errors ? "Some fields require your attention. Please check the form." : "";
  239.  
  240. }
  241.  
  242. function ApplyPreferences()
  243. {
  244.     // Clear the earlier status
  245.     SetOperationStatus('prefBanner', "");
  246.     validation_errors = ValidatePreferences();
  247.     if(validation_errors == "")
  248.     {
  249.         var settingsXml = CreateSettingsXml();
  250.         //var url = "/webaroo/e29f1fe6/settings?request=set";
  251.         //sendXMLData(url, "XMLData=" + settingsXml);
  252.         var prefForm = document.prefForm;
  253.         prefForm.XMLData.value = settingsXml;
  254.         prefForm.submit();
  255.     }
  256.     else
  257.         SetOperationStatus('prefBanner', validation_errors);
  258. }
  259.  
  260. function CreateSettingsXml()
  261. {
  262.     var prefForm = document.prefForm;
  263.     
  264.     var settingsXml = '<XmlData>\n';
  265.     settingsXml += '<Response>\n';
  266.     
  267.     settingsXml += '<ProxyName>' + prefForm.proxyAddress.value + '</ProxyName>\n';
  268.     settingsXml += '<ProxyPort>' + prefForm.proxyPort.value + '</ProxyPort>\n';
  269.     settingsXml += '<NoProxyList>' + prefForm.noProxyList.value + '</NoProxyList>\n';
  270.     settingsXml += '<ProxyUser>' + prefForm.proxyUser.value + '</ProxyUser>\n';
  271.     settingsXml += '<ProxyPassword><![CDATA[' + escape(prefForm.proxyPassword.value) + ']]></ProxyPassword>\n';
  272.     settingsXml += '<StartWebaroo>' + prefForm.startWebaroo.checked + '</StartWebaroo>\n';
  273.     settingsXml += '<LaunchWebaroo>false</LaunchWebaroo>\n';
  274.     settingsXml += '<AutoUpdate>' + prefForm.updateOption[0].checked + '</AutoUpdate>\n';
  275.     settingsXml += '<MySitesAutoUpdate>' + prefForm.mysiteupdateOption[0].checked + '</MySitesAutoUpdate>\n';
  276.     
  277.     settingsXml += '</Response>\n';
  278.     settingsXml += '</XmlData>\n';
  279.  
  280.     return settingsXml;
  281. }
  282.  
  283. function ClearPrefForm()
  284. {
  285.     document.prefForm.proxyAddress.value = "";
  286.     document.prefForm.proxyPort.value = "";
  287.     document.prefForm.noProxyList.value = "";
  288.     document.prefForm.proxyUser.value = "";
  289.     document.prefForm.proxyPassword.value = "";
  290.     document.prefForm.startWebaroo.checked = true;
  291.     document.prefForm.updateOption[1].checked = true;
  292.     document.prefForm.mysiteupdateOption[1].checked = true;
  293. }
  294. function GetPrefsPage(newLocation, historyData) 
  295. {
  296.     var currentLocation = window.location.href.split("#");
  297.     if (currentLocation[0].indexOf("/webaroo/e29f1fe6/about") == -1)
  298.     {
  299.         return;
  300.     }
  301.     currentLocation = window.location.href.split("=");
  302.     if(currentLocation.length >1)
  303.     {
  304.         var helpType = (parseInt(currentLocation[1]) != 0) ? currentLocation[1] : 1;
  305.         ShowPrefsPage(0,helpType);
  306.     }
  307.     else
  308.         ShowPrefsPage(0,1);
  309. }
  310.  
  311. // I18N issue
  312. function ShowPrefsPage(addToHistory,aboutType)
  313. {    
  314.     if(addToHistory)
  315.     {
  316.         dhtmlHistory.add("HelpIndex="+ aboutType,"");
  317.     }
  318.     for (var i=1; i < 6; ++i)
  319.     {
  320.  
  321.         document.getElementById('Div' + i).style.display="none";
  322.         document.getElementById('Cell' + i).className="";
  323.     }
  324.  
  325.     document.getElementById('Cell' + aboutType).className = "selected";
  326.     document.getElementById('Div' + aboutType).style.display="block";
  327.     // Clear the prefBanner Table to remove the earlier status message
  328.     ClearTable('prefBanner');
  329.     ShowSettings();
  330. }
  331.