2021-05-07 21:15:20 +02:00
|
|
|
|
|
|
|
$(document).ready(function() {
|
2021-05-10 22:29:01 +02:00
|
|
|
let base_url = "http://192.168.1.105:8000/";
|
2021-05-10 19:15:52 +02:00
|
|
|
let ids_list = [];
|
|
|
|
|
|
|
|
$.get("ip.txt", function(data) {
|
|
|
|
console.log(data);
|
|
|
|
base_url = `http://${data}:8000/`;
|
|
|
|
init_wesite();
|
|
|
|
});
|
2021-05-07 21:15:20 +02:00
|
|
|
|
2021-05-09 14:38:09 +02:00
|
|
|
function append_element(image_urls, descriptions, title, id) {
|
2021-05-10 19:15:52 +02:00
|
|
|
ids_list.push(id);
|
2021-05-09 14:38:09 +02:00
|
|
|
|
|
|
|
let template = `
|
|
|
|
<div class="wsList hey">
|
2021-05-10 15:03:04 +02:00
|
|
|
<div></div>
|
|
|
|
<img src="${image_urls[0]}" alt="#" class="obrazok_small">
|
2021-05-10 19:15:52 +02:00
|
|
|
<div id="list_item_holder${id}" class="list_item_holder">
|
2021-05-09 14:38:09 +02:00
|
|
|
<div class="title${id}">${title}</div>
|
2021-05-10 15:03:04 +02:00
|
|
|
<div class="short_description">${descriptions[0]}</div>
|
2021-05-09 14:38:09 +02:00
|
|
|
</div>
|
|
|
|
<div id="arrow${id}" class="arrow">▼</div>
|
|
|
|
</div>
|
|
|
|
<!-- Rozšírené malé zobrazenie -->
|
|
|
|
<div id="listExpand${id}" class="listHide">
|
2021-05-10 15:03:04 +02:00
|
|
|
<img src="${image_urls[1]}" alt="#" class="obrazok_big">
|
|
|
|
<div class="text_small">${descriptions[1]}</div>
|
|
|
|
<div class="sensors_small">
|
2021-05-09 14:38:09 +02:00
|
|
|
</div>
|
2021-05-10 15:03:04 +02:00
|
|
|
<div class="info_small"></div>
|
2021-05-09 14:38:09 +02:00
|
|
|
</div>
|
|
|
|
<!-- Veľké zobrazenie -->
|
2021-05-10 19:15:52 +02:00
|
|
|
<div id="big${id}" class="big">
|
2021-05-10 22:29:01 +02:00
|
|
|
<div class="imgBig"><img class="wsImg" src="${image_urls[1]}" alt="#"></div>
|
2021-05-10 15:03:04 +02:00
|
|
|
<div class="text_big">${descriptions[1]}</div>
|
|
|
|
<div class="sensors_big">
|
|
|
|
</div>
|
|
|
|
<div class="info_big"></div>
|
2021-05-09 14:38:09 +02:00
|
|
|
</div>`;
|
2021-05-07 21:15:20 +02:00
|
|
|
|
|
|
|
$("body").append(template);
|
|
|
|
|
2021-05-10 15:03:04 +02:00
|
|
|
$.get(`${base_url}${id}/sensors`, function(data1) {
|
2021-05-09 14:38:09 +02:00
|
|
|
Object.keys(data1).forEach(function(key) {
|
|
|
|
let value = data1[key];
|
|
|
|
if (key.startsWith("[translate]-")) {
|
|
|
|
key = key.slice(12, key.length);
|
|
|
|
}
|
2021-05-10 15:03:04 +02:00
|
|
|
$(".sensors_small").append(`<p class="sens_style_heat">${key}: ${value}</p>`);
|
|
|
|
$(".sensors_big").append(`<p class="sens_style_heat">${key}: ${value}</p>`);
|
2021-05-09 14:38:09 +02:00
|
|
|
});
|
|
|
|
});
|
2021-05-07 21:15:20 +02:00
|
|
|
|
2021-05-09 14:38:09 +02:00
|
|
|
$(".arrow").click(function() {
|
2021-05-07 21:15:20 +02:00
|
|
|
|
2021-05-09 14:38:09 +02:00
|
|
|
let id = this.id;
|
|
|
|
id = id.slice(id.length-1, id.length);
|
|
|
|
|
|
|
|
$(`#arrow${id}`).toggleClass("mystyle");
|
|
|
|
$(`#listExpand${id}`).toggleClass("expand");
|
2021-05-10 15:03:04 +02:00
|
|
|
id.a();
|
2021-05-09 14:38:09 +02:00
|
|
|
});
|
2021-05-10 19:15:52 +02:00
|
|
|
|
|
|
|
$(".list_item_holder").click(function() {
|
|
|
|
let id = this.id;
|
|
|
|
id = id.slice(id.length-1, id.length);
|
|
|
|
|
|
|
|
clear_big_display();
|
|
|
|
$(`#big${id}`).show();
|
|
|
|
});
|
2021-05-09 14:38:09 +02:00
|
|
|
|
|
|
|
}
|
2021-05-07 21:15:20 +02:00
|
|
|
|
2021-05-10 19:15:52 +02:00
|
|
|
function clear_big_display(){
|
|
|
|
ids_list.forEach(function(id) {
|
|
|
|
$(`#big${id}`).hide();
|
|
|
|
});
|
|
|
|
}
|
2021-05-07 21:15:20 +02:00
|
|
|
|
2021-05-10 19:15:52 +02:00
|
|
|
function init_wesite() {
|
|
|
|
$.get(`${base_url}devices_list`, function(data) {
|
2021-05-07 21:15:20 +02:00
|
|
|
|
2021-05-10 19:15:52 +02:00
|
|
|
let connected_id = data[0]["connected_id"];
|
|
|
|
let urls = ["", ""];
|
|
|
|
let descriptions = ["", ""];
|
|
|
|
let title = "";
|
|
|
|
let query = [[]];
|
|
|
|
|
|
|
|
for (let i = 1; i < data.length; i++) {
|
|
|
|
let spot_data = data[i];
|
|
|
|
let spot_id = spot_data["ID"]
|
|
|
|
urls = [`${base_url}files/${spot_id}/${spot_data["description"]["photo_s"]}`,
|
|
|
|
`${base_url}files/${spot_id}/${spot_data["description"]["photo_b"]}`];
|
|
|
|
descriptions = [spot_data["description"]["description_s"],
|
|
|
|
spot_data["description"]["description_l"]];
|
|
|
|
title = spot_data["description"]["title"];
|
|
|
|
|
|
|
|
if (spot_id == connected_id) {
|
|
|
|
query[0] = [urls, descriptions, title, parseInt(spot_id)];
|
|
|
|
} else {
|
|
|
|
query.push([urls, descriptions, title, parseInt(spot_id)]);
|
|
|
|
}
|
2021-05-09 14:38:09 +02:00
|
|
|
}
|
2021-05-07 21:15:20 +02:00
|
|
|
|
2021-05-10 19:15:52 +02:00
|
|
|
for (let i = 0; i < query.length; i++) {
|
|
|
|
append_element(query[i][0], query[i][1], query[i][2], query[i][3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
2021-05-11 08:55:16 +02:00
|
|
|
})
|