PageSourceSearch

https://www.ivg.it/wp-content/themes/edinews/assets/js/sharecount_frontend.js?ver=1679477020

js ivg.it collected 2026-10-01 11:43:34 UTC 3,431 bytes, 83 lines download raw bytes

1/**
2 * Create a pop-up window centered to the parent
3 *
4 * @param {string} url
5 * @param {string} title
6 * @param {Object} window
7 * @param {int} width
8 * @param {int} height
9 * */
10function edi_popup_window(url, title, window, width, height) {
11    const y = window.top.outerHeight / 2 + window.top.screenY - (height / 2);
12    const x = window.top.outerWidth / 2 + window.top.screenX - (width / 2);
13    return window.open(url, title, `toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${width}, height=${height}, top=${y}, left=${x}`);
14}
15
16/**
17 * @param {number|string|Object} e
18 * */
19function edi_get_counter(e){
20
21    //console.log('%c edi_get_counter event:', 'color: red;',e);
22    let query_value,query_param;
23    if(typeof e === 'number'){
24        query_param = 'post_id';
25        query_value = e;
26    } else {
27        query_param = 'permalink';
28        query_value = (typeof e === "object")?e.target.baseURI:e;
29    }
30
31    const json_endpoint = shareapi_settings.root + shareapi_settings.prefix + '/get_counts?' + query_param + '=' + query_value;
32    fetch(json_endpoint,{
33        method: 'GET', // *GET, POST, PUT, DELETE, etc.
34        mode: 'cors', // no-cors, cors, *same-origin
35        redirect: 'follow', // manual, *follow, error
36        credentials: 'same-origin', // include, *same-origin, omit
37        referrerPolicy: 'origin', // no-referrer, *client
38    })
39        .then( response => {
40            //console.log('response: ',response);
41            if (response.body !== null) {
42                return response.json();
43            }
44        } )
45        .then(( data ) => {
46            //console.log('%c counter data:','color: red;',data);
47            if(data.length < 1 || typeof data.body === 'undefined' || typeof data.body.total === 'undefined') return;
48            if(data.body.total > 0){
49                const counter_containers = document.querySelectorAll( '.single-share-count-container');
50                //console.log(counter_containers);
51                counter_containers.forEach(counter_container => {
52                    if(counter_container.length < 1) return;
53                    let counter_container_placeholder = counter_container.querySelector('.share-count-placeholder');
54
55                    //console.log(counter_container_placeholder);
56
57                    counter_container_placeholder.style.display = 'inline-block';
58                    counter_container_placeholder.innerText = shorterTotal(data.body.total);
59                    if(data.body.total > shareapi_settings.countsocialfire){
60                        counter_container.querySelector('.share-count-normal').style.display = 'none';
61                        counter_container.querySelector('.share-count-fire').style.display = 'inline-block';
62                    }
63                })
64            }
65        } )
66        .catch(error => console.error(error));
67
68}
69
70
71function shorterTotal(t) {
72    return t >= 1e6 ? t = (t / 1e6).toFixed(2) + "M" : t >= 1e3 && (t = (t / 1e3).toFixed(1) + "k"), t
73}
74
75// domReady is compatible with browsers not supporting DOMContentLoaded
76domReady(function () {
77    if(document.querySelector('article.single-content')){
78        let post_id = document.querySelector('article.single-content').dataset.postId;
79        if( typeof post_id === 'undefined') return;
80        post_id = parseInt(post_id, 10);
81        edi_get_counter(post_id);
82    }
83});

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.