diff --git a/website/desc_short.js b/website/desc_short.js index 7f74d8f..e13806c 100644 --- a/website/desc_short.js +++ b/website/desc_short.js @@ -1,14 +1,22 @@ $(document).ready(function() { - let base_url = "http://localhost:8000/"; + let base_url = "http://lohost:8000/"; + let ids_list = []; + + $.get("ip.txt", function(data) { + console.log(data); + base_url = `http://${data}:8000/`; + init_wesite(); + }); function append_element(image_urls, descriptions, title, id) { + ids_list.push(id); let template = `
# -
+
${title}
${descriptions[0]}
@@ -23,7 +31,7 @@ $(document).ready(function() {
-
+
#
${descriptions[1]}
@@ -53,37 +61,54 @@ $(document).ready(function() { $(`#listExpand${id}`).toggleClass("expand"); id.a(); }); + + $(".list_item_holder").click(function() { + let id = this.id; + id = id.slice(id.length-1, id.length); + + clear_big_display(); + $(`#big${id}`).show(); + }); } - $.get(`${base_url}devices_list`, function(data) { + function clear_big_display(){ + ids_list.forEach(function(id) { + $(`#big${id}`).hide(); + }); + } - let connected_id = data[0]["connected_id"]; - let urls = ["", ""]; - let descriptions = ["", ""]; - let title = ""; - let query = [[]]; + function init_wesite() { + $.get(`${base_url}devices_list`, function(data) { - 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)]); - } - } - - for (let i = 0; i < query.length; i++) { - append_element(query[i][0], query[i][1], query[i][2], query[i][3]); - } - - }) + 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)]); + } + } + + for (let i = 0; i < query.length; i++) { + append_element(query[i][0], query[i][1], query[i][2], query[i][3]); + } + + }) + } + + init_wesite(); }) diff --git a/website/ip.txt b/website/ip.txt new file mode 100644 index 0000000..d18580b --- /dev/null +++ b/website/ip.txt @@ -0,0 +1 @@ +localhost \ No newline at end of file diff --git a/website/test.txt b/website/test.txt deleted file mode 100644 index bf8e94d..0000000 --- a/website/test.txt +++ /dev/null @@ -1,8 +0,0 @@ -sf -fsd -f -sdf -sd -fsd -f -sd \ No newline at end of file