PageSourceSearch

https://thebakeryphx.com/js/common.js

js thebakeryphx.com collected 2026-10-07 03:20:43 UTC 17,218 bytes, 594 lines download raw bytes

1function AJAX(G) {
2	var K = [],
3	$ = this,
4	L = AJAX.__pool__ || (AJAX.__pool__ = []); (function(E) {
5		var D = function() {};
6		E = E ? E: {};
7		var C = ["url", "content", "method", "async", "encode", "timeout", "ontimeout", "onrequeststart", "onrequestend", "oncomplete", "onexception"],
8		A = ["", "", "GET", true, I("GBK"), 3600000, D, D, D, D, D],
9		B = C.length;
10		while (B--) $[C[B]] = _(E[C[B]], A[B]);
11		if (!N()) return false;
12	})(G);
13	function _(_, $) {
14		return _ != undefined ? _: $
15	}
16	function N() {
17		var A, $ = [window.XMLHttpRequest, "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
18		for (var B = 0; B < L.length; B += 1) if (L[B].readyState == 0 || L[B].readyState == 4) return L[B];
19		for (B = 0; B < $.length; B += 1) {
20			try {
21				if (window.XMLHttpRequest) {
22					A = ($[B] && typeof($[B]) == "function" ? new $[B] : new XMLHttpRequest($[B]));
23				}else
24				{
25					A = ($[B] && typeof($[B]) == "function" ? new $[B] : new ActiveXObject($[B]));
26				}	
27				break
28			} catch(_) {
29				A = false;
30				continue
31			}
32		}
33		if (!A) {
34			throw "Cannot init XMLHttpRequest object!";
35			return false
36		} else {
37			L[L.length] = A;
38			
39			return A
40		}
41	}
42	function E($) {
43		return document.getElementById($)
44	}
45	function C($) {
46		var _ = $ * 1;
47		return (isNaN(_) ? 0 : _)
48	}
49	function D($) {
50		return (typeof($) == "string" ? ($ = E($)) ? $: false: $)
51	}
52	function F() {
53		return ((new Date) * 1)
54	}
55	function M($, _) {
56		K[$ + ""] = _
57	}
58	function H($) {
59		return (K[$ + ""])
60	}
61	function J(_, $, B) {
62		return (function A(C) {
63			C = C.replace(/([^\u0080-\u00FF]+)/g,
64			function($0, $1) {
65				return _($1)
66			}).replace(/([\u0080-\u00FF])/g,
67			function($0, $1) {
68				return escape($1).replace("%", "%u00")
69			});
70			for (var E = 0,
71			D = $.length; E < D; E += 1) C = C.replace($[E], B[E]);
72			return (C)
73		})
74	}
75	function I($) {
76		if ($.toUpperCase() == "UTF-8") return (encodeURIComponent);
77		else return (J(escape, [/\+/g], ["%2B"]))
78	}
79	function O(A, B) {
80		if (!A.nodeName) return;
81		var _ = "|" + A.nodeName.toUpperCase() + "|";
82		if ("|INPUT|TEXTAREA|OPTION|".indexOf(_) > -1) A.value = B;
83		else {
84			try {
85				A.innerHTML = B
86			} catch($) {}
87		}
88	}
89	function P(_) {
90		if (typeof(_) == "function") return _;
91		else {
92			_ = D(_);
93			if (_) return (function($) {
94				O(_, $.responseText)
95			});
96			else return $.oncomplete
97		}
98	}
99	function B(_, A, $) {
100		var C = 0,
101		B = [];
102		while (C < _.length) {
103			B[C] = _[C] ? ($[C] ? $[C](_[C]) : _[C]) : A[C];
104			C += 1
105		}
106		while (C < A.length) {
107			B[C] = A[C];
108			C += 1
109		}
110		return B
111	}
112	function A() {
113		var E, C = false,
114		K = N(),
115		J = B(arguments, [$.url, $.content, $.oncomplete, $.method, $.async, null], [null, null, P, null, null, null]),
116		G = J[0],
117		I = J[1],
118		L = J[2],
119		M = J[3],
120		H = J[4],
121		A = J[5],
122		O = M.toUpperCase() == "POST" ? true: false;
123		if (!G) {
124			throw "url is null";
125			return false
126		}
127		var _ = {
128			url: G,
129			content: I,
130			method: M,
131			params: A
132		};
133		if (!O) G += (G.indexOf("?") > -1 ? "&": "?") + "timestamp=" + F();
134		K.open(M, G, H);
135		$.onrequeststart(_);
136		if (O) K.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
137		K.setRequestHeader("X-Request-With", "XMLHttpRequest");
138		E = setTimeout(function() {
139			C = true;
140			K.abort()
141		},
142		$.timeout);
143		var D = function() {
144			if (C) {
145				$.ontimeout(_);
146				$.onrequestend(_)
147			} else if (K.readyState == 4) {
148				clearTimeout(E);
149				_.status = K.status;
150				try {
151					if (K.status == 200) L(K, A);
152					else $.onexception(_)
153				} catch(B) {
154					$.onexception(_)
155				}
156				$.onrequestend(_)
157			}
158		};
159		K.onreadystatechange = D;
160		if (O) K.send(I);
161		else K.send("");
162		if (H == false) D();
163		return true
164	}
165	this.setcharset = function(_) {
166		if (!$.encode) $.encode = I(_)
167	};
168	this.get = function(C, B, _) {
169		return A(C, "", B, "GET", $.async, _)
170	};
171	this.update = function(H, J, _, D, E) {
172		_ = C(_);
173		D = C(D);
174		if (_ < 1) D = 1;
175		var B = function() {
176			A(J, "", H, "GET", $.async, E)
177		},
178		G = F(),
179		I = function($) {
180			B();
181			$--;
182			if ($ > 0) M(G, setTimeout(function() {
183				I($)
184			},
185			_))
186		};
187		I(D);
188		return G
189	};
190	this.stopupdate = function($) {
191		clearTimeout(H($))
192	};
193	this.post = function(D, _, C, B) {
194		return A(D, _, C, "POST", $.async, B)
195	};
196	this.postf = function(O, J, B) {
197		var H = [],
198		L,
199		_,
200		G,
201		I,
202		M,
203		K = arguments.length,
204		C = arguments;
205		O = O ? D(O) : false;
206		if (!O || O.nodeName != "FORM") return false;
207		validfoo = O.getAttribute("onvalidate");
208		validfoo = validfoo ? (typeof(validfoo) == "string" ? new Function(validfoo) : validfoo) : null;
209		if (validfoo && !validfoo()) return false;
210		var E = O.getAttribute("action"),
211		N = O.getAttribute("method"),
212		F = $.formToStr(O);
213		if (F.length == 0) return false;
214		if (N.toUpperCase() == "POST") return A(E, F, J, "POST", true, B);
215		else {
216			E += (E.indexOf("?") > -1 ? "&": "?") + F;
217			return A(E, "", J, "GET", true, B)
218		}
219	};
220	this.formToStr = function(C) {
221		var B = "",
222		E = "",
223		_, A;
224		for (var D = 0; D < C.length; D += 1) {
225			_ = C[D];
226			if (_.name != "") {
227				switch (_.type) {
228				case "select-one":
229					if (_.selectedIndex > -1) A = _.options[_.selectedIndex].value;
230					else A = "";
231					break;
232				case "checkbox":
233				case "radio":
234					if (_.checked == true) A = _.value;
235					break;
236				default:
237					A = _.value
238				}
239				A = $.encode(A);
240				B += E + _.name + "=" + A;
241				E = "&"
242			}
243		}
244		return B
245	}
246}
247//-------------------------------------------------------
248
249
250function checkAll(bool,tagname,name)
251{
252	var checkboxArray;checkboxArray=getElementsByName(tagname,name)
253	for (var i=0;i<checkboxArray.length;i++){checkboxArray[i].checked = bool;}
254}
255
256function checkOthers(tagname,name)
257{
258	var checkboxArray;checkboxArray=getElementsByName(tagname,name)
259	for (var i=0;i<checkboxArray.length;i++){
260		if (checkboxArray[i].checked == false){
261			checkboxArray[i].checked = true;
262		}else if (checkboxArray[i].checked == true){
263			checkboxArray[i].checked = false;
264		}
265	}
266}
267
268function textareasize(obj){
269	if(obj.scrollHeight > 70){
270		obj.style.height = obj.scrollHeight + 'px';
271	}
272}
273
274function set(obj,value){
275	obj.innerHTML = value
276}
277
278function view(id){
279	document.getElementById(id).style.display='inline'	
280}
281
282function hide(id){
283	document.getElementById(id).style.display='none'		
284}
285
286function getScroll(){var t;if(document.documentElement&&document.documentElement.scrollTop){t=document.documentElement.scrollTop;}else if(document.body){t=document.body.scrollTop;}return(t);} 
287
288
289function HtmlEncode(str)
290{   
291	 var s = "";
292	 if(str.length == 0) return "";
293	 s    =    str.replace(/&/g,"&amp;");
294	 s    =    s.replace(/</g,"&lt;");
295	 s    =    s.replace(/>/g,"&gt;");
296	 s    =    s.replace(/ /g,"&nbsp;");
297	 s    =    s.replace(/\'/g,"&#39;");
298	 s    =    s.replace(/\"/g,"&quot;"); 
299	 return   s;   
300}  
301
302function getElementsByName(tag,name){
303    var rtArr=new Array();
304    var el=document.getElementsByTagName(tag);
305    for(var i=0;i<el.length;i++){
306        if(el[i].name==name)
307              rtArr.push(el[i]);
308    }
309    return rtArr;
310}
311
312function closeWin(){
313	document.body.removeChild(document.getElementById("bg")); 
314	document.body.removeChild(document.getElementById("msg"));
315	if(document.getElementById("searchtype"))document.getElementById("searchtype").style.display="";
316}
317
318function openWindow(zindex,width,height,alpha){
319	var iWidth = document.documentElement.scrollWidth; 
320	var iHeight = document.documentElement.clientHeight; 
321	var bgDiv = document.createElement("div");
322	bgDiv.id="bg";
323	bgDiv.style.cssText = "top:0;width:"+iWidth+"px;height:"+document.documentElement.scrollHeight+"px;filter:Alpha(Opacity="+alpha+");opacity:0.3;z-index:"+zindex+";";
324	document.body.appendChild(bgDiv); 
325	var msgDiv=document.createElement("div");
326	msgDiv.id="msg";
327	msgDiv.style.cssText ="z-index:"+(zindex+1)+";width:"+width+"px; height:"+(parseInt(height)-0+29+16)+"px;left:"+((iWidth-width-2)/2)+"px;top:"+(getScroll()+(height=="auto"?150:(iHeight>(parseInt(height)+29+2+16+30)?(iHeight-height-2-29-16-30)/2:0)))+"px";
328	msgDiv.innerHTML="<div class='msgtitle'><div id='msgtitle'></div><img onclick='closeWin()' src='/"+sitePath+"pic/btn_close.gif' /></div><div id='msgbody' style='height:"+height+"px'></div>";
329	document.body.appendChild(msgDiv);
330}
331
332function openWindow2(zindex,width,height,alpha){
333	var iWidth = document.documentElement.scrollWidth; 
334	var bgDiv = document.createElement("div");
335	bgDiv.id="bg";
336	bgDiv.style.cssText = "top:0;width:"+iWidth+"px;height:"+document.documentElement.scrollHeight+"px;filter:Alpha(Opacity="+alpha+");opacity:0.3;z-index:"+zindex+";";
337	document.body.appendChild(bgDiv); 
338	var msgDiv=document.createElement("div");
339	msgDiv.id="msg";
340	msgDiv.style.cssText ="position: absolute;z-index:"+(zindex+1)+";width:"+width+"px; height:"+(height=="auto"?height:(height+"px"))+";";
341	document.body.appendChild(msgDiv);	
342}
343
344function selectTogg(){
345	var selects=document.getElementsByTagName("select");
346	for(var i=0;i<selects.length;i++){
347		selects[i].style.display=(selects[i].style.display=="none"?"":"none");
348	}
349}
350function checkInput(str,type){
351	switch(type){
352		case "mail":
353			if(!/^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi.test(str)){alert('邮箱填写错误');return false;}
354			break;
355		case "num" :
356			if(isNaN(str)){alert('QQ填写错误');return false;}
357			break;
358	}
359	return true;
360}
361
362function copyToClipboard(txt) {    
363	if(window.clipboardData){    
364		window.clipboardData.clearData();    
365		window.clipboardData.setData("Text", txt);
366		alert('复制成功!')
367	}else{
368		alert('请手动复制!')	
369	}   
370}
371function getUrlArgs()   
372  {   
373     return  location.pathname;
374  }
375
376// 全局图片智能5秒超时与通用懒加载容错机制(滚动入屏自动计时5秒,超时/失败100%兜底显示 /pic/nopic.gif)
377(function(){
378  var IMG_TIMEOUT = 5000; // 单图独立等待5秒
379  var FALLBACK_IMG = '/pic/nopic.gif'; // 系统默认缺省海报占位图
380
381  // 1. 处理标准 <img> 标签
382  function monitorImg(img) {
383    if (!img || img._monitored) return;
384    img._monitored = true;
385    
386    var timer = null;
387    function startTimer() {
388      if (timer) clearTimeout(timer);
389      if (!img.src || img.src.indexOf('data:') === 0 || img.src.indexOf(FALLBACK_IMG) !== -1 || img.complete) return;
390      timer = setTimeout(function() {
391        if (!img.complete || (typeof img.naturalWidth !== 'undefined' && img.naturalWidth === 0)) {
392          try {
393            img.src = FALLBACK_IMG;
394            img.classList.add('img-timeout-aborted');
395          } catch(e){}
396        }
397      }, IMG_TIMEOUT);
398    }
399
400    img.addEventListener('load', function() { if (timer) clearTimeout(timer); });
401    img.addEventListener('error', function() {
402      if (timer) clearTimeout(timer);
403      try { img.src = FALLBACK_IMG; } catch(e){}
404    });
405
406    if (window.MutationObserver) {
407      var srcObserver = new MutationObserver(function(mutations) {
408        for (var i = 0; i < mutations.length; i++) {
409          if (mutations[i].attributeName === 'src') startTimer();
410        }
411      });
412      srcObserver.observe(img, { attributes: true, attributeFilter: ['src'] });
413    }
414    startTimer();
415  }
416
417  // 2. 核心:通用懒加载元素视口观察器(覆盖所有影视/短剧模板中的 fed-lazy, lazyload, data-original 等)
418  var observer = null;
419  if (window.IntersectionObserver) {
420    observer = new IntersectionObserver(function(entries) {
421      entries.forEach(function(entry) {
422        if (entry.isIntersecting || entry.intersectionRatio > 0) {
423          var el = entry.target;
424          observer.unobserve(el);
425          handleLazyLoad(el);
426        }
427      });
428    }, { rootMargin: '150px' });
429  }
430
431  function handleLazyLoad(el) {
432    if (!el || el._handledLazy) return;
433    el._handledLazy = true;
434
435    var rawUrl = el.getAttribute('data-original') || el.getAttribute('data-background') || el.getAttribute('data-src') || '';
436    if (!rawUrl && el.style && el.style.backgroundImage) {
437      var m = el.style.backgroundImage.match(/url\(["']?([^"']+)["']?\)/);
438      if (m && m[1] && m[1].indexOf('http') === 0) rawUrl = m[1];
439    }
440
441    if (!rawUrl || rawUrl.indexOf('http') !== 0) return;
442
443    var testImg = new Image();
444    var timer = setTimeout(function() {
445      // 5秒超时无法加载完成,直接将元素设为默认占位图 /pic/nopic.gif
446      if (!testImg.complete || (typeof testImg.naturalWidth !== 'undefined' && testImg.naturalWidth === 0)) {
447        testImg.src = '';
448        applyFallback(el);
449      }
450    }, IMG_TIMEOUT);
451
452    testImg.onload = function() {
453      clearTimeout(timer);
454      if (el.tagName === 'IMG') {
455        el.src = rawUrl;
456      } else {
457        el.style.backgroundImage = 'url("' + rawUrl + '")';
458      }
459    };
460
461    testImg.onerror = function() {
462      clearTimeout(timer);
463      applyFallback(el);
464    };
465
466    testImg.src = rawUrl;
467  }
468
469  function applyFallback(el) {
470    try {
471      if (el.tagName === 'IMG') {
472        el.src = FALLBACK_IMG;
473      } else {
474        el.style.backgroundImage = 'url("' + FALLBACK_IMG + '")';
475      }
476      el.classList.add('img-fallback-applied');
477    } catch(e){}
478  }
479
480  function monitorLazyElem(el) {
481    if (!el || el._observed) return;
482    el._observed = true;
483    if (observer) {
484      observer.observe(el);
485    } else {
486      // 降级支持老旧浏览器
487      handleLazyLoad(el);
488    }
489  }
490
491  function init() {
492    var imgs = document.getElementsByTagName('img');
493    for (var i = 0; i < imgs.length; i++) monitorImg(imgs[i]);
494    
495    var lazyElems = document.querySelectorAll('.fed-lazy, .lazy, .lazyload, .stui-vodlist__thumb, [data-original], [data-background], [data-src]');
496    for (var j = 0; j < lazyElems.length; j++) monitorLazyElem(lazyElems[j]);
497
498    if (window.MutationObserver) {
499      var docObserver = new MutationObserver(function() {
500        var newImgs = document.getElementsByTagName('img');
501        for (var k = 0; k < newImgs.length; k++) monitorImg(newImgs[k]);
502        var newLazy = document.querySelectorAll('.fed-lazy, .lazy, .lazyload, .stui-vodlist__thumb, [data-original], [data-background], [data-src]');
503        for (var l = 0; l < newLazy.length; l++) monitorLazyElem(newLazy[l]);
504      });
505      docObserver.observe(document.documentElement, { childList: true, subtree: true });
506    }
507  }
508
509  if (document.readyState === 'loading') {
510    document.addEventListener('DOMContentLoaded', init);
511  } else {
512    init();
513  }
514})();
515//
516
517// =======================================================
518
519// ==============================================================================
520// ⚡ SeaCMS 智能首屏秒开与流式视口直显引擎 (Zero-Delay Smart Viewport Engine)
521// 1. 首屏视口内图片 0 毫秒同步直显(前 24 张海报无延迟并发秒出)
522// 2. 视口外底部图片使用 IntersectionObserver 预加载(防止 80+ 图片一次性塞满带宽导致标签栏转圈)
523// ==============================================================================
524(function() {
525  var FALLBACK = '/pic/nopic.gif';
526  
527  function applyPic(el) {
528    if (!el || el._directApplied) return;
529    el._directApplied = true;
530    
531    var raw = el.getAttribute('data-original') || el.getAttribute('data-background') || el.getAttribute('data-src');
532    if (!raw && el.style && el.style.backgroundImage) {
533      var m = el.style.backgroundImage.match(/url\(["']?([^"']+)["']?\)/);
534      if (m && m[1] && m[1].indexOf('http') === 0) raw = m[1];
535    }
536    
537    if (raw && raw.indexOf('http') === 0) {
538      if (el.tagName === 'IMG') {
539        el.src = raw;
540        el.onerror = function() { el.src = FALLBACK; };
541      } else {
542        el.style.backgroundImage = 'url("' + raw + '")';
543      }
544      el.classList.add('fed-lazy-loaded');
545    }
546  }
547
548  var observer = null;
549  if (window.IntersectionObserver) {
550    observer = new IntersectionObserver(function(entries) {
551      for (var i = 0; i < entries.length; i++) {
552        var entry = entries[i];
553        if (entry.isIntersecting || entry.intersectionRatio > 0) {
554          observer.unobserve(entry.target);
555          applyPic(entry.target);
556        }
557      }
558    }, { rootMargin: '600px 0px 600px 0px' });
559  }
560
561  function smartScan() {
562    var nodes = document.querySelectorAll('.fed-lazy, .fed-swip-lazy, .lazy, .lazyload, .stui-vodlist__thumb, [data-original], [data-background], [data-src]');
563    var vpH = window.innerHeight || 800;
564    
565    for (var i = 0; i < nodes.length; i++) {
566      var el = nodes[i];
567      if (el._directApplied) continue;
568      
569      // 首屏直接展示,无需等 observer;视口外加入高速预加载 observer
570      var rect = el.getBoundingClientRect();
571      if (rect.top < vpH * 1.5 || i < 20) {
572        applyPic(el);
573      } else if (observer) {
574        observer.observe(el);
575      } else {
576        applyPic(el);
577      }
578    }
579  }
580
581  // 1. DOM 构建阶段即执行首屏
582  if (document.readyState === 'loading') {
583    document.addEventListener('DOMContentLoaded', smartScan);
584  } else {
585    smartScan();
586  }
587
588  // 2. 极速巡检
589  setTimeout(smartScan, 20);
590  setTimeout(smartScan, 150);
591  setTimeout(smartScan, 500);
592
593  window.addEventListener('scroll', smartScan, { passive: true });
594})();

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.