// fetch("http://192.168.1.105:8000/devices_list") // .then(function(response){ // return response.json(); // }) // .then(function(data){ // appendData(data); // }) // .catch(function(err){ // console.log(err); // }); // function appendData(data){ // console.log(data); // console.log(data[1]["files"][0]); // var myJson = JSON.stringify(data[1]["description"]["description_s"]); // var myJson1 = JSON.stringify(data[1]["description"]["title"]); // var myJson2 = JSON.stringify(data[1]["description"]["description_l"]); // var uJson = myJson.replace(/\"/g, ""); // var str = (uJson); // var str_esc = escape(str); // console.log(str_esc + "
" + myJson1); // console.log(unescape(str_esc)); // var mainContainer = document.getElementById("hou1"); // var div = document.createElement("div"); // div.setAttribute("id", "hou"); // div.innerHTML = unescape(str_esc); // mainContainer.appendChild(div); // var mainContainer1 = document.getElementById("hey1"); // var uJson1 = myJson1.replace(/\"/g, ""); // var div1 = document.createElement("div"); // div1.setAttribute("id", "hey"); // div1.innerHTML = unescape(escape(uJson1)); // var uJson1 = myJson1.replace(/\"/g, ""); // mainContainer1.appendChild(div1); // } $(document).ready(function() { let urls = ["http://192.168.1.105:8000/files/0/library.jpg", "http://192.168.1.105:8000/files/0/library.jpg", "http://192.168.1.105:8000/files/0/library.jpg"]; let descriptions = ["here", "there"]; let n = 1; function append_element(urls, descriptions, n) { let template = `
#
#
${descriptions[0]}
Teplota
#
${descriptions[1]}
`; $("body").append(template); } append_element(urls, descriptions, n); $.get("http://192.168.1.105:8000/devices_list", function(data) { console.log(data); var myJson = JSON.stringify(data[1]["description"]["description_s"]); var myJson1 = JSON.stringify(data[1]["description"]["title"]); console.log(myJson); console.log(myJson1); uJson = myJson.replace(/\"/g, ""); var str = (uJson); var str_esc = escape(str); console.log(str_esc + "
" + myJson); console.log(unescape(str_esc)); var main = document.getElementById("hou1"); var div = document.createElement("div"); div.setAttribute("id", "hou"); div.innerHTML = unescape(str_esc); main.appendChild(div); var sub = document.getElementById("hey1"); var uJson1 = myJson1.replace(/\"/g, ""); var div1 = document.createElement("div"); div1.setAttribute("id", "hey"); div1.innerHTML = unescape(escape(uJson1)); sub.appendChild(div1); ID = 0; $.get(`http://192.168.1.105:8000/${ID}/sensors`, function(data1) { console.log(data1); var sens = JSON.stringify(data1["teplota"]); console.log(sens); var uSens = sens.replace(/\"/g, ""); var heat = document.getElementById("heat"); var div2 = document.createElement("div"); div2.setAttribute("id", "hot"); div2.innerHTML = unescape(escape(uSens)); heat.appendChild(div2); }) }) })