function get_json_from_list(str){ /* Format placeholers results and return a dictionary */ str = str.replace('', '') str = str.replace('', '') var reg = /(\d*)<\/entry>/gi; var line; var result = []; while((line = reg.exec(str)) !== null) { result[line[1]] = line[2]; } return result } function init_currency_conversion(currency_default){ /* Convert currency of element */ var spans = document.getElementsByClassName("dynamic-currency"); for (var i = 0; i < spans.length; i++) { let item = spans.item(i) let amount = item.dataset.amount || null let convert_to = item.dataset.convertTo || currency_default if (amount==null) return result = amount * window.currency_conversion_from_eur[convert_to] item.innerHTML = `${result} ${convert_to}` } } window.onload = function() { var arr_currencies = ''; var currency_default = 'EUR'; window.currency_conversion_from_eur = get_json_from_list(arr_currencies); init_currency_conversion(currency_default); };