diff options
author | Mario <mario@mariovavti.com> | 2024-12-21 10:27:28 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2024-12-21 10:27:28 +0000 |
commit | 92e21c4f3dae213f7f660de540cb12192366e8a3 (patch) | |
tree | 31de3bc1f7b1ed48ab8c0256ca987b3b8cba77a7 | |
parent | 55265c8a3ef749cd539e4c76b1d33237a83d1730 (diff) | |
download | volse-hubzilla-92e21c4f3dae213f7f660de540cb12192366e8a3.tar.gz volse-hubzilla-92e21c4f3dae213f7f660de540cb12192366e8a3.tar.bz2 volse-hubzilla-92e21c4f3dae213f7f660de540cb12192366e8a3.zip |
deduplicate the images array by src
-rw-r--r-- | view/js/main.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/view/js/main.js b/view/js/main.js index eff72197f..4ef924731 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -811,6 +811,7 @@ function imagesLoaded(elements, callback) { processed.push(src); loadedCount++; + document.getElementById('image_counter').innerHTML = Math.round((loadedCount * 100) / totalImages) + '%'; if (loadedCount === totalImages) { document.getElementById('image_counter').innerHTML = ''; @@ -830,10 +831,11 @@ function imagesLoaded(elements, callback) { return; } - // Filter out only img elements from the list - let images = Array.from(elements).filter(element => { - return element.tagName && element.tagName.toLowerCase() === 'img' && element.src; - }); + let images = Array.from(elements) + .filter(element => element.tagName && element.tagName.toLowerCase() === 'img' && element.src) + .filter((element, index, self) => + index === self.findIndex(e => e.src === element.src) + ); // If no images are found, call the callback immediately if (images.length === 0) { |