send Data to Server

This commit is contained in:
schrom01 2023-02-15 00:06:36 +01:00
parent 8a1a7d19b5
commit a9cad34e71
1 changed files with 17 additions and 1 deletions

View File

@ -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))
}