toastr.options = { "positionClass": "toast-bottom-right" }; var priceData = ""; //get the dataset $(document).ready(function() { $.ajax({ type: "GET", url: "https://api.fairplayground.info/rawdata/faircoin_prices.csv", dataType: "text", success: processData }); $('#inputFaircoin').on('input', calculateEuros); $('#inputEuro').on('input', calculateFaircoins); $('#inputDate').on('input', calculateEuros); var strDate = new Date().toISOString().slice(0,10); $('#inputDate').val(strDate); }); function csvToArray(csv) { var a1 = csv.split("\n"); var r = []; for(var i=0; i" + faircoins + " FAIR were worth " + euros + " €"; toastr.success(faircoins + " FAIR were " + euros + " €"); } function calculateFaircoins() { document.getElementById("result").innerHTML=""; var euros = document.getElementById("inputEuro").value; var date = document.getElementById("inputDate").value; if(!euros){ toastr.warning("please, fill the euro input box"); return; } if(!date){ toastr.warning("no date"); return; } //let's find the date in the priceData var selectedPriceData = [] for(var i=0; i" + euros + " € were worth " + faircoins + " FAIR"; toastr.success(euros + "€ were " + faircoins + " FAIR"); }