home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 February / Gamestar_81_2006-02_dvd.iso / Programy / mcombo152.exe / Plugin / Weather / script / weather.js < prev    next >
Encoding:
JavaScript  |  2005-11-15  |  18.5 KB  |  554 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 weather.js ===
  21.  
  22. Here are the variables declared and the main functions.
  23.  
  24.  
  25. ***************************************************************************************/
  26.  
  27. var SECURITY_ID    = max_security_id
  28. var PLUGIN_NAME = "Weather"
  29.  
  30. var alreadyShowingError    = false
  31. window.onerror    = ShowError
  32.  
  33. function ShowError(msg,url,line){
  34.     var d         = new Date()
  35.     var date    = d.getHours().toString()+':'+d.getMinutes().toString()+':'+d.getSeconds().toString()
  36.     if(!alreadyShowingError) external.get_tab(SECURITY_ID,external.cur_sel).window.status 
  37.                 = 'Message: '+msg+' Line: '+line+' URL: '+url+' Date: '+date
  38.     alreadyShowingError        = true
  39. }
  40.  
  41. checkIfIniFileExists()
  42.  
  43. var activeLocation     = readIni("Number")
  44. if(activeLocation=='') 
  45.     activeLocation     = '1'
  46. var locationId         = readIni("LocationCode"+activeLocation)
  47. var activeCityName     = readIni("LocationTxt"+activeLocation,'? , ?')
  48. var units             = readIni("units").replace(/1/,'Celcius').replace(/0/,'Fahrenheit')
  49. if(units=='') 
  50.     units             = 'Celcius'
  51. var futdays         = readIni("FutureDays",'8');
  52. var details         = readIni("showDetails",'1')
  53. var design             = readIni("design")
  54. var detlink         = readIni("DetailsLink")
  55. var style             = readIni("StyleName")
  56. var iconExtension     = readIni("IconExtension")
  57. var fontsize        = readIni("FontSize","MediumFonts.css")
  58. var type             = readIni('Type','Summary').replace(/0/,'Summary').replace(/1/,'Future').replace(/2/,'Today')
  59. var showTodayDate     = readIni('ShowDate','0')
  60. var compactDisplay     = readIni('compactDisplay','1')
  61. var showWinAlways     = readIni('showFloatingWindow','0')
  62. var numberOfCities     = readIni('numberOfCities','3')
  63. var titleAlign         = readIni('TitleAlign','left')
  64. var imageLocation     = readIni('ImageSet','Type1_25')+'/'
  65. var use24Hours        = readIni('24Hours','1')
  66. var disableTooltips = readIni('DisableTooltips','0')
  67. try{
  68.     var interval     = eval(readIni("Interval"));
  69. catch(err){ 
  70.     var interval     = 9999
  71. }
  72. var QuantLength     = readIni("QuantityLength",'2')
  73. if(QuantLength == 0) 
  74.             compact = 0
  75. else compact         = 1
  76. var pluginfolder    = external.m2_plugin_folder(SECURITY_ID,PLUGIN_NAME);
  77. var name            = 'Weather'
  78. var languageFile    = getCurrentLanguage()
  79. var cityTra            = readFile("language/Language"+languageFile+".ini").toLowerCase().split('\r\n')
  80. var errorMsg1        = trans('WT_error')+'<br><a href="'+scriptURL+'" target=_blank>'+locationId+'</a><br>'+trans('WT_errorconn')
  81. var errorMsg2        = trans('WT_error')+'<br><a href="'+scriptURL+'" target=_blank>'+locationId+'</a><br>'+trans('WT_errorsupp')
  82. var errorMsgCached    = '<b>'+trans('WT_noupdate')+'</b>'
  83. var topicMsg        = '<span style="cursor:hand" title="'+trans("WT_ForumTopic")+
  84.                 '" onclick="window.open(\'http://forum.maxthon.com/forum/index.php?showtopic=22354\')">Weather 4.41</span>'
  85. if(units == 'Fahrenheit') 
  86.     var unitsSym     = ['F', trans('WT_mph'), trans('WT_mile'), trans('WT_inches')]
  87. else var unitsSym     = ['C', trans('WT_kmh'), trans('WT_km'), trans('WT_hPa')]
  88. var monthname        = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
  89. var scriptURL, 
  90.     dataall         = 0, 
  91.     couldNotLoad     = false, 
  92.     goAnyway         = false
  93. data                = new Array()
  94. var smallWindow        = ''
  95.  
  96. try{
  97.             objXMLHTTP = external.max_activex(SECURITY_ID,"Microsoft.XMLHTTP")
  98.         } catch(err) {
  99.             objXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
  100.         }
  101.  
  102. //constants
  103.  
  104. var IMG_LOCATION_MODDIALOG    = readIni('imageLocationFloatingWindow','Type2_45/')
  105. var FONT_SIZE_MODDIALOG        = 'SmallFonts.css'
  106. var WEBPAGE_SUM             = 'http://www.msnbc.com/m/chnk/d/weather_d_src.asp?acid='
  107. var WEBPAGE_FUT             = 'http://www.weather.com/weather/mpdwcr/tenday?locid='
  108. var WEBPAGE_TODAY             = 'http://www.weather.com/weather/mpdwcr/dailydetails?locid='
  109. var WEBPAGE_LOCATION_SEARCH = 'http://xml.weather.com/search/search?where='
  110.  
  111. document.write('<link href="style/'+style+'" rel="stylesheet" type="text/css">')
  112. document.write('<link href="style/'+fontsize+'" rel="stylesheet" type="text/css">')
  113. document.write('<style>.titleleft{text-align:'+titleAlign+' !important;}</style>')
  114.  
  115. for(i=0;i<=numberOfCities;i++){
  116.     eval('city'+i+' = readIni("LocationTxt'+i+'","? , ?")')
  117. }
  118.  
  119. /*If no location is set */
  120.  
  121. if(locationId == '') locationId = 'NLXX0016'
  122.  
  123.  
  124. function goAgain(dataall){
  125.     top.dataall = dataall
  126.     getDat()
  127.     restart()
  128.     showErrorMessage('')//remove old error messages
  129. }
  130.  
  131. /*The data received from weather.com (summary)
  132.  
  133. function makeWeatherObj() { this.swCity = "Hong Kong"; this.swSubDiv = ""; this.swCountry = "China"; this.swRegion = "Asia"; this.swTemp = "84"; this.swTempCel = 
  134. Math.round((5/9)*(this.swTemp-32)); this.swCIcon = "27"; this.swWindS = "17"; this.swWindD = "SSW"; this.swBaro = "29.68"; this.swHumid = "79"; this.swReal = "94"; this.swUV = "0"; this.swVis = 
  135. "6.21"; this.swLastUp = "06/18/2005 07:00:00"; this.swConText = "Mostly Cloudy"; this.swFore = "7|1|2|3|4| 06/18/2005|06/19/2005|06/20/2005|06/21/2005|06/22/2005| 38|38|38|38|38| 
  136. 28|66|28|28|28| 88|89|89|89|87| 60|60|60|60|60| 47|47|47|47|47| 28|28|28|28|28| 82|82|82|81|80|"; this.swAcid = "ChXX0049"; }*/
  137.  
  138. /*Show the last update of the weather.com data */
  139.  
  140. function lastUpdateTime() {
  141.     try{
  142.         var text="<a href='"+detlink+
  143.             locationId+"' target=_blank title='"+trans("WT_DetLinkTitle")+"'>"+trans("WT_DetLink")+"</a><br>"+
  144.             trans("WT_Lastupdate");
  145.         if(design==1) text+='<br>'
  146.         text+=' '+updateTime
  147.         document.all['lastUpdate'].innerHTML = text
  148.     }    catch(err){}
  149. }
  150.  
  151. /*Change the weather forecast type (summary, 10-day future)*/
  152.  
  153. function changeType(x){
  154.     writeIni('Type',x)
  155.     if(x == 'Summary')         scriptURL     = WEBPAGE_SUM+locationId
  156.     else if(x == 'Future') scriptURL    = WEBPAGE_FUT+locationId
  157.     else if(x == 'Today')  scriptURL    = WEBPAGE_TODAY+locationId
  158.     type = x
  159.     goAnyway = true
  160.     reloadPage()
  161. }
  162.  
  163. /*Get the correct day */
  164.  
  165. function getWeekday(n) {
  166.     if(type== 'Summary') n--
  167.     if(n<0) n+=7
  168.     days    = ["WT_Sunday","WT_Monday","WT_Tuesday","WT_Wednesday","WT_Thursday","WT_Friday","WT_Saturday"]
  169.     q        = trans(days[(n)])
  170.     if(compact==1&&q.length>QuantLength+2) q='<span title="'+q+'">'+q.substring(0,QuantLength+2)+'</span>'
  171.     return q
  172. }
  173.  
  174. /*Save the state of the items (today/tomorrow/future) */
  175.  
  176. function switchstate(item) {
  177.     var key    = item.replace(/title/gi,'Show')
  178.     var x    = readIni(key)
  179.     if(x == 0)     writeIni(key,1)
  180.     else         writeIni(key,0)
  181.     ExpandCollapse(item);
  182. }
  183.  
  184. /* Shows today's date */
  185.  
  186. function showDate(x){
  187.     var x=x.replace(/[^0-9,]*/g,'').split(',')
  188.     if(type=='Today' || type=='Future'){
  189.         var month = (eval(x[1])+1).toString()
  190.         if(month.length==1) month='0'+month
  191.         var year = x[0]
  192.         var day  = x[2]
  193.         if(day.length==1) day = '0'+day
  194.     }
  195.     else{
  196.         var month    = x[0]
  197.         var year    = x[2]
  198.         var day        = x[1]
  199.     }
  200.     var date    = readIni('TodaysDate')
  201.     date         = date.replace(/dd/g,day).replace(/mm/g,month).replace(/yyyy/g,year)
  202.     date         = date.replace(/yy/g,year.substring(2,4)).replace(/Month/gi,trans('WT_'+monthname[(eval(month)-1)]))
  203.     top.dateToday = date
  204. }
  205.  
  206.  
  207. /* Expand/Collapse the items */
  208.  
  209. function ExpandCollapse(item) {
  210.     var key    = item.replace(/title/gi,'Show')
  211.     var x    = readIni(key)
  212.     var d    = key.replace(/Show/gi,'').toLowerCase()
  213.     if(document.all['title'+d]==null) return
  214.     if(x == 0) {
  215.         document.all['title'+d].src = "images/plus.gif";
  216.         var d=document.all["content"+d]
  217.         if(d[0]) d[0].style.display = "none";
  218.         else     d.style.display     = "none";
  219.         if(d[1]) d[1].style.display = "none";
  220.     } else {
  221.         document.all['title'+d].src = "images/minus.gif";
  222.         var d=document.all["content"+d]
  223.         if(d[0]) d[0].style.display = "block";
  224.         else     d.style.display     = "block";
  225.         if(d[1]) d[1].style.display = "block";
  226.     }
  227. }
  228.  
  229. /* Expand/Collapse the items on start */
  230.  
  231. function setExpandCollapseStates() {
  232.     ExpandCollapse("titlenow")
  233.     ExpandCollapse("titletoday")
  234.     ExpandCollapse("titlefuture")
  235. }
  236.  
  237. /* Auto-Update the window */
  238.  
  239. function setAutoUpdate () {
  240.     if(interval==null||interval==9999||interval==0) return;
  241.     else autoUpdateTimer = setTimeout("reloadPage()",1000*60*interval);
  242. }
  243.  
  244. function showErrorMessage(message){
  245.     document.all['error'].innerHTML = message
  246.     if(message=='') document.all['error'].style.display='none'
  247.     else document.all['error'].style.display='block'
  248. }
  249.  
  250. /* start the retrieveHTML function (located in functionsWeather.js) */
  251.  
  252. function reloadPage(){
  253.     retrieveHTML(scriptURL)
  254. }
  255.  
  256. /* Set the active tab to bold */
  257.  
  258. function setFontWeight(){
  259.     if(type == 'Future'){
  260.         document.all['futu'].style.fontWeight    = 'bold'
  261.         document.all['Summ'].style.fontWeight    = 'normal'
  262.         document.all['Tod'].style.fontWeight    = 'normal'
  263.     }
  264.     else if(type == 'Summary'){
  265.         document.all['Summ'].style.fontWeight    = 'bold'
  266.         document.all['futu'].style.fontWeight    = 'normal'
  267.         document.all['Tod'].style.fontWeight    = 'normal'
  268.     }
  269.     else if(type == 'Today'){
  270.         document.all['Summ'].style.fontWeight    = 'normal'
  271.         document.all['futu'].style.fontWeight    = 'normal'
  272.         document.all['Tod'].style.fontWeight    = 'bold'
  273.     }
  274.     if(numberOfCities!=1) {
  275.         for(var i=1; i<=numberOfCities; i++){
  276.             if(activeLocation!=i) eval('document.all["city'+i+'"].style.fontWeight = "normal"')
  277.             else eval('document.all["city'+i+'"].style.fontWeight = "bold"')
  278.         }
  279.     }
  280.     //Translate City + Country
  281.     document.all['cityNameDisp'].innerHTML = transLoc(activeCityName)
  282.  
  283. }
  284.  
  285. /* Write the city tabs */
  286.  
  287. function City() {
  288.     var text = ''
  289.     var d = Math.round(100/(eval(numberOfCities)+2))
  290.     if(numberOfCities==1) return
  291.     for(var x=1; x<=numberOfCities; x++){
  292.         text+='<td class=center width="'+d+'%">'+
  293.                 '<a id="city'+x+'" href="javascript:ChangeCity('+x+')" '+
  294.                     ((activeLocation==x)?'style="font-weight:bold"':'')+
  295.                 ' title="'+transLoc(eval('city'+x))+'">'+x+'</a>'+
  296.             '</td>'
  297.     }
  298.     document.write(text)
  299.  
  300.     /*document.write('<a id="city'+x+'" href="javascript:ChangeCity('+x+')" '+((activeLocation==x)?'style="font-weight:bold"':'')+
  301.         ' title="'+transLoc(eval('city'+x))+'">'+x+'</a>')*/
  302. }
  303.  
  304. /* Change city if the users clicks 1,2 or 3 */
  305.  
  306. function ChangeCity(x) {
  307.     writeIni('Number',x)
  308.     activeLocation = x
  309.     if(name=='Config') {
  310.         if(readIni("LocationTxt"+activeLocation)!='')
  311.             document.all['cityNameDisp'].innerHTML=transLoc(readIni("LocationTxt"+activeLocation))
  312.         else document.all['cityNameDisp'].innerHTML='? , ?'
  313.         locationId = readIni("LocationCode"+activeLocation)
  314.         
  315.         for(var i=1; i<=numberOfCities; i++){
  316.             if(activeLocation!=i) eval('document.all["city'+i+'"].style.fontWeight = "normal"')
  317.             else eval('document.all["city'+i+'"].style.fontWeight = "bold"')
  318.         }
  319.     }
  320.     else {
  321.         locationId = readIni("LocationCode"+x)
  322.         if(locationId == '') {
  323.             goConfig()
  324.             document.all['cityNameDisp'].innerHTML='? , ?'
  325.             setFontWeight()
  326.             return
  327.         }
  328.         
  329.         setScriptURL()
  330.         goAnyway=true
  331.         reloadPage()
  332.     }
  333. }
  334.  
  335. /* Is called when basic HTML page (weather.htm) finished loading 
  336.  this function will start the retrieveHTML function to recieve the weather info 
  337.  and set the right tab (in bold) + activeCityName on the HTML page*/
  338.  
  339. function start(){
  340.     if(languageFile=='0002'||languageFile=='0016') {
  341.             document.body.style.direction='RTL'//set the text alignment for the Arabic and Hebrew languagefiles to right to left
  342.     }
  343.     setFontWeight()
  344.     setScriptURL()
  345.     
  346.     retrieveHTML(scriptURL)
  347.     
  348.     //Blur all links when you click on them, makes everything a bit nicer.
  349.     var allLinks = document.links
  350.     for(var i=0; i<allLinks.length; i++){
  351.         allLinks[i].onfocus=function(){
  352.             this.blur()
  353.         }
  354.     }
  355.     
  356.     //if(disableTooltips == 1) {alert();disableTooltips()}
  357. }
  358.  
  359.  
  360. function setScriptURL(){
  361.     if(type == 'Summary')          scriptURL = WEBPAGE_SUM+locationId
  362.     else if(type == 'Future')     scriptURL = WEBPAGE_FUT+locationId
  363.     else if(type == 'Today')     scriptURL = WEBPAGE_TODAY+locationId
  364. }
  365.  
  366. /* This function is started when all the data is recieved and loaded (by evaluate) */
  367.  
  368. function restart(){
  369.     errorMsg1 = trans('WT_error')+'!<br><a href="'+scriptURL+'" target=_blank>'+locationId+'</a><br>'+trans('WT_errorconn')
  370.     errorMsg2 = trans('WT_error')+'!<br><a href="'+scriptURL+'" target=_blank>'+locationId+'</a><br>'+trans('WT_errorsupp')
  371.     
  372.     setFontWeight()
  373.     
  374.     //couldNotLoad is true when an error occures, so the weather data should not be showed, only an error message
  375.     if(!couldNotLoad) {
  376.         loadPage()
  377.         setExpandCollapseStates()
  378.         setAutoUpdate()
  379.         lastUpdateTime()
  380.     } else {
  381.         document.all['mainBody'].innerHTML='<div class=error>'+errorMsg1+'</div>'
  382.         document.all['lastUpdate'].innerHTML=''
  383.     }
  384.     if(disableTooltips == '1')    removeTooltips()
  385. }
  386.  
  387. function removeTooltips(){
  388.     var allLinks = document.links
  389.     for(var i=0; i<allLinks.length; i++){
  390.         allLinks[i].title = ''
  391.     }
  392.     var allSpanTags = document.getElementsByTagName('span')
  393.     for(var i=0; i<allSpanTags.length; i++){
  394.         allSpanTags[i].title = ''
  395.     }
  396.     var allImages = document.getElementsByTagName('img')
  397.     for(var i=0; i<allImages.length; i++){
  398.         allImages[i].title = ''
  399.     }
  400.     var allTdTags = document.getElementsByTagName('td')
  401.     for(var i=0; i<allTdTags.length; i++){
  402.         allTdTags[i].title = ''
  403.     }
  404.     var allTrTags = document.getElementsByTagName('tr')
  405.     for(var i=0; i<allTrTags.length; i++){
  406.         allTrTags[i].title = ''
  407.     }
  408. }
  409.  
  410. /* Go to the configuration page */
  411.  
  412. function goConfig(){
  413.     showErrorMessage('')
  414.     document.all['configu'].style.display    = 'block'
  415.     document.all['mainBody'].style.display    = 'none'
  416.     document.all['typelinks'].style.display    = 'none'
  417.     document.all['confTD'].disabled            = false
  418.     oldLastUpd=document.all['lastUpdate'].innerHTML
  419.     document.all['lastUpdate'].innerHTML    = ''
  420.     document.all['configbox'].style.display    = 'block'
  421.     document.all['weatherbox'].style.display= 'none'
  422.     document.all['icon1'].src                = 'images/sun.gif'
  423.     document.all['icon1'].parentElement.href= 'javascript:goWeather()'
  424.     if(disableTooltips != '1') 
  425.         document.all['icon1'].title            = trans('WT_Weather')
  426.     document.all['icon2'].parentElement.href= 'javascript:location.reload()'
  427.     readPara()
  428.     if(top.autoUpdateTimer!=null) window.clearInterval(autoUpdateTimer)
  429.     name = 'Config'
  430.     //These 2 lines fix an IE bug. If the configuration is clipped and you go back to the weather data the scrollbar is gone, but the page is still small.
  431.     document.body.style.overflow = 'hidden'
  432.     document.body.style.overflow = 'auto'
  433.     if(smallWindow&&smallWindow!='') smallWindow.window.close()
  434. }
  435.  
  436. /* Go to the weather page */
  437.  
  438. function goWeather(){
  439.     if(locationId=='') goConfig()
  440.     setScriptURL()
  441.     clearRows(resultcontent)
  442.     name = 'Weather'
  443.     document.all['configu'].style.display    = 'none'
  444.     document.all['mainBody'].style.display    = 'block'
  445.     document.all['mainBody'].innerHTML        = trans('WT_loading')
  446.     document.all['typelinks'].style.display    = 'block'
  447.     document.all['confTD'].disabled            = true
  448.     document.all['lastUpdate'].innerHTML    = oldLastUpd
  449.     document.all['configbox'].style.display    = 'none'
  450.     document.all['weatherbox'].style.display= 'block'
  451.     document.all['icon1'].src                = 'images/config.gif'
  452.     document.all['icon1'].parentElement.href= 'javascript:goConfig()'
  453.     document.all['icon1'].title                = trans('WT_Setup')
  454.     
  455.     //These 2 lines fix an IE bug. If the configuration is clipped and you go back to the weather data the scrollbar is gone, but the page is still small.
  456.     document.body.style.overflow = 'hidden'
  457.     document.body.style.overflow = 'auto'
  458.     
  459.     //setAutoUpdate()
  460.     reloadPage()
  461. }
  462.  
  463. function nothing(){
  464.     return true
  465. }
  466.  
  467. /* Get the Maxthon language, and save it (only the firstRun time you load the plugin, after that it will only load the saved language) */
  468.  
  469. function getCurrentLanguage(){
  470.     var firstRun = readIni("First")
  471.     if(firstRun=='true') {
  472.         try{
  473.             var languageFile = external.max_language_id;
  474.         }
  475.         catch(err) {
  476.             var languageFile=''
  477.         }
  478.         writeIni('First','false')
  479.         if(external.m2_readIni(SECURITY_ID,PLUGIN_NAME,'/Language/Language'+languageFile+'.ini','Language','WT_Now','err')!='err')
  480.             writeIni('Language',languageFile)
  481.         else writeIni('Language','')
  482.     }
  483.     else var languageFile = readIni('Language')
  484.     if(external.m2_readIni(SECURITY_ID,PLUGIN_NAME,'/Language/Language'+languageFile+'.ini','Language','WT_Now','err')=='err') 
  485.         languageFile=''
  486.     return languageFile
  487. }
  488.  
  489.  
  490. /* Show the small window */
  491.  
  492. function showFloatingWindow(){
  493.     smallWindow = external.max_modelessDialog(SECURITY_ID,"script/Dialog.htm",window,"dialogTop:"+readIni('WinTop')+
  494.             "px;dialogLeft:"+readIni('WinLeft')+"px;status:0;help:0;scroll:0;"+
  495.             "resizable:1;dialogHeight:"+readIni('WinHeight')+";dialogWidth:"+readIni('WinWidth')+";center:0;",window);
  496.     document.all['showWinLink'].innerHTML    = trans('WT_CloseWin')
  497.     document.all['showWinLink'].href        = 'javascript:smallWindow.window.close()'
  498. }
  499.  
  500.  
  501. /* Save the window size/position */
  502.  
  503. function saveCurrentPosition(x,y,z,a){
  504.     writeIni('WinLeft',    x-4)
  505.     writeIni('WinTop',     y-30)
  506.     writeIni('WinHeight', z)
  507.     writeIni('WinWidth',  a)
  508.     smallWindow = ''
  509.     if(document.all['showWinLink']){
  510.         document.all['showWinLink'].innerHTML= trans('WT_OpenWin')
  511.         document.all['showWinLink'].href     = 'javascript:showFloatingWindow()'
  512.     }
  513. }
  514.  
  515. /*Read/write files */
  516.  
  517. function readFile(filename) {
  518.     return external.readFile(SECURITY_ID,PLUGIN_NAME,filename)
  519. }
  520.  
  521. function writeFile(filename,data) {
  522.     external.writeFile(SECURITY_ID,PLUGIN_NAME,filename,data)
  523. }
  524.  
  525. /*Read/Write Settings*/
  526.  
  527. function readIni(Key, errorResponse) {
  528.     if(errorResponse==null) errorResponse = ''
  529.     returnValue = external.m2_readIni(SECURITY_ID,PLUGIN_NAME,"settings.ini","Settings", Key, 'error')
  530.     if(returnValue == 'error') {
  531.         var defaultFileValue = external.m2_readIni(SECURITY_ID,PLUGIN_NAME,"DefaultSettings.ini","Settings", Key, 'error')
  532.         if(defaultFileValue == 'error')
  533.             return errorResponse
  534.         else {
  535.         //alert(Key+returnValue+defaultFileValue)
  536.             writeIni(Key, defaultFileValue)
  537.             returnValue = defaultFileValue
  538.         }
  539.     }
  540.     return returnValue
  541. }
  542.  
  543. function writeIni(Key, Data) {
  544.     external.m2_writeIni(SECURITY_ID,PLUGIN_NAME,"settings.ini","Settings", Key, Data+'')
  545. }
  546.  
  547.  
  548. function checkIfIniFileExists(){
  549.     if(readIni('Number','error') != 'error') return
  550.     var defaultSettingsFile = readFile('defaultSettings.ini')
  551.     if(defaultSettingsFile && defaultSettingsFile != '') 
  552.         writeFile('settings.ini',defaultSettingsFile)
  553. }