From 5e2af0fdbc430511399c76e61f60f236805599a7 Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Sat, 21 Sep 2019 16:35:52 +0200 Subject: [PATCH] Json BG loader Readet and working --- app/templates/js/script.js | 60 +++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/app/templates/js/script.js b/app/templates/js/script.js index 31195a1..420409a 100644 --- a/app/templates/js/script.js +++ b/app/templates/js/script.js @@ -182,36 +182,36 @@ $( '[name="room"]' ).change(function (e) { }); -// var windowLoc = $(location).attr('pathname'); -// windowLoc = windowLoc.substring(windowLoc.lastIndexOf("/")); -// console.log(); -// if (windowLoc == "/") { -// var autoUpdate = setInterval(function(){ -// $.ajax({ -// url: 'ajax', -// type: 'POST', -// dataType: 'json', -// data: { -// "action": 'getState' -// }, -// success: function(data){ -// // console.log('DATA: ', data); -// for (const key in data) { -// if (data.hasOwnProperty(key)) { -// const device = data[key]; -// $('[data-sub-device-id="'+key+'"]') -// .find('.device-button-value') -// .text(device['value']) -// .attr('title',device['time']) -// } -// } -// }, -// error: function (request, status, error) { -// console.log("ERROR ajaxChart():", request, error); -// } -// }); -// },2000); -// } +var windowLoc = $(location).attr('pathname'); +windowLoc = windowLoc.substring(windowLoc.lastIndexOf("/")); +console.log(); +if (windowLoc == "/") { + var autoUpdate = setInterval(function(){ + $.ajax({ + url: 'ajax', + type: 'POST', + dataType: 'json', + data: { + "action": 'getState' + }, + success: function(data){ + console.log(data); + for (const key in data) { + if (data.hasOwnProperty(key)) { + const device = data[key]; + $('[data-sub-device-id="'+key+'"]') + .find('.device-button-value') + .text(device['value']) + .attr('title',device['time']) + } + } + }, + error: function (request, status, error) { + console.log("ERROR ajaxChart():", request, error); + } + }); + },2000); +}