PageSourceSearch

https://www.lecturalia.com/js/nslec.js?v=7

js lecturalia.com collected 2026-10-02 05:31:12 UTC 6,578 bytes, 221 lines download raw bytes

1var NSLec = NSLec || {}; //Creamos el esapcio de nombres (vacio), si no fue cargado en otro script
2NSLec.modalForms = NSLec || [];
3NSLec.user = NSLec.user || [];
4
5var getJSON = function (url, callback) {
6    var xhr = new XMLHttpRequest();
7    xhr.open('GET', url, true);
8    xhr.responseType = 'json';
9    xhr.onload = function () {
10        var status = xhr.status;
11        if (status === 200) {
12            callback(null, xhr.response);
13        } else {
14            callback(status, xhr.response);
15        }
16    };
17    xhr.send();
18};
19
20var serializeForm = function (form, action) {
21    var formData = new FormData();
22    formData.append('action', action);
23
24    if (form) {
25        var elements = form.getElementsByTagName('input');
26        for (var i = 0; i < elements.length; ++i) {
27            var element = elements[i];
28            if (!['text', 'password', 'checkbox'].includes(element.getAttribute('type'))) {
29                continue;
30            }
31            if (element.getAttribute('type') == 'checkbox' && !element.checked) {
32                continue;
33            }
34            formData.append(element.name, element.value);
35        }
36    }
37
38    return formData;
39};
40
41(function (oNS) {
42    oNS.action = 'https://www.lecturalia.com/action';
43    oNS.userAction = 'https://www.lecturalia.com/user-action';
44    oNS.ArrModalzone = this.ArrModalzone || [];
45    oNS.Active = null;
46
47    oNS.open = function (id) {
48        e = document.getElementById(id);
49        if (oNS.Active && oNS.Active.id != id) {
50            oNS.close(oNS.Active.id);
51        }
52        if (e) {
53            oNS._bgToggle(true);
54            e.classList.toggle('is-active');
55            var lCnf = oNS._getConfig(id);
56            if (lCnf.jsA) {
57                eval(lCnf.jsA);
58            }
59        } else {
60            var lCnf = oNS._getConfig(id);
61            if (lCnf) {
62                oNS._bgToggle(true);
63                if (lCnf.html) oNS.appendHtml(document.body, lCnf.html);
64                if (lCnf.js) eval(lCnf.js);//window[lCnf.js]();//
65                e = document.getElementById(id);
66                if (e) {
67                    e.classList.toggle('is-active');
68                    oNS.Active = lCnf;
69                    if (lCnf.jsA) {
70                        eval(lCnf.jsA);
71                    }
72                }
73            }
74        }
75    };
76    oNS.appendHtml = function (el, str) {
77        var div = document.createElement('div');
78        div.innerHTML = str;
79        while (div.children.length > 0) {
80            el.appendChild(div.children[0]);
81        }
82    };
83    oNS.close = function (id) {
84        oNS._bgToggle(false);
85        e = document.getElementById(id);
86        if (e) {
87            e.classList.toggle('is-active');
88            if (oNS.Active && oNS.Active.id == id) {
89                oNS.Active = null;
90            }
91        }
92    };
93    oNS._bgToggle = function (vOn) {
94        if (
95            (vOn && !document.body.classList.contains('fullbg'))
96            ||
97            (!vOn && document.body.classList.contains('fullbg'))) {
98            document.body.classList.toggle('fullbg');
99        }
100    }
101    oNS._getConfig = function (id) {
102        var r = false;
103        for (var i = 0; i < this.ArrModalzone.length; ++i) {
104            if (this.ArrModalzone[i] && this.ArrModalzone[i].id == id) {
105                r = this.ArrModalzone[i];
106                break;
107            }
108        }
109        if (!r) {
110            getJSON(oNS.action + '?form=' + id, function(err, data) {
111                if (err === null && data !== null && data.id) {
112                    oNS.ArrModalzone.push(data);
113                    oNS.open(id);
114                }
115            });
116        }
117        return r;
118    }
119
120})(NSLec);
121
122(function (oUsr, oNS) {
123    oUsr.action = function (vAction, vData) {
124        var formData = serializeForm(vData, vAction);
125
126        var xhr = new XMLHttpRequest();
127        xhr.open("POST", oNS.userAction, true);
128        xhr.onload = function () {
129            oUsr._process(JSON.parse(xhr.response));
130        };
131        xhr.send(formData);
132    };
133
134    oUsr._process = function (data) {
135        var lMsg = '';
136        if (data.status) {
137            if (data.reload) {
138                if (data.reload_URL) {
139                    location.replace(data.reload_URL);
140                } else {
141                    location.reload();
142                }
143            }
144        }
145        if (data.msg) {
146            lMsg = data.msg;
147        }
148        if (lMsg && data.msg_container) {
149            var x = document.querySelectorAll(data.msg_container);
150            if (x[0]) {
151                x[0].innerHTML = lMsg;
152            }
153        }
154    }
155
156})(NSLec.user, NSLec);
157
158(function (oNS) {
159    oNS.openModal = function (id) {
160        NSLec.modalForms.open(id);
161    };
162    oNS.closeModal = function (id) {
163        NSLec.modalForms.close(id);
164    };
165    oNS._toggleIs = function (id, isclass, id2) {
166        if (typeof id == 'string') {
167            var e = document.getElementById(id);
168        } else {
169            var e = id;
170        }
171        if (id2) {
172            if (typeof id2 == 'string') {
173                var e2 = document.getElementById(id2);
174            } else {
175                var e2 = id2;
176            }
177            if (e2) {
178                if (e2.classList.contains(isclass)) {
179                    e2.classList.toggle(isclass);
180                }
181            }
182        }
183        if (e) {
184            e.classList.toggle(isclass);
185        }
186    };
187    oNS.toggleReadMore = function (id) {
188        var e;
189        if (typeof id === 'string') {
190            e = document.getElementById(id);
191        } else {
192            e = id;
193        }
194        if (e.classList.contains('is-hidden')) {
195            e.classList.remove('is-hidden');
196            e.classList.add('is-visible');
197        } else if (e.classList.contains('is-visible')) {
198            e.classList.add('is-hidden');
199            e.classList.remove('is-visible');
200        }
201    };
202    oNS.toggleIsShow = function (id) {
203        oNS._toggleIs(id, "is-show");
204    };
205    oNS.toggleIsHidden = function (id) {
206        oNS._toggleIs(id, "is-hidden");
207    };
208    oNS.toggleIsActive = function (id, id2) {
209        oNS._toggleIs(id, "is-active", id2);
210    };
211    oNS.openSlider = function () {
212        var s = document.getElementById('sliderMenu');
213        s.classList.add('is-active');
214        oNS.modalForms._bgToggle(true);
215    };
216    oNS.closeSlider = function () {
217        var s = document.getElementById('sliderMenu');
218        s.classList.remove('is-active');
219        oNS.modalForms._bgToggle(false);
220    };
221})(NSLec);

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.