#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)((?:(?:^[ \t]*)?(?:\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\/(?:[ \t]*\r?\n(?=[ \t]*(?:\r?\n|\/\*|\/\/)))?|\/\/(?:[^\\]|\\(?:\r?\n)?)*?(?:\r?\n(?=[ \t]*(?:\r?\n|\/\*|\/\/))|(?=\r?\n))))+)|((?:"[^"\\]*(?:\\[\S\s][^"\\]*)*"|'[^'\\]*(?:\\[\S\s][^'\\]*)*'|(?:\r?\n(?:(?=(?:^[ \t]*)?(?:\/\*|\/\/))|[^\/"'\\\r\n]*))+|[^\/"'\\\r\n]+)+|[\S\s][^\/"'\\\r\n]*)"
Local $sString = "/* Some of these types off comments" & @CRLF & _
"more here and here ..." & @CRLF & _
"*/" & @CRLF & _
"" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// THIS CODE IS NOT APPROVED FOR USE IN/ON ANY OTHER UI ELEMENT OR PRODUCT COMPONENT." & @CRLF & _
"// Copyright (c) 2009 Microsoft Corporation. All rights reserved." & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"var g_oService;" & @CRLF & _
"var g_oCurr = new Array(4);" & @CRLF & _
"var g_oTimer = null;" & @CRLF & _
"var g_StartValue = 1;" & @CRLF & _
"var g_sRowCount = 1;" & @CRLF & _
"var g_sRowHeight = 54;" & @CRLF & _
"var g_sBodyHeight;" & @CRLF & _
"var g_sMenuHeight;" & @CRLF & _
"var g_sFullName = true;" & @CRLF & _
"var g_dataFromService;" & @CRLF & _
"var g_isStaleData = false;" & @CRLF & _
"var g_ageStampText = "";" & @CRLF & _
"var spinner;" & @CRLF & _
" " & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Load gadget's main function" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function loadMain()" & @CRLF & _
"{" & @CRLF & _
" // Set initial values needed for dynamic re-sizing of menu and rows" & @CRLF & _
" g_sBodyHeight = parseInt(document.body.currentStyle.height);" & @CRLF & _
" " & @CRLF & _
"" & @CRLF & _
" // Check if gadget is new or reloaded with sidebar" & @CRLF & _
" if (readSetting('rowCount'))" & @CRLF & _
" {" & @CRLF & _
" g_sRowCount = readSetting('rowCount');" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" saveSetting('rowCount', g_sRowCount);" & @CRLF & _
" }" & @CRLF & _
" spinner = new getSpinner('messageSpinner');" & @CRLF & _
" localizeUI();" & @CRLF & _
"" & @CRLF & _
" SetUIState('loading');" & @CRLF & _
" " & @CRLF & _
" g_oService = new CurrencyService()" & @CRLF & _
" g_oService.OnDataReady = DataReady;" & @CRLF & _
" " & @CRLF & _
" // If we are actually running in the gadget platform" & @CRLF & _
" // wire up all the events." & @CRLF & _
" if (gGadgetMode)" & @CRLF & _
" { " & @CRLF & _
" System.Gadget.onDock = DockGadget;" & @CRLF & _
" System.Gadget.onUndock = UndockGadget;" & @CRLF & _
" " & @CRLF & _
" if (System.Gadget.docked)" & @CRLF & _
" {" & @CRLF & _
" DockGadget();" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" UndockGadget();" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" UndockGadget();" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" // Attaching events to the toolbar buttons" & @CRLF & _
" addButton.attachEvent("onmouseover", function(){addButton.style.backgroundImage = 'url(../images/add_over.png)';});" & @CRLF & _
" addButton.attachEvent("onclick", function(){addButton.style.backgroundImage = 'url(../images/add_down.png)'; addRow();});" & @CRLF & _
" addButton.attachEvent("onmouseout", function(){addButton.style.backgroundImage = 'url(../images/add_up.png)';});" & @CRLF & _
" addButton.attachEvent("onfocus", function(){addButton.style.backgroundImage = 'url(../images/add_down.png)';});" & @CRLF & _
" addButton.attachEvent("onblur", function(){addButton.style.backgroundImage = 'url(../images/add_up.png)';});" & @CRLF & _
" addButton.title = L_localizedStrings_Text['Add']" & @CRLF & _
" " & @CRLF & _
" g_StartValue = g_StartValue.toLocaleString(); " & @CRLF & _
" g_oCurr[0].oTextBox.value = g_StartValue; " & @CRLF & _
" g_oService.GetCurrencies(); " & @CRLF & _
" " & @CRLF & _
" if (System.Gadget.docked)" & @CRLF & _
" {" & @CRLF & _
" document.getElementById('curr0input').style.display = 'block';" & @CRLF & _
" document.getElementById('curr1input').style.display = 'block';" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" " & @CRLF & _
"}" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Localize all data" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function localizeUI()" & @CRLF & _
"{" & @CRLF & _
" for (var i = 0; i < g_oCurr.length; i++)" & @CRLF & _
" {" & @CRLF & _
" g_oCurr[i] = new CurrencyBox('curr' + i, getLocalizedString('GettingExchangeRate'), '0');" & @CRLF & _
" // reverse reference in array" & @CRLF & _
" g_oCurr[i].oTextBox.setAttribute('arrayIdx', i);" & @CRLF & _
" g_oCurr[i].oTextBox.onkeyup = OnAmountChange;" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" var oDataLink = document.getElementById('dataLink');" & @CRLF & _
" oDataLink.innerHTML = getLocalizedString('DataProviders');" & @CRLF & _
" oDataLink.href = getLocalizedString('MSNMoneyURL');" & @CRLF & _
"}" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Creates a currency row for each id in g_oCurr array" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function CurrencyBox(oControl, sCaption, sValue)" & @CRLF & _
"{" & @CRLF & _
" // Self reference" & @CRLF & _
" var me = this;" & @CRLF & _
" " & @CRLF & _
" // Private data members" & @CRLF & _
" var m_oCaption = '';" & @CRLF & _
" var m_sCaption = sCaption;" & @CRLF & _
" var m_oControl = oControl;" & @CRLF & _
" var oDeleteButton;" & @CRLF & _
" var oCurrOnline;" & @CRLF & _
" var oValueDiv;" & @CRLF & _
" var oTextBoxBack;" & @CRLF & _
" var sCurrCount = oControl.replace('curr', '');" & @CRLF & _
" var tableCurr;" & @CRLF & _
" var oTableCaption;" & @CRLF & _
" var oTD = new Array();" & @CRLF & _
" var oTDCaption = new Array();" & @CRLF & _
" var oCaptionA;" & @CRLF & _
" var oCurrencyImage;" & @CRLF & _
" " & @CRLF & _
" // Public Properties" & @CRLF & _
" this.oTextBox = null;" & @CRLF & _
" this.oTag = null;" & @CRLF & _
" " & @CRLF & _
" // Get currency div" & @CRLF & _
" m_oControl = document.getElementById(oControl);" & @CRLF & _
" " & @CRLF & _
" // Private methods" & @CRLF & _
" function Initialize()" & @CRLF & _
" {" & @CRLF & _
" // Create table " & @CRLF & _
" tableCurr = document.createElement('<table cellpadding="0" cellspacing="0" border="0"></table>');" & @CRLF & _
" var tbCurr = document.createElement('tbody');" & @CRLF & _
" var trCurr = document.createElement('tr');" & @CRLF & _
" tableCurr.appendChild(tbCurr);" & @CRLF & _
" tbCurr.appendChild(trCurr);" & @CRLF & _
" for (j=0;j<3;j++)" & @CRLF & _
" {" & @CRLF & _
" oTD[j] = document.createElement('td'); " & @CRLF & _
" oTD[j].setAttribute("id", m_oControl.id + "TD" + j);" & @CRLF & _
" trCurr.appendChild(oTD[j]); " & @CRLF & _
" } " & @CRLF & _
" " & @CRLF & _
" // Create table for Caption and left-right borders " & @CRLF & _
" oTableCaption = document.createElement('<table cellpadding="0" cellspacing="0" border="0"></table>');" & @CRLF & _
" var oTBCaption = document.createElement('tbody');" & @CRLF & _
" var oTRCaption = document.createElement('tr');" & @CRLF & _
" oTableCaption.appendChild(oTBCaption);" & @CRLF & _
" oTBCaption.appendChild(oTRCaption);" & @CRLF & _
" for (j=0;j<3;j++)" & @CRLF & _
" {" & @CRLF & _
" oTDCaption[j] = document.createElement('td'); " & @CRLF & _
" oTDCaption[j].setAttribute("id", m_oControl.id + "TDCaption" + j);" & @CRLF & _
" oTRCaption.appendChild(oTDCaption[j]); " & @CRLF & _
" } " & @CRLF & _
" " & @CRLF & _
" // Create container for text/textbox" & @CRLF & _
" oValueDiv = document.createElement('div');" & @CRLF & _
" oValueDiv.id = m_oControl.id + 'value';" & @CRLF & _
" " & @CRLF & _
" // Create currency text" & @CRLF & _
" var oLabel = document.createElement('label');" & @CRLF & _
" oLabel.id = m_oControl.id + 'label';" & @CRLF & _
" m_oCaption = document.createElement('div');" & @CRLF & _
" m_oCaption.id = m_oControl.id + 'caption';" & @CRLF & _
" " & @CRLF & _
" if(document.dir == 'rtl')" & @CRLF & _
" {" & @CRLF & _
" m_oCaption.onmouseover = function() {oTDCaption[0].style.backgroundImage = 'url(../images/combo-hover-right.png)';" & @CRLF & _
" oTDCaption[1].style.backgroundImage = 'url(../images/combo-hover-middle.png)';" & @CRLF & _
" oTDCaption[2].style.backgroundImage = 'url(../images/combo-hover-left.png)';};" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" m_oCaption.onmouseover = function() {oTDCaption[0].style.backgroundImage = 'url(../images/combo-hover-left.png)';" & @CRLF & _
" oTDCaption[1].style.backgroundImage = 'url(../images/combo-hover-middle.png)';" & @CRLF & _
" oTDCaption[2].style.backgroundImage = 'url(../images/combo-hover-right.png)';};" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" m_oCaption.onmouseout = function() {oTDCaption[0].style.backgroundImage = '';" & @CRLF & _
" oTDCaption[1].style.backgroundImage = '';" & @CRLF & _
" oTDCaption[2].style.backgroundImage = '';};" & @CRLF & _
" " & @CRLF & _
" oLabel.appendChild(m_oCaption);" & @CRLF & _
" " & @CRLF & _
" //Create Caption A HREF and triangle image" & @CRLF & _
" oCaptionA = document.createElement('a');" & @CRLF & _
" oCaptionA.id = 'captionA';" & @CRLF & _
" oCaptionA.href = "javascript:void;";" & @CRLF & _
" if ( g_isStaleData )" & @CRLF & _
" {" & @CRLF & _
" oCaptionA.title = getLocalizedString('ServiceNotAvailable');" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" oCaptionA.title = m_sCaption;" & @CRLF & _
" }" & @CRLF & _
" oCaptionA.innerHTML = m_sCaption; " & @CRLF & _
" oCurrencyImage = document.createElement('img');" & @CRLF & _
" oCurrencyImage.id = "currencyImage";" & @CRLF & _
" oCurrencyImage.src = 'images/triangle.png';" & @CRLF & _
" oCurrencyImage.border = '0';" & @CRLF & _
" " & @CRLF & _
" oCaptionA.onclick = function() {showCurrencyList(oControl);};" & @CRLF & _
" oCaptionA.appendChild(oCurrencyImage);" & @CRLF & _
" m_oCaption.appendChild(oCaptionA);" & @CRLF & _
" " & @CRLF & _
" " & @CRLF & _
" " & @CRLF & _
" " & @CRLF & _
" " & @CRLF & _
" " & @CRLF & _
" " & @CRLF & _
" " & @CRLF & _
" // Create button for online currency" & @CRLF & _
" oCurrOnline = document.createElement('div');" & @CRLF & _
" oCurrOnline.id = m_oControl.id + 'OnlineButton';" & @CRLF & _
" oCurrOnlineA = document.createElement('a');" & @CRLF & _
" oCurrOnlineA.id = m_oControl.id + 'OnlineButtonA';" & @CRLF & _
" oCurrOnlineA.target = '_blank';" & @CRLF & _
"" & @CRLF & _
" if ( g_isStaleData )" & @CRLF & _
" {" & @CRLF & _
" oCurrOnlineA.title = getLocalizedString('ServiceNotAvailable');" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" oCurrOnlineA.title = L_localizedStrings_Text['Graph'];" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" oCurrOnlineAImg = document.createElement('img');" & @CRLF & _
" oCurrOnlineAImg.border = '0';" & @CRLF & _
" oCurrOnlineAImg.src = '../images/graph_up.png';" & @CRLF & _
" oCurrOnlineAImg.onmousedown = function() {this.src = '../images/graph_down.png';};" & @CRLF & _
" oCurrOnlineAImg.onmouseover = function() {this.src = '../images/graph_over.png';};" & @CRLF & _
" oCurrOnlineAImg.onmouseout = function() {this.src = '../images/graph_up.png';}; " & @CRLF & _
" " & @CRLF & _
" oCurrOnlineA.appendChild(oCurrOnlineAImg);" & @CRLF & _
" oCurrOnline.appendChild(oCurrOnlineA);" & @CRLF & _
" " & @CRLF & _
" // Create delete button" & @CRLF & _
" oDeleteButtonA = document.createElement('a');" & @CRLF & _
" oDeleteButtonA.setAttribute("href","javascript:void;");" & @CRLF & _
" oDeleteButtonA.setAttribute("title",L_localizedStrings_Text['Remove']);" & @CRLF & _
" oDeleteButtonA.style.backgroundImage = 'url(../images/delete_up.png)';" & @CRLF & _
" oDeleteButton = document.createElement('div');" & @CRLF & _
" oDeleteButton.id = m_oControl.id + 'DeleteButton'; " & @CRLF & _
" oDeleteButton.style.backgroundImage = 'url(../images/delete_up.png)';" & @CRLF & _
" oDeleteButtonA.onclick = function() {oDeleteButton.style.backgroundImage = 'url(../images/delete_down.png)'; deleteRow(oControl);};" & @CRLF & _
" oDeleteButton.onmouseover = function() {this.style.backgroundImage = 'url(../images/delete_over.png)';};" & @CRLF & _
" oDeleteButton.onmouseout = function() {this.style.backgroundImage = 'url(../images/delete_up.png)';}; " & @CRLF & _
" oDeleteButtonA.onfocus = function() {if(m_oControl.id.replace('curr', '') !='0' && g_sRowCount > 1){oDeleteButton.style.backgroundImage = 'url(../images/delete_over.png)';oDeleteButton.style.display = 'block';} };" & @CRLF & _
" oDeleteButtonA.onblur = function() {oDeleteButton.style.backgroundImage = 'url(../images/delete_up.png)'; oDeleteButton.style.display = 'none'; };" & @CRLF & _
" oDeleteButtonA.appendChild(oDeleteButton);" & @CRLF & _
" " & @CRLF & _
" // Create the textbox" & @CRLF & _
" me.oTextBox = document.createElement('input');" & @CRLF & _
" me.oTextBox.id = oLabel.htmlFor = m_oControl.id + 'input';" & @CRLF & _
" me.oTextBox.type = 'text';" & @CRLF & _
" me.oTextBox.maxLength = 20;" & @CRLF & _
" me.oTextBox.value = sValue;" & @CRLF & _
" " & @CRLF & _
" // Create the textbox background" & @CRLF & _
" oTextBoxBack = document.createElement('div');" & @CRLF & _
" oTextBoxBack.id = m_oControl.id + 'InputBack'; " & @CRLF & _
" " & @CRLF & _
" oValueDiv.appendChild(tableCurr);" & @CRLF & _
" oValueDiv.appendChild(me.oTextBox);" & @CRLF & _
" oValueDiv.appendChild(oTextBoxBack);" & @CRLF & _
" " & @CRLF & _
" // Add everything in and make it accessible" & @CRLF & _
" m_oControl.appendChild(oValueDiv);" & @CRLF & _
" " & @CRLF & _
" tableCurr.style.height = '21px';" & @CRLF & _
" oTableCaption.style.height = '21px';" & @CRLF & _
" tableCurr.style.position = 'absolute';" & @CRLF & _
" " & @CRLF & _
" oTD[0].style.width = '16px';" & @CRLF & _
" oTDCaption[0].style.width = '3px';" & @CRLF & _
" oTDCaption[2].style.width = '3px';" & @CRLF & _
" oTD[2].style.width = '16px'; " & @CRLF & _
" oTD[0].appendChild(oCurrOnline);" & @CRLF & _
" oTD[1].appendChild(oTableCaption);" & @CRLF & _
" oTDCaption[1].appendChild(oLabel);" & @CRLF & _
" oTD[2].appendChild(oDeleteButtonA); " & @CRLF & _
" " & @CRLF & _
" me.setCaption(m_sCaption);" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" this.setCaption = function(sCaption)" & @CRLF & _
" {" & @CRLF & _
" if ( g_isStaleData )" & @CRLF & _
" {" & @CRLF & _
" oCaptionA.title = getLocalizedString('ServiceNotAvailable');" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" oCaptionA.title = sCaption;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" oCaptionA.innerHTML = sCaption + oCurrencyImage.outerHTML;" & @CRLF & _
" " & @CRLF & _
" " & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" // Set styles depending on docked or undocked" & @CRLF & _
" this.changeMode = function(sMode)" & @CRLF & _
" {" & @CRLF & _
" if (sMode == 'docked')" & @CRLF & _
" {" & @CRLF & _
" oTD[0].style.display = 'none';" & @CRLF & _
" oTD[2].style.display = 'none';" & @CRLF & _
" tableCurr.style.width = '43px'; " & @CRLF & _
" tableCurr.style.left = '9px';" & @CRLF & _
" tableCurr.style.right = '9px';" & @CRLF & _
" tableCurr.style.top = '9px'; " & @CRLF & _
" " & @CRLF & _
" var sCurr = readSetting(oControl) || L_localizedStrings_Text['default'+sCurrCount];" & @CRLF & _
" this.setCaption(sCurr);" & @CRLF & _
" curr1.style.top = '27px';" & @CRLF & _
" tableCurr.className = 'tableFont';" & @CRLF & _
" oTableCaption.className = 'tableCaption';" & @CRLF & _
" m_oControl.className = 'dockedCurrencyContainer';" & @CRLF & _
" m_oCaption.className = 'dockedCurrencyTitle';" & @CRLF & _
" if(document.dir == 'rtl')" & @CRLF & _
" {" & @CRLF & _
" me.oTextBox.className = 'dockedCurrencyValueRtl';" & @CRLF & _
" oTextBoxBack.className = 'dockedCurrencyValueBackRtl';" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" me.oTextBox.className = 'dockedCurrencyValue';" & @CRLF & _
" oTextBoxBack.className = 'dockedCurrencyValueBack';" & @CRLF & _
" }" & @CRLF & _
" oValueDiv.className = 'dockedCurrencyDiv';" & @CRLF & _
" oCurrOnline.className = 'dockedCurrencyOnlineButton';" & @CRLF & _
" oDeleteButton.className = 'dockedCurrencyDeleteButton';" & @CRLF & _
" currencyList.className = 'dockedCurrencyList';" & @CRLF & _
" document.getElementById('currencySelect').className = 'dockedCurrencySelect';" & @CRLF & _
" document.getElementById('currencySelect').size = 4;" & @CRLF & _
" document.getElementById('bottomTable').style.display = 'none';" & @CRLF & _
" m_oControl.onmouseover = '';" & @CRLF & _
" m_oControl.onmouseout = '';" & @CRLF & _
" oValueDiv.onmouseover = '';" & @CRLF & _
" oValueDiv.onmouseout = '';" & @CRLF & _
" g_sFullName = false;" & @CRLF & _
" }" & @CRLF & _
" // undocked" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" oTD[0].style.display = 'block';" & @CRLF & _
" oTD[2].style.display = 'block';" & @CRLF & _
" tableCurr.style.width = '212px';" & @CRLF & _
" tableCurr.style.left = '3px';" & @CRLF & _
" tableCurr.style.right = '3px';" & @CRLF & _
" tableCurr.style.top = '';" & @CRLF & _
" " & @CRLF & _
" var sCurr = readSetting(oControl) || L_localizedStrings_Text['default'+sCurrCount];" & @CRLF & _
" this.setCaption(getLocalizedString(sCurr));" & @CRLF & _
" curr1.style.top = g_sRowHeight;" & @CRLF & _
" oDeleteButton.style.display = 'none';" & @CRLF & _
" tableCurr.className = 'tableFont';" & @CRLF & _
" oTableCaption.className = 'tableCaption';" & @CRLF & _
" m_oControl.className = 'currencyContainer';" & @CRLF & _
" m_oCaption.className = 'currencyTitle';" & @CRLF & _
" me.oTextBox.className = 'currencyValue';" & @CRLF & _
" me.oTextBox.style.display = '';" & @CRLF & _
" oTextBoxBack.className = 'currencyValueBack';" & @CRLF & _
" oValueDiv.className = 'currencyDiv';" & @CRLF & _
" oCurrOnline.className = 'currencyOnlineButton';" & @CRLF & _
" oDeleteButton.className = 'currencyDeleteButton';" & @CRLF & _
" currencyList.className = 'undockedCurrencyList';" & @CRLF & _
" document.getElementById('currencySelect').className = 'undockedCurrencySelect';" & @CRLF & _
" document.getElementById('currencySelect').size = 4 + (g_sRowCount * 4);" & @CRLF & _
" m_oControl.onmouseover = function() {showDelete(oControl)};" & @CRLF & _
" m_oControl.onmouseout = function() {hideDelete(oControl)};" & @CRLF & _
" oValueDiv.onmouseover = function() {this.style.background = 'url(../images/row_over.png) no-repeat';};" & @CRLF & _
" oValueDiv.onmouseout = function() {this.style.background = '';};" & @CRLF & _
" g_sFullName = true; " & @CRLF & _
" }" & @CRLF & _
" } " & @CRLF & _
"" & @CRLF & _
" // Constructor" & @CRLF & _
" Initialize();" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"function setBackground(path)" & @CRLF & _
"{" & @CRLF & _
" // if you switch backgrounds on the fly, you must set the style size to zero" & @CRLF & _
" // so it dynamically refreshes" & @CRLF & _
" currencybackground.style.width = 0;" & @CRLF & _
" currencybackground.style.height = 0;" & @CRLF & _
" currencybackground.src = path;" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Add currency row" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function addRow()" & @CRLF & _
"{" & @CRLF & _
" if (g_sRowCount < 3)" & @CRLF & _
" {" & @CRLF & _
" g_sRowCount++;" & @CRLF & _
" document.getElementById('curr'+g_sRowCount).style.display = 'block';" & @CRLF & _
" document.body.style.height = parseInt(document.body.style.height) + g_sRowHeight; " & @CRLF & _
" setBackground("url(images/base-undocked-"+(g_sRowCount+1)+".png)");" & @CRLF & _
" saveSetting('rowCount', g_sRowCount);" & @CRLF & _
" document.getElementById('currencySelect').size += 4;" & @CRLF & _
" if ( g_oService.IsAvailable )" & @CRLF & _
" {" & @CRLF & _
" loadSettings();" & @CRLF & _
" }" & @CRLF & _
" } " & @CRLF & _
" " & @CRLF & _
" // "Deactivate" add link if max rows reached" & @CRLF & _
" if (g_sRowCount >= (g_oCurr.length - 1))" & @CRLF & _
" {" & @CRLF & _
" addButton.style.display = 'none';" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Remove currency row" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function deleteRow(sControlId)" & @CRLF & _
"{" & @CRLF & _
" var sOptionCount = sControlId.replace('curr', '');" & @CRLF & _
" // Must not delete if only 2 rows" & @CRLF & _
" if(sOptionCount ==0 || g_sRowCount < 2)" & @CRLF & _
" {" & @CRLF & _
" return false;" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" sOptionCount *= 1;" & @CRLF & _
"" & @CRLF & _
" document.getElementById('curr'+g_sRowCount).style.display = 'none';" & @CRLF & _
" document.getElementById(sControlId+'DeleteButton').style.display = 'none';" & @CRLF & _
" document.body.style.height = parseInt(document.body.style.height) - g_sRowHeight;" & @CRLF & _
" " & @CRLF & _
" currencybackground.style.width = 0;" & @CRLF & _
" currencybackground.style.height = 0;" & @CRLF & _
" currencybackground.src = "url(images/base-undocked-"+(g_sRowCount)+".png)";" & @CRLF & _
" " & @CRLF & _
" for (i = sOptionCount; i < g_sRowCount; i++)" & @CRLF & _
" {" & @CRLF & _
" saveSetting('curr'+i, readSetting('curr'+(i+1)));" & @CRLF & _
" saveSetting('curr'+(i+1), L_localizedStrings_Text['default'+(i+1)]);" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" g_sRowCount--;" & @CRLF & _
" " & @CRLF & _
" // "Activate" add link if it was greyed out" & @CRLF & _
" if (g_sRowCount <= (g_oCurr.length - 2))" & @CRLF & _
" {" & @CRLF & _
" addButton.style.display = 'block';" & @CRLF & _
" }" & @CRLF & _
" saveSetting('rowCount', g_sRowCount);" & @CRLF & _
" document.getElementById('currencySelect').size -= 4;" & @CRLF & _
" if ( g_oService.IsAvailable )" & @CRLF & _
" {" & @CRLF & _
" loadSettings();" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Show row deletion button" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function showDelete(sControlId)" & @CRLF & _
"{" & @CRLF & _
" if (sControlId != 'curr0' && g_sRowCount > 1)" & @CRLF & _
" {" & @CRLF & _
" document.getElementById(sControlId + 'DeleteButton').style.display = 'block';" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Hide row deletion button" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function hideDelete(sControlId)" & @CRLF & _
"{" & @CRLF & _
" document.getElementById(sControlId + 'DeleteButton').style.display = 'none';" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Show Currency List" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function showCurrencyList(sControlId)" & @CRLF & _
"{" & @CRLF & _
" " & @CRLF & _
" var currencyList = new Array();" & @CRLF & _
" var oSelect = document.getElementById('CurrencySelect');" & @CRLF & _
" " & @CRLF & _
" // Clear list" & @CRLF & _
" oSelect.innerHTML = "";" & @CRLF & _
" " & @CRLF & _
" oSelect.onkeypress = function() {if(event.keyCode == 13){optionsDown(CurrencySelect.options[CurrencySelect.selectedIndex].id);}};" & @CRLF & _
" " & @CRLF & _
" // Set up function for creating currencyList object" & @CRLF & _
" function createCurrency(currSymbol, currText, currTextForSorting)" & @CRLF & _
" {" & @CRLF & _
" this.currSymbol = currSymbol;" & @CRLF & _
" this.currText = currText;" & @CRLF & _
" this.currTextForSorting = currTextForSorting;" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" // Set up sort function" & @CRLF & _
" function currencySort(x, y)" & @CRLF & _
" {" & @CRLF & _
" var xTemp = x.currText;" & @CRLF & _
" var yTemp = y.currText;" & @CRLF & _
" " & @CRLF & _
" if (xTemp > yTemp)" & @CRLF & _
" {" & @CRLF & _
" return 1;" & @CRLF & _
" }" & @CRLF & _
" else if (xTemp < yTemp)" & @CRLF & _
" {" & @CRLF & _
" return -1;" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" return 0;" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" // Iterate through symbol list returned from currency service and create currencyList" & @CRLF & _
" for (x in g_oService.hsCurrencies)" & @CRLF & _
" {" & @CRLF & _
" var currency = g_oService.hsCurrencies[x];" & @CRLF & _
" currencyList.push(new createCurrency(currency.Symbol, getLocalizedString(currency.Symbol), currency.NameForSorting));" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" // Sort currency list" & @CRLF & _
" currencyList.sort(currencySort);" & @CRLF & _
" " & @CRLF & _
" // Iterate through sorted list and create options" & @CRLF & _
" for (var i = 0; i < currencyList.length; i++)" & @CRLF & _
" {" & @CRLF & _
" var oEachOption = document.createElement('option');" & @CRLF & _
" oEachOption.id = sControlId + "-" + currencyList[i].currSymbol;" & @CRLF & _
" oEachOption.innerText = currencyList[i].currText;" & @CRLF & _
" oSelect.appendChild(oEachOption); " & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" //Selecting the current currency" & @CRLF & _
" document.getElementById(sControlId + '-' + g_oCurr[sControlId.replace('curr', '')].oTag.Symbol).selected = true;" & @CRLF & _
" " & @CRLF & _
" // Display the Currency List" & @CRLF & _
" var d = document.getElementById('currencyList');" & @CRLF & _
" d.style.display = 'block';" & @CRLF & _
" CurrencySelect.focus();" & @CRLF & _
"}" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Close menu when option is selected" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function optionsDown(sOptionID)" & @CRLF & _
"{" & @CRLF & _
" saveOptions(sOptionID);" & @CRLF & _
" if ( g_oService.IsAvailable )" & @CRLF & _
" {" & @CRLF & _
" loadSettings();" & @CRLF & _
" }" & @CRLF & _
" currencyList.style.display = 'none';" & @CRLF & _
"}" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Save newly selected option" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function saveOptions(sOptionID)" & @CRLF & _
"{" & @CRLF & _
" var oOptionID = sOptionID.split('-');" & @CRLF & _
" saveSetting(oOptionID[0], oOptionID[1]); " & @CRLF & _
" g_oCurr[oOptionID[0].replace('curr', '')].oTextBox.focus();" & @CRLF & _
"}" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Data for gadget in docked state" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function DockGadget()" & @CRLF & _
"{" & @CRLF & _
" var oBody = document.body.style;" & @CRLF & _
" oBody.width = '130px';" & @CRLF & _
" oBody.height = '83px';" & @CRLF & _
" " & @CRLF & _
" currencybackground.style.width = 0;" & @CRLF & _
" currencybackground.style.height = 0;" & @CRLF & _
" currencybackground.src = "url(images/base-docked.png)";" & @CRLF & _
" " & @CRLF & _
" for (var i = g_sRowCount; i > 1; i--)" & @CRLF & _
" {" & @CRLF & _
" document.getElementById('curr'+i).style.display = 'none';" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" for (var i=0; i < g_oCurr.length; i++)" & @CRLF & _
" {" & @CRLF & _
" g_oCurr[i].changeMode('docked');" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" container.className = 'dockedUIBoundary';" & @CRLF & _
" message.className = 'dockedMessage';" & @CRLF & _
" " & @CRLF & _
" if(document.dir == 'rtl')" & @CRLF & _
" {" & @CRLF & _
" ageStampText.className = 'ageStampTextDockedModeRtl';" & @CRLF & _
" ageStampTextTd.className = 'ageStampTextUndockedModeRtl'" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" ageStampText.className = 'ageStampTextDockedMode';" & @CRLF & _
" ageStampTextTd.className = 'ageStampTextUndockedMode'" & @CRLF & _
" }" & @CRLF & _
" document.getElementById('ageStampText').innerText = g_ageStampText;" & @CRLF & _
" document.getElementById('ageStampText').style.visibility = "hidden";" & @CRLF & _
" document.getElementById('ageStampTextTd').innerText = g_ageStampText;" & @CRLF & _
" document.getElementById('ageStampTextTd').style.visibility = "hidden";" & @CRLF & _
" " & @CRLF & _
" if (g_oService.IsAvailable)" & @CRLF & _
" {" & @CRLF & _
" if(g_isStaleData)" & @CRLF & _
" {" & @CRLF & _
" document.getElementById('ageStampText').style.visibility = "visible";" & @CRLF & _
" }" & @CRLF & _
" updateValues(g_oCurr[0].oTextBox, false);" & @CRLF & _
" }" & @CRLF & _
" bottomTable.style.display = 'none';" & @CRLF & _
" addButton.style.display = 'none';" & @CRLF & _
"}" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Data for gadget in undocked state" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function UndockGadget()" & @CRLF & _
"{" & @CRLF & _
" var oBody = document.body.style;" & @CRLF & _
" oBody.width = '254px';" & @CRLF & _
" oBody.height = (g_sBodyHeight - g_sRowHeight) + (g_sRowCount * g_sRowHeight);" & @CRLF & _
" " & @CRLF & _
" currencybackground.style.width = 0;" & @CRLF & _
" currencybackground.style.height = 0;" & @CRLF & _
" currencybackground.src = "url(images/base-undocked-"+(g_sRowCount+1)+".png)";" & @CRLF & _
" " & @CRLF & _
" for (var i = g_sRowCount; i > 1; i--)" & @CRLF & _
" {" & @CRLF & _
" document.getElementById('curr'+i).style.display = 'block';" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" for (var i=0; i < g_oCurr.length; i++)" & @CRLF & _
" {" & @CRLF & _
" g_oCurr[i].changeMode('undocked');" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" container.className = 'UIBoundary';" & @CRLF & _
" dataLink.className = 'dataProviderLink';" & @CRLF & _
" message.className = 'message';" & @CRLF & _
" " & @CRLF & _
" if(document.dir == 'rtl')" & @CRLF & _
" {" & @CRLF & _
" ageStampText.className = 'ageStampTextDockedModeRtl';" & @CRLF & _
" ageStampTextTd.className = 'ageStampTextUndockedModeRtl'" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" ageStampText.className = 'ageStampTextDockedMode';" & @CRLF & _
" ageStampTextTd.className = 'ageStampTextUndockedMode'" & @CRLF & _
" }" & @CRLF & _
" document.getElementById('ageStampText').innerText = g_ageStampText;" & @CRLF & _
" document.getElementById('ageStampText').style.visibility = "hidden";" & @CRLF & _
" document.getElementById('ageStampTextTd').innerText = g_ageStampText;" & @CRLF & _
" document.getElementById('ageStampTextTd').style.visibility = "hidden";" & @CRLF & _
" " & @CRLF & _
" if (g_oService.IsAvailable)" & @CRLF & _
" {" & @CRLF & _
" if(g_isStaleData)" & @CRLF & _
" {" & @CRLF & _
" document.getElementById('ageStampTextTd').style.visibility = "visible";" & @CRLF & _
" }" & @CRLF & _
" updateValues(g_oCurr[0].oTextBox, false);" & @CRLF & _
" bottomTable.style.display = 'block';" & @CRLF & _
" if(g_sRowCount<3)" & @CRLF & _
" {" & @CRLF & _
" addButton.style.display = 'block';" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" " & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Fire update function on keyup" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function OnAmountChange()" & @CRLF & _
"{" & @CRLF & _
" var sourceTextBox = event.srcElement;" & @CRLF & _
"" & @CRLF & _
" updateValues(sourceTextBox, true);" & @CRLF & _
"}" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Update currency field values" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function updateValues(sourceTextBox,bSkipCurrent)" & @CRLF & _
"{ " & @CRLF & _
" if (g_oService.IsAvailable)" & @CRLF & _
" {" & @CRLF & _
" // Get the currency object that goes with this text box" & @CRLF & _
" var sourceCurrency = g_oCurr[sourceTextBox.getAttribute('arrayIdx')];" & @CRLF & _
" " & @CRLF & _
" var oCurrency;" & @CRLF & _
" " & @CRLF & _
" for (var i=0; i < g_oCurr.length; i++)" & @CRLF & _
" {" & @CRLF & _
" oCurrency = g_oCurr[i];" & @CRLF & _
" " & @CRLF & _
" // skip the box where the text changed." & @CRLF & _
" if(bSkipCurrent)" & @CRLF & _
" {" & @CRLF & _
" if (sourceTextBox != oCurrency.oTextBox)" & @CRLF & _
" {" & @CRLF & _
" try" & @CRLF & _
" {" & @CRLF & _
" oCurrency.oTextBox.value = g_oService.Convert(sourceTextBox.value, sourceCurrency.oTag.Symbol, oCurrency.oTag.Symbol);" & @CRLF & _
" }" & @CRLF & _
" catch(objError)" & @CRLF & _
" {" & @CRLF & _
" oCurrency.oTextBox.value = getLocalizedString('Error');" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" try" & @CRLF & _
" {" & @CRLF & _
" oCurrency.oTextBox.value = g_oService.Convert(sourceTextBox.value, sourceCurrency.oTag.Symbol, oCurrency.oTag.Symbol);" & @CRLF & _
" }" & @CRLF & _
" catch(objError)" & @CRLF & _
" {" & @CRLF & _
" oCurrency.oTextBox.value = getLocalizedString('Error');" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Set UI state" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function SetUIState(sState)" & @CRLF & _
"{" & @CRLF & _
" function ShowMessage(sMessage)" & @CRLF & _
" {" & @CRLF & _
" showOrHide('container', false);" & @CRLF & _
" showOrHide('message', true); " & @CRLF & _
" " & @CRLF & _
" }" & @CRLF & _
" document.getElementById('bottomTable').style.display = 'none';" & @CRLF & _
" " & @CRLF & _
" document.getElementById('ageStampText').innerText = g_ageStampText;" & @CRLF & _
" document.getElementById('ageStampText').style.visibility = "hidden";" & @CRLF & _
" document.getElementById('ageStampTextTd').innerText = g_ageStampText;" & @CRLF & _
" document.getElementById('ageStampTextTd').style.visibility = "hidden";" & @CRLF & _
" " & @CRLF & _
" spinner.stop();" & @CRLF & _
" switch(sState)" & @CRLF & _
" {" & @CRLF & _
" " & @CRLF & _
" case 'loading':" & @CRLF & _
" " & @CRLF & _
" spinner.show();" & @CRLF & _
" spinner.start();" & @CRLF & _
" document.getElementById('messageSpinner').style.display = 'inline';" & @CRLF & _
" document.getElementById('messageIcon').style.display = 'none';" & @CRLF & _
" ShowMessage(getLocalizedString('WaitText'));" & @CRLF & _
" document.getElementById('messageText').innerHTML = getLocalizedString('WaitText');" & @CRLF & _
" break;" & @CRLF & _
" " & @CRLF & _
" case 'error':" & @CRLF & _
" " & @CRLF & _
" document.getElementById('messageIcon').style.display = 'inline';" & @CRLF & _
" document.getElementById('messageSpinner').style.display = 'none';" & @CRLF & _
" ShowMessage(getLocalizedString('ServiceNotAvailable'));" & @CRLF & _
" if(document.dir == 'rtl')" & @CRLF & _
" {" & @CRLF & _
" document.getElementById('messageText').innerHTML = getLocalizedString('ServiceNotAvailable');" & @CRLF & _
" document.getElementById('messageText').style.textAlign = 'right';" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" document.getElementById('messageText').innerHTML = getLocalizedString('ServiceNotAvailable');" & @CRLF & _
" document.getElementById('messageText').style.textAlign = 'left';" & @CRLF & _
" }" & @CRLF & _
" break;" & @CRLF & _
" " & @CRLF & _
" case 'ready':" & @CRLF & _
" showOrHide('container', true);" & @CRLF & _
" showOrHide('message', false);" & @CRLF & _
" if (!System.Gadget.docked)" & @CRLF & _
" {" & @CRLF & _
" document.getElementById('bottomTable').style.display = 'block';" & @CRLF & _
" } " & @CRLF & _
" break;" & @CRLF & _
" " & @CRLF & _
" case 'cached':" & @CRLF & _
" showOrHide('container', true);" & @CRLF & _
" showOrHide('message', false);" & @CRLF & _
" if (!System.Gadget.docked)" & @CRLF & _
" {" & @CRLF & _
" document.getElementById('bottomTable').style.display = 'block';" & @CRLF & _
" document.getElementById('ageStampTextTd').style.visibility = "visible";" & @CRLF & _
" } " & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" document.getElementById('ageStampText').style.visibility = "visible";" & @CRLF & _
" }" & @CRLF & _
" break;" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Check for availability of data" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function DataReady(data)" & @CRLF & _
"{" & @CRLF & _
" var milliSecondsToNextQuery;" & @CRLF & _
" " & @CRLF & _
" g_dataFromService = data;" & @CRLF & _
" g_isStaleData = false;" & @CRLF & _
" g_ageStampText = "";" & @CRLF & _
" " & @CRLF & _
" if (g_oTimer != null)" & @CRLF & _
" clearTimeout(g_oTimer);" & @CRLF & _
"" & @CRLF & _
" if ((data != null) && g_oService.IsAvailable && (data.Count > 0) && ((data.RetCode == 200) || (data.RetCode == 1507)))" & @CRLF & _
" {" & @CRLF & _
" if (data.RetCode == 200)" & @CRLF & _
" {" & @CRLF & _
" var serviceRefreshInterval;" & @CRLF & _
" " & @CRLF & _
" gTimeStampLastRefreshAvailable = true;" & @CRLF & _
" gTimeStampLastRefresh = data.Timestamp;" & @CRLF & _
"" & @CRLF & _
" SetUIState('ready');" & @CRLF & _
" loadSettings();" & @CRLF & _
" " & @CRLF & _
" serviceRefreshInterval = g_oService.RefreshInterval();" & @CRLF & _
" if (serviceRefreshInterval != -1)" & @CRLF & _
" {" & @CRLF & _
" // Update the UI after refresh interval" & @CRLF & _
" milliSecondsToNextQuery = 1000 * 60 * serviceRefreshInterval;" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" // Update the UI in 1 minute" & @CRLF & _
" milliSecondsToNextQuery = 1000 * 60;" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" g_isStaleData = true;" & @CRLF & _
" g_ageStampText = calculateAgeStampText(calculateAge(data.Timestamp));" & @CRLF & _
" SetUIState('cached');" & @CRLF & _
" loadSettings();" & @CRLF & _
" // Update the UI in 1 minute" & @CRLF & _
" milliSecondsToNextQuery = 1000 * 60;" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" SetUIState('error');" & @CRLF & _
" // Try again in 1 minute" & @CRLF & _
" milliSecondsToNextQuery = 1000 * 60;" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" g_oTimer = setTimeout('g_oService.GetCurrencies()', milliSecondsToNextQuery);" & @CRLF & _
"}" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Load currency symbols for each currency row" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function loadSettings()" & @CRLF & _
"{" & @CRLF & _
" " & @CRLF & _
" for (i = 0; i < g_oCurr.length; i++)" & @CRLF & _
" {" & @CRLF & _
" var sCurr = readSetting('curr'+i) || L_localizedStrings_Text['default'+i];" & @CRLF & _
" saveSetting('curr'+i, sCurr);" & @CRLF & _
" " & @CRLF & _
" g_oCurr[i].oTag = g_oService.hsCurrencies[sCurr];" & @CRLF & _
" " & @CRLF & _
" //Get first available if list of currency is not complete" & @CRLF & _
" if(g_oCurr[i].oTag == undefined)" & @CRLF & _
" {" & @CRLF & _
" sCurr = g_dataFromService.Item(0).Symbol;" & @CRLF & _
" g_oCurr[i].oTag = g_oService.hsCurrencies[sCurr]; " & @CRLF & _
" } " & @CRLF & _
" " & @CRLF & _
" if (g_sFullName){" & @CRLF & _
" g_oCurr[i].setCaption(g_oService.hsCurrencies[sCurr].Name);" & @CRLF & _
" } else {" & @CRLF & _
" g_oCurr[i].setCaption(g_oCurr[i].oTag.Symbol);" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" var sURLLocale = '';" & @CRLF & _
" if (g_oCurr[i].oTag.Symbol != 'USD')" & @CRLF & _
" {" & @CRLF & _
" sURLLocale = g_oCurr[i].oTag.Symbol;" & @CRLF & _
" }" & @CRLF & _
" document.getElementById('curr'+i+'OnlineButtonA').href = getLocalizedString('CurrencyLink')+sURLLocale+'USD';" & @CRLF & _
" " & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" updateValues(g_oCurr[0].oTextBox, false);" & @CRLF & _
"}" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Handle ESCAPE and ENTER keydown" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function OnKeyDownHandler()" & @CRLF & _
"{" & @CRLF & _
" if(event.keyCode == 27)//ESCAPE key" & @CRLF & _
" {" & @CRLF & _
" document.getElementById('currencyList').style.display = 'none'; " & @CRLF & _
" } " & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Spinner Animation" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function getSpinner( spinnerDivID ) " & @CRLF & _
"{" & @CRLF & _
" var self = this;" & @CRLF & _
" this.id = spinnerDivID;" & @CRLF & _
" this.parentDiv = document.getElementById( self.id );" & @CRLF & _
" this.fps = 1000/30; " & @CRLF & _
" with (this.parentDiv.style) {" & @CRLF & _
" fontSize=0;" & @CRLF & _
" posWidth=16;" & @CRLF & _
" posHeight=16;" & @CRLF & _
" backgroundImage = 'url("images/activity16v.png")';" & @CRLF & _
" backgroundPositionY = 0;" & @CRLF & _
" }" & @CRLF & _
" this.hide = function() { self.parentDiv.style.display='none'; }" & @CRLF & _
" this.show = function() { self.parentDiv.style.display='block'; }" & @CRLF & _
" this.stop = function() { clearInterval( self.animationInterval ); }" & @CRLF & _
" this.start = function() {" & @CRLF & _
" clearInterval( self.animationInterval );" & @CRLF & _
" this.animationInterval = setInterval( 'animate(' + self.id + ')', 30 );" & @CRLF & _
" }" & @CRLF & _
"} " & @CRLF & _
"" & @CRLF & _
"function animate(spinnerDiv) " & @CRLF & _
"{" & @CRLF & _
" spinnerDiv.style.backgroundPositionY=parseInt(spinnerDiv.style.backgroundPositionY)-16; " & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"//" & @CRLF & _
"// Handle RightClick" & @CRLF & _
"//" & @CRLF & _
"////////////////////////////////////////////////////////////////////////////////" & @CRLF & _
"function OnRightClickHandler()" & @CRLF & _
"{" & @CRLF & _
" if(event.srcElement.tagName != 'INPUT')" & @CRLF & _
" {" & @CRLF & _
" if(event.button > 1)" & @CRLF & _
" {" & @CRLF & _
" var selectedText = document.getElementById('curr0input').createTextRange();" & @CRLF & _
" selectedText.moveStart('character', document.getElementById('curr0input').value.length); " & @CRLF & _
" selectedText.select();" & @CRLF & _
" event.srcElement.focus(); " & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" return true;" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"function calculateAge ( timestamp )" & @CRLF & _
"{" & @CRLF & _
" var timestampDay = new Date( timestamp );" & @CRLF & _
" var currentDay = new Date();" & @CRLF & _
" " & @CRLF & _
" var millisecondsTillTimestamp = Date.parse( timestamp );" & @CRLF & _
" var millisecondsTillNow = (new Date()).getTime();" & @CRLF & _
" var minutesDifference = parseInt( ( millisecondsTillNow - millisecondsTillTimestamp ) / ( 60 * 1000 ) );" & @CRLF & _
" var hoursDifference = parseInt ( minutesDifference / 60 );" & @CRLF & _
" var daysDifference = parseInt ( hoursDifference / 24 );" & @CRLF & _
" " & @CRLF & _
" this.minutesAge = 0;" & @CRLF & _
" this.hoursAge = 0;" & @CRLF & _
" this.daysAge = 0;" & @CRLF & _
" " & @CRLF & _
" if ( minutesDifference <= 0 )" & @CRLF & _
" {" & @CRLF & _
" return this;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" // shows hours and mins only for the same day" & @CRLF & _
" if ( timestampDay.getDate() == currentDay.getDate()" & @CRLF & _
" && timestampDay.getMonth() == currentDay.getMonth()" & @CRLF & _
" && timestampDay.getFullYear() == currentDay.getFullYear() )" & @CRLF & _
" {" & @CRLF & _
" this.minutesAge = minutesDifference % 60;" & @CRLF & _
" this.hoursAge = hoursDifference % 24;" & @CRLF & _
" this.daysAge = daysDifference;" & @CRLF & _
" }" & @CRLF & _
" else // only calculate total no of days past" & @CRLF & _
" {" & @CRLF & _
" timestampDay.setHours(currentDay.getHours(),currentDay.getMinutes(),currentDay.getSeconds(),currentDay.getMilliseconds());" & @CRLF & _
" this.daysAge = parseInt ( ( currentDay.getTime() - timestampDay.getTime() ) / ( 60 * 1000 * 60 * 24 ) );" & @CRLF & _
" if ( this.daysAge < 0 )" & @CRLF & _
" {" & @CRLF & _
" this.daysAge = 0;" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" return this;" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"function calculateAgeStampText( age )" & @CRLF & _
"{" & @CRLF & _
" var ageStampText = "";" & @CRLF & _
" var unitText = "";" & @CRLF & _
" var durationText = "";" & @CRLF & _
" " & @CRLF & _
" if ( age.daysAge > 0 )" & @CRLF & _
" {" & @CRLF & _
" durationText = getLocalizedString('day');" & @CRLF & _
" if ( age.daysAge > 1 )" & @CRLF & _
" {" & @CRLF & _
" durationText = getLocalizedString('days');" & @CRLF & _
" }" & @CRLF & _
" unitText = age.daysAge;" & @CRLF & _
" }" & @CRLF & _
" else if ( age.hoursAge > 0 )" & @CRLF & _
" {" & @CRLF & _
" durationText = getLocalizedString('hr');" & @CRLF & _
" if ( age.hoursAge > 1 )" & @CRLF & _
" {" & @CRLF & _
" durationText = getLocalizedString('hrs');" & @CRLF & _
" }" & @CRLF & _
" unitText = age.hoursAge;" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" if ( age.minutesAge != 0 )" & @CRLF & _
" {" & @CRLF & _
" durationText = getLocalizedString('min');" & @CRLF & _
" unitText = age.minutesAge;" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" if((unitText != "") && (durationText != ""))" & @CRLF & _
" {" & @CRLF & _
" ageStampText = getLocalizedString('ageStampMessage')" & @CRLF & _
" ageStampText = ageStampText.replace("%1", unitText);" & @CRLF & _
" ageStampText = ageStampText.replace("%2", durationText);" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" return ageStampText;" & @CRLF & _
"}" & @CRLF & _
""
Local $sSubst = "$2"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm