PageSourceSearch

https://sundials.org/media/plg_system_eprivacy/js/eprivacy.js?a8bf26

js sundials.org collected 2026-10-02 05:12:01 UTC 12,863 bytes, 304 lines download raw bytes

1const plg_system_eprivacy_class = function(){
2    const root = this;
3    this.targets = {};
4    this.modal = false;
5    const construct = function(){
6        Object.assign(root.targets, Joomla.getOptions('plg_system_eprivacy'));
7        if(!['0','1'].includes(root.getCookie('plg_system_eprivacy'))){
8            root.display();
9        }
10        let privacyLinks = document.querySelectorAll('.plg_system_eprivacy_privacy');
11        if(privacyLinks.length > 0){
12            privacyLinks.forEach(function(link){
13                link.addEventListener('click', function(event){
14                    event.preventDefault();
15                    root.display(true);
16                });
17            });
18        }
19    }
20    this.setCookie = function(name, value, days){
21        let expires = "";
22        if(days){
23            let date = new Date();
24            date.setTime(date.getTime() + (days*24*60*60*1000));
25            expires = "; expires=" + date.toUTCString();
26        }
27        document.cookie = name + "=" + value + expires + "; path=/";
28    }
29    this.getCookie = function(name,defaultValue=false){
30        return document.cookie.match('(^|;)\\s*'+name+'\\s*=\\s*([^;]+)')?.pop() || defaultValue;
31    }
32    this.eraseCookie = function(name){
33        root.setCookie(name, "", -1);
34    }
35    this.display = function(force=false){
36        let suppress = false;
37        if(root.targets.plg_system_eprivacy.suppress !== false && force !== true){
38            if(window.location.href.includes(root.targets.plg_system_eprivacy.suppress)){
39                suppress = true;
40            }
41        }
42        switch(root.targets.plg_system_eprivacy.display) {
43            case 'modal':
44                if(!root.modal){
45                    root.initModal();
46                }
47                if(suppress){
48                    return;
49                }
50                root.displayModal();
51                break;
52            case 'alert':
53                if(suppress){
54                    return;
55                }
56                root.displayAlert();
57                break;
58        }
59    }
60    this.initModal = function(){
61        let element = document.getElementById('plg_system_eprivacy_modal');
62        root.modal = new bootstrap.Modal(element);
63        let acceptButton = document.querySelector('#plg_system_eprivacy_modal button.accept');
64        acceptButton.addEventListener('click', function(){
65            root.setCookie('plg_system_eprivacy', 1, 365);
66            root.modal.hide();
67            root.accept();
68        });
69        let declineButton = document.querySelector('#plg_system_eprivacy_modal button.decline');
70        declineButton.addEventListener('click', function(){
71            root.setCookie('plg_system_eprivacy', 0, 365);
72            Object.getOwnPropertyNames(root.targets).forEach(function(target){
73                if(target === 'plg_system_eprivacy'){
74                    return;
75                }
76                root.eraseCookie(target+'_consent');
77            });
78            root.modal.hide();
79            root.decline();
80        });
81        document.querySelectorAll('#plg_system_eprivacy_modal i[data-bs-toggle="tooltip"]').forEach(function(element){
82            new bootstrap.Tooltip(element);
83        });
84    }
85    this.displayModal = function(){
86        if(root.modal){
87            document.querySelectorAll('#plg_system_eprivacy_modal input[type="checkbox"]').forEach(function(input){
88                if((root.targets[input.dataset.plugin].mandatory??[]).includes(input.dataset.option)??false){
89                    input.disabled = true;
90                }
91                input.checked = true;
92            });
93            root.modal.show();
94        }
95    }
96    this.displayAlert = function(){
97        if(document.getElementById('plg_system_eprivacy_alert')){
98            return;
99        }
100        let container = document.getElementById('system-message-container');
101        let alert = root.newElement('div',['alert','alert-info','row']);
102        alert.id = 'plg_system_eprivacy_alert';
103        let messageBox = root.newElement('div',['col','d-flex','flex-column','justify-content-between']);
104        alert.appendChild(messageBox);
105        let buttonBox = root.newElement('div',['col-lg-2','text-center','d-flex','flex-column']);
106        alert.appendChild(buttonBox);
107
108        let consentIconStack = root.newElement('span',['fa-stack','fa-2x','mx-auto','d-none','d-lg-block']);
109        let consentIcon = root.newElement('i',['fas','fa-shield','fa-stack-2x','text-dark']);
110        consentIconStack.appendChild(consentIcon);
111        let consentIconCheck = root.newElement('i',['fas','fa-user','fa-stack-1x','text-light']);
112        consentIconStack.appendChild(consentIconCheck);
113        buttonBox.appendChild(consentIconStack);
114
115        let accept = root.acceptButton(['btn','btn-success','mt-1','
115w-100']);
116        accept.addEventListener('click', function(){
117            alert.remove();
118        });
119        buttonBox.appendChild(accept);
120        let decline = root.declineButton(['btn','btn-danger','mt-1','w-100']);
121        decline.addEventListener('click', function(){
122            alert.remove();
123        });
124        buttonBox.appendChild(decline);
125        let h5 = root.newElement('h5');
126        h5.innerText = Joomla.Text._('PLG_SYSTEM_EPRIVACY_TITLE');
127        messageBox.appendChild(h5);
128
129        let p = document.createElement('p');
130        let message = Joomla.Text._('PLG_SYSTEM_EPRIVACY_MESSAGE')
131        p.innerText = message;
132        messageBox.appendChild(p);
133
134        if(root.targets.plg_system_eprivacy.suppress !== false){
135            let p2 = document.createElement('p');
136            let p2a = document.createElement('a');
137            p2a.href = root.targets.plg_system_eprivacy.suppress;
138            p2a.innerText = Joomla.Text._('PLG_SYSTEM_EPRIVACY_PRIVACY_POLICY');
139            p2a.target = '_blank';
140            p2.appendChild(p2a);
141            messageBox.appendChild(p2);
142        }
143
144        let detailsAccordion = root.newElement('div',['accordion','accordion-flush']);
145        detailsAccordion.id = 'plg_system_eprivacy_details';
146        messageBox.appendChild(detailsAccordion);
147        let accordionItem = root.newElement('div',['accordion-item']);
148        detailsAccordion.appendChild(accordionItem);
149        let accordionHeader = root.newElement('div',['accordion-header']);
150        accordionHeader.id = 'plg_system_eprivacy_details_header';
151        accordionItem.appendChild(accordionHeader);
152        let accordionButton = root.newElement('button',['accordion-button','collapsed']);
153        accordionButton.type = 'button';
154        accordionButton.setAttribute('data-bs-toggle','collapse');
155        accordionButton.setAttribute('data-bs-target','#plg_system_eprivacy_details_content');
156        accordionButton.setAttribute('aria-expanded','false');
157        accordionButton.setAttribute('aria-controls','plg_system_eprivacy_details_content');
158        accordionButton.innerText = Joomla.Text._('PLG_SYSTEM_EPRIVACY_DETAILS');
159        accordionHeader.appendChild(accordionButton);
160        let accordionContent = root.newElement('div',['accordion-collapse','collapse']);
161        accordionContent.id = 'plg_system_eprivacy_details_content';
162        accordionContent.setAttribute('aria-labelledby','plg_system_eprivacy_details_header');
163        accordionContent.setAttribute('data-bs-parent','#plg_system_eprivacy_details');
164        accordionItem.appendChild(accordionContent);
165        let accordionBody = root.typeList();
166        accordionContent.appendChild(accordionBody);
167
168        container.appendChild(alert);
169    }
170    this.typeList = function(){
171        let accordionBody = root.newElement('div',['accordion-body']);
172        let types = root.getTypes();
173        let typeTitle = '';
174        let listflag = false;
175        let ul = document.createElement('ul');
176        ul.classList.add('list-unstyled');
177        types.forEach(function(typeset){
178            let type = typeset.split('.')[0];
179            let constant = typeset.split('.')[1];
180            if(typeTitle !== type){
181                if(listflag){
182                    accordionBody.appendChild(ul);
183                    ul = root.newElement('ul',['list-unstyled']);
184                }
185                listflag = true;
186                typeTitle = type;
187                let h6 = root.newElement('h6');
188                h6.innerText = Joomla.Text._((type+'_SCRIPT').toUpperCase());
189                accordionBody.appendChild(h6);
190            }
191            let li = root.newElement('li');
192            let formCheck = root.newElement('div',['form-check']);
193            li.appendChild(formCheck);
194            let input = root.newElement('input',['form-check-input']);
195            input.type = 'checkbox';
196            input.id = type+'-'+constant;
197            input.checked = true;
198            if((root.targets[type].mandatory??[]).includes(constant)??false){
199                input.disabled = true;
200            }
201            formCheck.appendChild(input);
202            let label = root.newElement('label',['form-check-label']);
203            label.setAttribute('for',input.id);
204            label.innerText = Joomla.Text._((type+'_SCRIPT_'+constant).toUpperCase());
205            let infoIcon = root.newElement('i',['fas','fa-info-circle','ms-1']);
206            infoIcon.setAttribute('data-bs-toggle','tooltip');
207            infoIcon.setAttribute('data-bs-placement','top');
208            let desc = Joomla.Text._((type+'_SCRIPT_'+constant+'_DESC').toUpperCase());
209            if(input.disabled === true){
210                desc = Joomla.Text._('PLG_SYSTEM_EPRIVACY_MANDATORY')+': '+desc;
211            }
212            infoIcon.setAttribute('title',desc);
213            label.appendChild(infoIcon);
214            new bootstrap.Tooltip(infoIcon);
215            formCheck.appendChild(label);
216            ul.appendChild(li);
217        });
218        if(listflag){
219
220            accordionBody.appendChild(ul);
221        }
222        return accordionBody;
223    }
224    this.newElement = function(type, classes=[]){
225        let element = document.createElement(type);
226        classes.forEach(function(classname){
227            element.classList.add(classname);
228        });
229        return element;
230    }
231    this.acceptButton = function(classes){
232        let button = root.newElement('button',classes);
233        button.textContent = Joomla.Text._('PLG_SYSTEM_EPRIVACY_ACCEPT');
234        button.addEventListener('click', function(){
235            root.setCookie('plg_system_eprivacy', 1, 365);
236            root.accept();
237        });
238        return button;
239    }
240    this.declineButton = function(classes){
241        let button = root.newElement('button',classes);
242        button.textContent = Joomla.Text._('PLG_SYSTEM_EPRIVACY_DECLINE');
243        button.addEventListener('click', function(){
244            root.setCookie('plg_system_eprivacy', 0, 365);
245            Object.getOwnPropertyNames(root.targets).forEach(function(target){
246                if(target === 'plg_system_eprivacy'){
247                    return;
248                }
249                root.eraseCookie(target+'_consent');
250            });
251            root.decline();
252        });
253        return button;
254    }
255    this.getTypes = function(){
256        let types = [];
257        Object.getOwnPropertyNames(root.targets).forEach(function(target){
258            if(target === 'plg_system_eprivacy'){
259                return;
260            }
261            let o = root.targets[target].consent;
262            let consents = Object.getOwnPropertyNames(o);
263            consents.forEach(function(consent){
264                types.push(target+'.'+consent);
265            });
266        });
267        return types;
268    }
269    this.accept = function(){
270        Object.getOwnPropertyNames(root.targets).forEach(function(target){
271            if(target === 'plg_system_eprivacy'){
272                return;
273            }
274            let o = root.targets[target];
275            Object.getOwnPropertyNames(o.consent).forEach(function(consent){
276                let input = document.getElementById(target+'-'+consent);
277                if(!input.checked){
278                    o.consent[consent] = 'denied';
279                } else {
280                    o.consent[consent] = 'granted';
281                }
282            });
283            root.setCookie(target+'_consent', JSON.stringify(o.consent), 365);
284            if(o.function === 'gtag'){
285                root.gtag(o.consent);
286            }
287        });
288        window.dispatchEvent(new Event('plg_system_eprivacy_accepted'));
289    }
290    this.decline = function(){
291        window.dispatchEvent(new Event('plg_system_eprivacy_declined'));
292    }
293    this.gtag = function(o){
294        window.dataLayer = window.dataLayer || [];
295        function gtag(){dataLayer.push(arguments);}
296        gtag('consent', 'update', o);
297    }
298
299    construct();
300    return root;
301}
302window.addEventListener('DOMContentLoaded', function(){
303    new plg_system_eprivacy_class();
304});

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.