/* * you have to specify path to xml file, * script work only if you specify correct path to xml file on server * script does not work without web server * * */ /*--------path---------------*/ /*example absolute path*/ //var hostURL = 'http://example.com/rateswithcss.xml' /*example relative path - can be use if xml file is located in current project*/ var hostURL = 'rateswithcss.xml'; /*--------refresh time-------*/ var timeRef = 1*60*1000; // 1*60*1000 - 1 minute var timeUpdateDate = true;//true or false - display or not time update date /*--column option--*/ /*you can specify column for display - true or false*/ var displayColFlag = true;//true or false var displayColCode = true;//true or false var displayColCurrency = true;//true or false var displayColCountry = true;//true or false var displayColWeBuy = true;//true or false var displayColWeSell = true;//true or false var displayColINVBuy = false;//true or false var displayColINVSell = false;//true or false /*---------------------*/ jQuery(document).ready(function($){ /**--column option--*/ if (displayColFlag === false) { $('.flag').remove(); } if (displayColCode === false) { $('.code').remove(); } if (displayColCurrency === false) { $('.cur').remove(); } if (displayColWeBuy === false) { $('.buy').remove(); } if (displayColWeSell === false) { $('.sell').remove(); } if (displayColINVBuy === false) { $('.invbuy').remove(); } if (displayColINVSell === false) { $('.invsell').remove(); } if (displayColCountry === false) { $('.country').remove(); } /*----*/ currency_rates(); /**refresh rates table*/ setInterval(function() { currency_rates(); }, timeRef ); }); /** * Window Resize * */ jQuery(window).resize(function(){ currency_rates(); }); function currency_rates(){ $.ajax({ type: "POST", url: hostURL, dataType: "xml", success: function(xml) { success_load(xml); }, error: function(request, status, error){ var statusCode = request.status; if (statusCode === 0){ window.location.reload(); console.log('currency_rates() - erorr : 0'); } } }); } function success_load(xml) { /**updating info from XML file **/ var timeUpdate = ''; $(xml).find('TIMESTAMP').each(function () { if(timeUpdateDate === true){ timeUpdate += $(this).text(); } }); $('.time_update').html(timeUpdate); /**writing data from XML file into rates board **/ var rateRows = ''; var iCount = 0; $(xml).find('RATE').each(function () { if ($(this).find('ISFLAGGED').text() === '*') { /**for styles*/ var row_class = (iCount % 2 === 0) ? 'row_even': 'row_odd'; var name_alts = new Object(); name_alts['USD'] = 'United States'; name_alts['EUR'] = 'Euro Members'; name_alts['XPF'] = 'French Polynesian'; var country_name = $(this).find('COUNTRY').text(); var iso = $(this).find('ISO').text(); if (iso in name_alts) { // country_name = name_alts[iso]; } /**rate row*/ rateRows +='