home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 February / Gamestar_81_2006-02_dvd.iso / Programy / mcombo152.exe / Plugin / Weather / script / configuration.js next >
Text File  |  2005-11-15  |  5KB  |  175 lines

  1. /*************************************************************************************
  2.  
  3. === Weather 4.41 ===
  4.  
  5. By Neo101
  6. Previous versions by crino, Arkim, mdlist, seidenj and Tara
  7. Created for Maxthon Tabbed Browser (www.maxthon.com)
  8.  
  9. === License ===
  10.  
  11. Please contact Neo10 on forum.maxthon.com or www.neo101.nl if you would like to make any changes!
  12. This plugin is for Maxthon only. You are not allowed to use it for any other program without permission.
  13. Do not remove these comments/credits.
  14. You are allowed to use/copy the icons. I did not create them.
  15.  
  16. Copyright 2005
  17.  
  18. Last modified 17-11-2005
  19.  
  20. === Description of configuration.js ===
  21.  
  22. Here are the functions used by the configuration
  23.  
  24.  
  25. ***************************************************************************************/
  26.  
  27. /* Parse the XML file with search results */
  28.  
  29. function xmlParse(xmlText) {
  30.     var nodes = new Array()
  31.     try{
  32.         var xmlDoc = external.max_activex(SECURITY_ID,"Microsoft.XMLDOM")
  33.     }
  34.     catch(err) {
  35.         var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
  36.     }
  37.     xmlDoc.async = "false"
  38.     xmlDoc.loadXML(xmlText)
  39.     var ch=xmlDoc.documentElement.childNodes
  40.     for(i=0; i<ch.length; i++){
  41.         nodes[i]     = new Array()
  42.         nodes[i][0] = ch.item(i).text
  43.         nodes[i][1] = ch.item(i).getAttribute("id") 
  44.     }
  45.     return nodes
  46. }
  47.  
  48. /* Clear/Add rows for the city search */
  49.  
  50. function clearRows(oTable) {
  51.     var rowsnum = oTable.rows.length
  52.     for(i=0; i<rowsnum; i++) oTable.deleteRow()
  53. }
  54.  
  55. function addRow(oTable,rowHTML) {
  56.     var oRow = oTable.insertRow()
  57.     var oCell= oTable.rows(oRow.rowIndex).insertCell(oRow.cells.length)
  58.     oCell.innerHTML = rowHTML
  59. }
  60.  
  61. /* Search for Cities */
  62.  
  63. function findlocationId() {
  64.     var name = document.all['citynameinp'].value
  65.     if(name.search(/[a-zA-Z]{4}[0-9]{4}/g)!=-1) {
  66.         writeIni("LocationCode"+activeLocation, name)
  67.         writeIni("LocationTxt"+activeLocation,'unknown')
  68.         location.replace("weather.htm")
  69.         return
  70.     } else if(name=='') {
  71.         clearRows(resultcontent)
  72.         addRow(resultcontent,trans('WT_NoKeywords'))
  73.         return
  74.     }
  75.     name = transCity(name.toLowerCase())
  76.     var scriptURL = WEBPAGE_LOCATION_SEARCH + name
  77.     retrieveHTML(scriptURL)
  78. }
  79.  
  80.  
  81. /* Confirm the city after a search */
  82.  
  83. function confirmcity() {
  84.     var sel = 0
  85.     if(cities.length==1 && listcities.checked) {
  86.         writeIni("LocationCode"+activeLocation, cities[0][1])
  87.         writeIni("LocationTxt"+activeLocation, cities[0][0])
  88.         locationId=cities[0][1]
  89.         sel = 1
  90.     } else if(cities.length>1){
  91.         for(i=0; i<cities.length; i++) {
  92.             if(listcities[i].checked) {
  93.                 writeIni("LocationCode"+activeLocation, cities[i][1])
  94.                 writeIni("LocationTxt"+activeLocation, cities[i][0])
  95.                 locationId=cities[i][1]
  96.                 sel = 1
  97.             }
  98.         }
  99.     }
  100.     if(sel==1) {
  101.         document.all['cityNameDisp'].innerHTML=transLoc(readIni("LocationTxt"+activeLocation))
  102.         clearRows(resultcontent)
  103.         document.all['citynameinp'].value=''
  104.         addRow(resultcontent,'<b>'+trans('WT_Saved')+'</b>')
  105.         //location.reload()
  106.     }
  107. }
  108.  
  109. /* Set the correct settings*/
  110.  
  111. function setPara() {
  112.     var inputTags=document.all.tags('INPUT');
  113.     for (var i=0; i<inputTags.length; i++) {
  114.         if(inputTags[i].type=='radio' && inputTags[i].checked) writeIni(inputTags[i].name,inputTags[i].value)
  115.     }
  116.     var selectTags=document.all.tags('SELECT');
  117.     for (var i=0; i<selectTags.length; i++) {
  118.         writeIni(selectTags[i].name,selectTags[i].options[selectTags[i].selectedIndex].value)
  119.     }
  120.     location.replace("weather.htm")
  121. }
  122.  
  123. /* read the correct settings on start */
  124.  
  125. function readPara() {
  126.     var inputTags = document.all.tags('INPUT');
  127.     for (var i=0; i<inputTags.length; i++) {
  128.         if(inputTags[i].type == 'radio') {
  129.             var iniValue = readIni(inputTags[i].name)
  130.             if(inputTags[i].value == iniValue) inputTags[i].checked=true
  131.             else inputTags[i].checked=false
  132.         }
  133.     }
  134.     var selectTags = document.all.tags('SELECT');
  135.     for (var i=0; i<selectTags.length; i++) {
  136.         var iniValue = readIni(selectTags[i].name)
  137.         for(var d=0; d<selectTags[i].options.length; d++) {
  138.             if(iniValue == selectTags[i].options[d].value) selectTags[i].selectedIndex = d
  139.         }
  140.     }
  141.     document.all['cityNameDisp'].innerHTML = transLoc(activeCityName)
  142.     ExpandCollapse("titleadvanced")
  143.     ExpandCollapse("titlehelp")
  144.     if(languageFile=='0002'||languageFile=='0016') {
  145.             document.body.style.direction='RTL'//set the text alignment for the Arabic and Hebrew languagefiles to right to left
  146.     }
  147. }
  148.  
  149. function EnterKeyPress() {
  150.     if (window.event.keyCode == 13)    findlocationId();
  151. }
  152.  
  153. /* Read the icon sets available in the icons.ini file, and print the select tag */
  154.  
  155. function getIconSets(){
  156.     var text = ''
  157.     for(var i=1; i<10; i++){
  158.         var iconLoc = eval('readIniIcon("icon'+i+'")')
  159.         var iconName= eval('readIniIcon("iconName'+i+'")')
  160.         if(iconLoc!='') text += '<option value="'+iconLoc+'">'+trans("WT_Type")+' '+iconName+'</option>'
  161.         else break
  162.     }
  163.     document.write(text)
  164. }
  165.  
  166. function readIniIcon(key){
  167.     return external.m2_readIni(SECURITY_ID,PLUGIN_NAME,"icons.ini","IconSets", key, '')
  168. }
  169.  
  170. /* Prints the info+explanation for the settings in the configuration */
  171.  
  172. function printHead(name){
  173.     document.write('<tr class="config-tr" title="'+trans('WT_Explain_'+name)+'">'+
  174.         '<td class="head">'+trans('WT_'+name)+'</td>')
  175. }