PageSourceSearch

https://www.lojaintt.com.br/common/js/lazyLoadService.js?v=1

js lojaintt.com.br collected 2026-09-26 10:09:10 UTC 6,080 bytes, 236 lines download raw bytes

1var lazyLoadService = {};
2lazyLoadService.eventExecuted = false;
3lazyLoadService.eventAfterFirstInteractionExecuted = false;
4lazyLoadService.inlineScriptsStored = [];
5lazyLoadService.scriptTagsStored = [];
6lazyLoadService.functionsStored = [];
7lazyLoadService.videosStored = [];
8lazyLoadService.functionsAfterInteractionStored = [];
9
10lazyLoadService.addScriptTagToQueue = function(element, url, attributes = []) {
11	lazyLoadService.scriptTagsStored.push({element, url, attributes});
12
13	if (lazyLoadService.eventExecuted) {
14		lazyLoadService.appendScriptTagsToDOM();
15	}
16}
17
18lazyLoadService.addVideoToQueue = function(element, html) {
19	lazyLoadService.videosStored.push({element, html});
20
21	if (lazyLoadService.eventExecuted) {
22		lazyLoadService.appendVideosToDOM();
23	}
24}
25
26lazyLoadService.addInlineScriptToQueue = function(element, html) {
27	lazyLoadService.inlineScriptsStored.push({element, html});
28
29	if (lazyLoadService.eventExecuted) {
30		lazyLoadService.appendInlineScriptsToDOM();
31	}
32}
33
34lazyLoadService.addFunctionToQueue = function(func) {
35	if (lazyLoadService.eventExecuted) {
36		func();
37	} else {
38		lazyLoadService.functionsStored.push(func);
39	}
40}
41
42lazyLoadService.addFunctionToQueueAfterInteraction = function(func) {
43	if (lazyLoadService.eventAfterFirstInteractionExecuted) {
44		func();
45	} else {
46		lazyLoadService.functionsAfterInteractionStored.push(func);
47	}
48}
49
50lazyLoadService.appendHtml = function(element, html) {
51	switch (element) {
52		case 'body':
53			document.body.appendChild(html);
54			break;
55		case 'head':
56			document.head.appendChild(html);
57			break;
58		default:
59			document.querySelector(element).appendChild(html);
60			break;
61	}
62}
63
64lazyLoadService.appendScriptTagsToDOM = function() {
65	if (lazyLoadService.scriptTagsStored === undefined) {
66		return;
67	}
68
69	if (!lazyLoadService.scriptTagsStored.length) {
70		return;
71	}
72
73	lazyLoadService.scriptTagsStored.map((script) => {
74		let html = document.createElement('script');
75		html.type = 'text/javascript';
76		html.async = true;
77		html.src = script.url;
78
79		if (script.attributes.length > 0) {
80			script?.attributes?.map(attribute => {
81				html.setAttribute(attribute.key, attribute.value);
82			});
83		}
84
85		lazyLoadService.appendHtml(script.element, html);
86	});
87
88	lazyLoadService.scriptTagsStored = [];
89}
90
91lazyLoadService.appendInlineScriptsToDOM = function() {
92	if (lazyLoadService.inlineScriptsStored === undefined) {
93		return;
94	}
95
96	if (!lazyLoadService.inlineScriptsStored.length) {
97		return;
98	}
99
100	lazyLoadService.inlineScriptsStored.map((script) => {
101		lazyLoadService.appendHtml(script.element, script.html);
102	});
103
104	lazyLoadService.inlineScriptsStored = [];
105}
106
107lazyLoadService.appendVideosToDOM = function() {
108	if (lazyLoadService.videosStored === undefined) {
109		return;
110	}
111
112	if (!lazyLoadService.videosStored.length) {
113		return;
114	}
115
116	lazyLoadService.videosStored.map((video) => {
117		document.querySelector(video.element).innerHTML = video.html;
118	});
119}
120
121lazyLoadService.runEnqueuedFunctionsAfterInteraction = function() {
122	if (lazyLoadService.functionsAfterInteractionStored === undefined) {
123		return;
124	}
125
126	if (!lazyLoadService.functionsAfterInteractionStored.length) {
127		return;
128	}
129
130	lazyLoadService.functionsAfterInteractionStored.map(func => {
131		func();
132	});
133
134	lazyLoadService.functionsAfterInteractionStored = [];
135}
136
137lazyLoadService.runEnqueuedFunctions = function() {
138	if (lazyLoadService.functionsStored === undefined) {
139		return;
140	}
141
142	if (!lazyLoadService.functionsStored.length) {
143		return;
144	}
145
146	lazyLoadService.functionsStored.map(func => {
147		func();
148	});
149
150	lazyLoadService.functionsStored = [];
151}
152
153lazyLoadService.executeFunctions = function() {
154	lazyLoadService.eventExecuted = true;
155
156	lazyLoadService.appendScriptTagsToDOM();
157	lazyLoadService.appendInlineScriptsToDOM();
158	lazyLoadService.runEnqueuedFunctions();
159	lazyLoadService.appendVideosToDOM();
160}
161
162lazyLoadService.executeFunctionsAfterInteraction = function() {
163	lazyLoadService.runEnqueuedFunctionsAfterInteraction();
164}
165
166lazyLoadService.runLazyloadFunctions = function() {
167	setTimeout(() => {
168		document.addEventListener('scroll', triggerFunctions);
169		document.addEventListener('mousemove', triggerFunctions);
170		document.addEventListener('touchstart', triggerFunctions);
171	} , 3500);
172
173	function triggerFunctions(event) {
174		event.currentTarget.removeEventListener(event.type, triggerFunctions);
175
176		if (lazyLoadService.eventExecuted) {
177			return;
178		}
179
180		lazyLoadService.executeFunctions();
181		console.log("functions executed with lazyload");
182	}
183}
184
185lazyLoadService.runLazyLoadFunctionsAfterFirstInteraction = function() {
186	function triggerAfterInteractions(event) {
187		event.currentTarget.removeEventListener(event.type, triggerAfterInteractions);
188
189		if (lazyLoadService.eventAfterFirstInteractionExecuted) {
190			return;
191		}
192
193		lazyLoadService.executeFunctionsAfterInteraction();
194		lazyLoadService.eventAfterFirstInteractionExecuted = true;
195		console.log("functions lazy after first interaction executed");
196	}
197
198	document.addEventListener('scroll', triggerAfterInteractions);
199	document.addEventListener('mousemove', triggerAfterInteractions);
200	document.addEventListener('touchstart', triggerAfterInteractions);
201}
202
203lazyLoadService.loadNoScriptHtml = (selector = "lazyload-html") => {
204	const data =  document.querySelectorAll(`[${selector}]`);
205
206	if (!data) {
207		return;
208	}
209
210	data.forEach(item => {
211		let element = item.getAttribute(selector);
212		let html = document.querySelector(element);
213
214		const parser = new DOMParser();
215		const dom = parser.parseFromString(item.innerText, "text/html");
216
217		if (html) {
218			html.innerHTML += dom.querySelector('body').innerHTML;
219		}
220
221		item.remove();
222	});
223}
224
225document.addEventListener('DOMContentLoaded', () => {
226	let path = window.location.pathname;
227
228	if (/\/(compra|cliente|pedido|vendedor|catalogo|contarecebimento|historicocupom|mercadopago)\/.*/i.test(path)) {
229		lazyLoadService.executeFunctions();
230		lazyLoadService.executeFunctionsAfterInteraction();
231		console.log("functions executed without lazyload");
232	} else {
233		lazyLoadService.runLazyloadFunctions();
234		lazyLoadService.runLazyLoadFunctionsAfterFirstInteraction();
235	}
236});

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.