From 18a07f3902a206b24af5d4934a4eb28329a69697 Mon Sep 17 00:00:00 2001 From: Redume Date: Sat, 8 Oct 2022 10:58:23 +0300 Subject: [PATCH] placeholder made --- web/static/image/placeholder.png | Bin 0 -> 6146 bytes web/static/scripts/gallery.js | 59 +++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 19 deletions(-) create mode 100644 web/static/image/placeholder.png diff --git a/web/static/image/placeholder.png b/web/static/image/placeholder.png new file mode 100644 index 0000000000000000000000000000000000000000..bf1d31046f6bb3ca7699ba3bc40b953380d1b754 GIT binary patch literal 6146 zcmd5=cTiJbw}p^kNa!UrDWM3MNC#;G2^|Cl6ap%QDhLWvl_m*QBS;ZYnj(rI0Rjku zNC}8EmEN0F=|Otu#ou3VzBg~?&G*my?##XCoW0jtXYGCO+_`ffUo|seg786TXlR&> z40SDNXn-Ud8aiPx9W?^f^pK?v%2zL6)BCfz-PqC7{Ih>;eRGAfvA9YZ7@O+o86KXT z`O!DhGdwXpzw~=)ZE|*@wQF!}YQA$|Y<6+wW_F|v4GnjUkuK`mgOQa!S|%DA#-`Vk z^^1#c0FkOQv8=EJI8s;#qa95OXLO+DZ3M_if}Fw7*8l$mmTH%QT7LNJ(~?oP1@Og4 zkS7>A#0n$9kysr}1JyB;11*0eK>0r+@zqQqf$Ek9d~o_%02iO|pXBX-c1-VIn(OeN z*UJSJf9}iA74thXIyoUSW3aR=l}2*hx9xnyS>Q@s@dhNC(P#&sc}vZf(h_emd{nRp z`u7ir|04RvlrRwb$)!c5-<89~@Ox#vHp%Y->a? zRWHxM$`M+!y(3KI#;mRG47$FT5d)fF*uAD`$9PK-j-pjI{@7E?ae(=RFn$#~)XPd9h9z8Q08AKj^<91I1XmL=l)9ng8PWEy%8M~z*j8*sV)XvuZ7}Skn@shC z?IZ~sAz@4xIY9q>(zYfZ#D)JdD%@rpjz!`0zn!ORvyH=|G~B%+9wEN))ZwtG&pQW% zRm#huj-ba_l(Ileq1VgRU2ZT;m*aDXtj90@ruSf&S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/web/static/scripts/gallery.js +++ b/web/static/scripts/gallery.js @@ -39,11 +39,6 @@ $(document).ready(function() { }); }); -const myModal = new bootstrap.Modal('#Wallpaper', { - keyboard: false -}); -myModal.show(); - function wallpaper(data) { $(".preloader").hide(); data = data.reverse(); @@ -51,32 +46,52 @@ function wallpaper(data) { for (let i = 0; i < data.length; i++, id++) { ids.push(data[i]); - if (ids.filter((item) => item.url === data[i].url).length > 1) { + if (ids.filter((item) => item['url'] === data[i]['url']).length > 1) { continue; } + let image = new Image(); + image.src = ids[id]['media_type'] === "video" ? + `https://img.youtube.com/vi/${ids[id]['url'].slice(30, 41)}/maxresdefault.jpg` : + ids[id]['url']; + + image.onload = function() { + if(image.width+image.height !== 210) { + $(`img[data-src="${image.src}"]`).attr("src", `${image.src}`); + } + } + if (ids[id]['media_type'] === "image") { $(".header-row").append(` `); } else { $(".header-row").append(` -
- - ${ids[id]['title']} - -
- `); +
+ + ${ids[id]['title']} + +
+ `); } } + let button_modal = document.querySelector(".header-row"); button_modal.addEventListener("click", function (event) { - let id = event.target.getAttribute("idi"); + if (event.target === button_modal) { + return; + } + + let id = event.target.getAttribute("id"); let img = document.querySelector(".modal-body"); let title = document.querySelector(".w-modal-title"); @@ -87,6 +102,7 @@ function wallpaper(data) { ids[id]['copyright'] = ids[id]['copyright'] === undefined ? "NASA" : ids[id]['copyright']; if (ids[id]['media_type'] === "image") { + title.innerHTML = ``; img.innerHTML = ` ${ids[id]['title']}

Author: ${ids[id]['copyright']}

@@ -94,27 +110,32 @@ function wallpaper(data) {

Explanation: ${ids[id]['explanation']}

`; - title.innerHTML = ``; setWallpaper.addEventListener("click", function () { wallpaperUpdate(ids[id]['hdurl']); }); } else { + title.innerHTML = ``; img.innerHTML = ` - + +

Author: ${ids[id]['copyright']}

Date of publication: ${ids[id]['date']}

Explanation: ${ids[id]['explanation']}

`; - title.innerHTML = ``; setWallpaper.addEventListener("click", function () { - wallpaperUpdate(`https://img.youtube.com/vi/${ids[id]['url'].slice(30,41)}/maxresdefault.jpg`); + wallpaperUpdate(`https://img.youtube.com/vi/${ids[id]['url'].slice(30, 41)}/maxresdefault.jpg`); }); } }); $(window).scroll(function () { - if (($(window).scrollTop() > $(document).height() - $(window).height() - 100)) { + if (($(window).scrollTop() > $(document).height() - $(window).height() - 100)) { $(".preloader").show(); $(window).off("scroll");