import QtQuick 2.0 Item { property var data; property var day_cache; signal loaded(); property bool is_loaded; id: root function measure(title, fn){ const ts = new Date().getTime(); fn(); const te = new Date().getTime(); console.log(title, te-ts, "ms"); } function refresh(callback){ log.text = "Wczytywanie..." is_loaded = false; data = []; day_cache = {} console.log("making request..."); http.get("https://solar.kuba-orlik.name/data.csv", function(text){ console.log("got response!"); background.send("newdata", text, function(data){ is_loaded = true; const update_time = new Date(data[data.length-2]); log.text = "Aktualna produkcja: " + data[data.length-2][1] + "W\nDane z " + update_time.getHours() + ":" + (update_time.getMinutes() < 10 ? "0" : "") + update_time.getMinutes(); root.loaded(); callback(); }) }) } function getForDay(day, month, year, callback){ background.send("get-for-day", {day, month, year}, callback) } }