diff --git a/js/functions.js b/js/functions.js index 51ff018..40719de 100644 --- a/js/functions.js +++ b/js/functions.js @@ -192,10 +192,26 @@ function saveActualTopicName() { function saveActualTopic() { //save it to LocalStorage localStorage.setItem("actualTopic", JSON.stringify(actualTopic)) + + //save it to Server + fetch(document.URL + "dataCollector/dataCollector.php", { + method: 'POST', + headers: { 'Content-type': 'application/json' }, + body: JSON.stringify({ + "lastSave": new Date().getTime(), + "timeWatchM": sumForWatch(actualTopic.watches[0]), + "timeWatchW": sumForWatch(actualTopic.watches[1]), + "timeWatchD": sumForWatch(actualTopic.watches[2]), + "countWatchM": countForWatch(actualTopic.watches[0]), + "countWatchW": countForWatch(actualTopic.watches[1]), + "countWatchD": countForWatch(actualTopic.watches[2]), + "id": actualTopic.id, + "watches": actualTopic.watches + }) + }); } function saveClosedTopics() { - //save it to LocalStorage localStorage.setItem("closedTopics", JSON.stringify(closedTopics)) }