PageSourceSearch

https://elgger-zeitung.ch/apps/bcms/@themes/demo/assets/js/deferred_image_loader.js

js elgger-zeitung.ch collected 2026-10-02 15:45:51 UTC 1,701 bytes, 41 lines download raw bytes

1// function loadImage(url) {
2//     //TODO EMANUELE: replace promises!
3//     return new Promise((resolve, reject) => {
4//         let img = new Image();
5//         img.addEventListener('load', e => resolve(img));
6//         img.addEventListener('error', () => {
7//             reject(new Error(`Failed to load image's URL: ${url}`));
8//         });
9//         img.src = url;
10//     });
11// }
12
13// ImageLoaderWorker.postMessage('Hello world!')
14// Get all of the `<img>` elements that have a `data-src` property
15const imgElements = document.querySelectorAll('.img-worker')
16
17// Loop over the image elements and pass their URLs to the web worker
18imgElements.forEach(imageElement => {
19    const imageObjectString = imageElement.getAttribute('data-src');
20    try{
21        const imageObject = JSON.parse(imageObjectString);
22        //getting the first image
23        let imageURL = "";
24        //TODO EMANUELE: fix image caching by creating new images on image crop instead of adding random query strings
25        if(imageObject.length > 0){
26            imageURL =  typeof imageObject[0]["cropInfo"] != "undefined"? imageObject[0].base+imageObject[0]["cropInfo"]["cropped"]+"?"+Math.random() :imageObject[0].base+imageObject[0]["370x370"]+"?"+Math.random();
27        }
28
29		// if(imageURL=='') { imageElement.parentElement.childNodes[3].style.display = 'block' }
30
31        // loadImage(imageURL).then( img => {
32        //         imageElement.setAttribute('src', img.src);
33        //         imageElement.classList.add("no-blur");
34        //     }
35        // ).catch(error => console.error(error));
36        imageElement.setAttribute('src', imageURL);
37    }catch (ex){
38        // alert(imageObjectString);
39    }
40})
41

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.