PageSourceSearch

https://ca.csu.edu.cn/authserver/gorgeousCsu20260806/static/common/common-header.js?v=20260922.133736

js csu.edu.cn collected 2026-10-02 03:15:41 UTC 13,714 bytes, 505 lines download raw bytes

1var isMobile = false;
2$(function () {
3    if(typeof commonHeaderinit === "function"){
4    	commonHeaderinit();
5    }
6    //如果logo不存在就不显示
7    $("#logo").on("error",function(){
8    	//如果没有就不显示,防止显示没有图片小图标
9    	$(this).hide();
10    });
11
12	//校验是否为钉钉小程序,如果是登录form的post改为get
13	var interv = setInterval(function(){
14		if($("#loginFromId")){
15			var ua = navigator.userAgent;
16			if(ua.match(/.*iPhone.*DingTalk.*Nebula dd-web.*/)){
17				$("#loginFromId").attr("method", "get");
18			}
19			window.clearInterval(interv);
20		}
21	},500);
22
23	generateFingerPrint(function(r) {
24		console.log('Generated and stored fingerprint');
25	});
26});
27
28function commonHeaderinit() {
29    $.ajax(contextPath + "/tenant/info", {
30        dataType: "json",
31        success: function (data) {
32        	var logoSrc = "";
33        	var bgUrl = "";
34        	var themeName = data.themeName;
35			var themeColorMode = data.themeColorMode;
36			if(themeColorMode && themeColorMode == "1"){
37				//主题黑白色
38				var cssText = "filter:grayscale(100%);-webkit-filter:grayscale(100%);-moz-filter:grayscale(100%);-ms-filter:grayscale(100%);-o-filter:grayscale(100%);"
39				utils.addCss($(".root-main"), cssText)
40			}
41        	if(data.mobileFlay!=undefined && data.mobileFlay){
42        		isMobile = true;
43        		//移动端:logo设置和背景设置
44                if (data.schoolLogoUrlMobile!=undefined && data.schoolLogoUrlMobile!="") {
45                	logoSrc = data.schoolLogoUrlMobile;
46                }else{
47                	logoSrc = contextPath+"/"+themeName+"/static/common/images/mobile_logo.png";
48                }
49            	if (data.schoolBgUrlMobile!=undefined && data.schoolBgUrlMobile!="") {
50            		bgUrl = data.schoolBgUrlMobile;
51                }else{
52                	bgUrl = contextPath+"/"+themeName+"/static/common/images/mobile_bg.png";
53                }
54        	}else{
55        		//PC端:logo设置和背景设置
56                if (data.schoolLogoUrlPc!=undefined && data.schoolLogoUrlPc!="") {
57                	logoSrc = data.schoolLogoUrlPc;
58                }else{
59                	logoSrc = contextPath+"/"+themeName+"/static/common/images/pc_logo.png";
60                }
61				jsonObject= window.jsonObject==undefined?{}:jsonObject;
62				if (jsonObject.defaultImage==1){//自定义
63					if (jsonObject.imageType==1){//轮播
64						//实现多图轮播
65						var swiper = new Swiper('.swiper-container', {
66							autoplay: (jsonObject.shufflingTime)*1000,	//轮播时间
67							autoplayDisableOnInteraction: false, // 手动切换之后继续自动轮播
68							speed: jsonObject.shufflingStyle == 1 ? 5 : 1000, // 切换速度(1切换 2平移)
69							loop: true,
70							pagination: '.swiper-pagination',
71							paginationClickable: true
72						})
73					}
74				}else{//默认
75					if (data.schoolBgUrlPc!=undefined && data.schoolBgUrlPc!="") {
76						bgUrl = data.schoolBgUrlPc;//取数据库
77					}else{//取初始图片
78						bgUrl = contextPath+"/"+themeName+"/static/common/images/pc_bg.png";
79					}
80				}
81        	}
82        	$("#logo").attr("src", logoSrc);
83			$("#bg").css("background-image", "url(" + bgUrl + ")")
84			$("#bg").css("background-size","100% 100%")
85			$("#bg").css("background-attachment","fixed");
86        }
87    });
88}
89
90//设置浏览器cookie
91function setBFP(_3b){
92	$.ajax(contextPath + "/bfp/info", {
93		data: { bfp: _3b },
94		cache: false,
95		dataType: "json",
96		success: function (data) {
97
98		}
99	});
100
101}
102
103function getCookie(cookie_name) {
104    var allcookies = document.cookie;
105    var cookie_pos = allcookies.indexOf(cookie_name);
106    if (cookie_pos != -1) {
107        cookie_pos += cookie_name.length + 1;
108        var cookie_end = allcookies.indexOf(";", cookie_pos);
109        if (cookie_end == -1) {
110            cookie_end = allcookies.length;
111        }
112        var value = unescape(allcookies.substring(cookie_pos, cookie_end));
113    }
114    return value;
115}
116
117// 通过文件名获取当前脚本URL
118function getCurrentScriptUrl() {
119	var scripts = document.getElementsByTagName('script');
120	var currentScript = null;
121	for (var i = 0; i < scripts.length; i++) {
122		if (scripts[i].src.indexOf('common-header.js') !== -1) {
123			currentScript = scripts[i];
124			break;
125		}
126	}
127	return currentScript ? currentScript.src : '';
128}
129
130// 获取基础路径
131function getBasePath() {
132	var url = getCurrentScriptUrl();
133	if (!url) {
134		console.error('Failed to get current script URL');
135		return '';
136	}
137	return url.substring(0, url.lastIndexOf('/') + 1);
138}
139
140// 1. 加载本地JS文件
141function loadScript(scriptName) {
142	// 获取当前可用的Promise实现
143	var PromiseImpl = window.Promise || (function() {
144		var PromisePolyfill = function(executor) {
145			var self = this;
146			self.status = 'pending';
147			self.value = undefined;
148			self.reason = undefined;
149			self.onFulfilledCallbacks = [];
150			self.onRejectedCallbacks = [];
151
152			function resolve(value) {
153				if (self.status === 'pending') {
154					self.status = 'fulfilled';
155					self.value = value;
156					self.onFulfilledCallbacks.forEach(function(callback) {
157						callback(value);
158					});
159				}
160			}
161
162			function reject(reason) {
163				if (self.status === 'pending') {
164					self.status = 'rejected';
165					self.reason = reason;
166					self.onRejectedCallbacks.forEach(function(callback) {
167						callback(reason);
168					});
169				}
170			}
171
172			try {
173				executor(resolve, reject);
174			} catch (e) {
175				reject(e);
176			}
177		};
178
179		PromisePolyfill.prototype.then = function(onFulfilled, onRejected) {
180			var self = this;
181			var promise2 = new PromisePolyfill(function(resolve, reject) {
182				if (self.status === 'fulfilled') {
183					setTimeout(function() {
184						try {
185							var x = onFulfilled(self.value);
186							resolve(x);
187						} catch (e) {
188							reject(e);
189						}
190					}, 0);
191				}
192				if (self.status === 'rejected') {
193					setTimeout(function() {
194						try {
195							var x = onRejected(self.reason);
196							resolve(x);
197						} catch (e) {
198							reject(e);
199						}
200					}, 0);
201				}
202				if (self.status === 'pending') {
203					self.onFulfilledCallbacks.push(function(value) {
204						setTimeout(function() {
205							try {
206								var x = onFulfilled(value);
207								resolve(x);
208							} catch (e) {
209								reject(e);
210							}
211						}, 0);
212					});
213					self.onRejectedCallbacks.push(function(reason) {
214						setTimeout(function() {
215							try {
216								var x = onRejected(reason);
217								resolve(x);
218							} catch (e) {
219								reject(e);
220							}
221						}, 0);
222					});
223				}
224			});
225			return promise2;
226		};
227
228		PromisePolyfill.prototype.catch = function(onRejected) {
229			return this.then(null, onRejected);
230		};
231
232		return PromisePolyfill;
233	})();
234
235	return new PromiseImpl(function(resolve, reject) {
236		var basePath = getBasePath();
237		if (!basePath) {
238			reject(new Error('Invalid base path'));
239			return;
240		}
241
242		var fullPath = basePath + scriptName;
243		console.log('Loading script from: ' + fullPath); // 调试用
244
245		var script = document.createElement('script');
246		script.src = fullPath;
247
248		script.onload = function() {
249			console.log('Successfully loaded: ' + fullPath);
250			resolve();
251		};
252
253		script.onerror = function(error) {
254			console.error('Failed to load: ' + fullPath, error);
255			reject(error);
256		};
257
258		document.head.appendChild(script);
259	});
260}
261
262// 2. 获取浏览器信息
263function getNavigatorInfo() {
264	return {
265		platform: navigator.platform,
266		language: navigator.language,
267		hardwareConcurrency: navigator.hardwareConcurrency || 0,
268		maxTouchPoints: navigator.maxTouchPoints || 0,
269		deviceMemory: navigator.deviceMemory || 0
270	};
271}
272
273// 3. 生成Canvas指纹
274function createDataUrl() {
275	var canvas = document.createElement("canvas");
276	canvas.setAttribute("width", 220);
277	canvas.setAttribute("height", 30);
278	var ctx = canvas.getContext("2d");
279
280	var txt = "WiseduCiap,com <canvas> 1.0";
281	ctx.textBaseline = "top";
282	ctx.font = "14px 'Arial'";
283	ctx.textBaseline = "alphabetic";
284	ctx.fillStyle = "#f60";
285	ctx.fillRect(112, 1, 62, 20);
286	ctx.fillStyle = "#069";
287	ctx.fillText(txt, 2, 15);
288	ctx.fillStyle = "rgba(102, 204, 0, 0.7)";
289	ctx.fillText(txt, 4, 17);
290
291	var dataUrl = canvas.toDataURL();
292	var rawData = atob(dataUrl.split(",")[1]);
293
294	return {
295		dataUrl : dataUrl,
296		rawData : rawData
297	};
298}
299
300// 4. 生成Hash
301function createHash(rawData) {
302	if (!rawData) {
303		return "N/A";
304	}
305	var dataArr;
306	try {
307		dataArr = new Uint8Array(rawData.length);
308		for (var i = 0; i < rawData.length; i++) {
309			dataArr[i] = rawData.charCodeAt(i);
310		}
311	} catch(e) {
312		// 如果 Uint8Array 不可用,使用普通数组
313		dataArr = [];
314		for (var i = 0; i < rawData.length; i++) {
315			dataArr.push(rawData.charCodeAt(i));
316		}
317	}
318	return md5(dataArr).toUpperCase();
319}
320
321// 5. 生成混合Hash
322function createMixHash(browserInfo, navigatorInfo, canvasHash) {
323	var items = [];
324
325	// 添加浏览器信息
326	items.push((browserInfo.browser || {}).name || "-");
327	items.push((browserInfo.engine || {}).name || "-");
328	items.push((browserInfo.os || {}).name || "-");
329	items.push((browserInfo.cpu || {}).architecture || "-");
330	items.push((browserInfo.device || {}).type || "-");
331	items.push((browserInfo.device || {}).model || "-");
332	items.push((browserInfo.device || {}).vendor || "-");
333
334	// 添加navigator信息
335	items.push(navigatorInfo.platform);
336	items.push(navigatorInfo.language);
337	items.push(navigatorInfo.hardwareConcurrency);
338	items.push(navigatorInfo.maxTouchPoints);
339	items.push(navigatorInfo.deviceMemory);
340
341	// 添加canvas hash
342	items.push(canvasHash);
343
344	return md5(items.join("|")).toUpperCase();
345}
346
347// 6. 生成完整指纹
348function generateFingerPrint(callback) {
349	try {
350		// 获取当前可用的Promise实现
351		var PromiseImpl = window.Promise || (function() {
352			var PromisePolyfill = function(executor) {
353				var self = this;
354				self.status = 'pending';
355				self.value = undefined;
356				self.reason = undefined;
357				self.onFulfilledCallbacks = [];
358				self.onRejectedCallbacks = [];
359
360				function resolve(value) {
361					if (self.status === 'pending') {
362						self.status = 'fulfilled';
363						self.value = value;
364						self.onFulfilledCallbacks.forEach(function(callback) {
365							callback(value);
366						});
367					}
368				}
369
370				function reject(reason) {
371					if (self.status === 'pending') {
372						self.status = 'rejected';
373						self.reason = reason;
374						self.onRejectedCallbacks.forEach(function(callback) {
375							callback(reason);
376						});
377					}
378				}
379
380				try {
381					executor(resolve, reject);
382				} catch (e) {
383					reject(e);
384				}
385			};
386
387			PromisePolyfill.prototype.then = function(onFulfilled, onRejected) {
388				var self = this;
389				var promise2 = new PromisePolyfill(function(resolve, reject) {
390					if (self.status === 'fulfilled') {
391						setTimeout(function() {
392							try {
393								var x = onFulfilled(self.value);
394								resolve(x);
395							} catch (e) {
396								reject(e);
397							}
398						}, 0);
399					}
400					if (self.status === 'rejected') {
401						setTimeout(function() {
402							try {
403								var x = onRejected(self.reason);
404								resolve(x);
405							} catch (e) {
406								reject(e);
407							}
408						}, 0);
409					}
410					if (self.status === 'pending') {
411						self.onFulfilledCallbacks.push(function(value) {
412							setTimeout(function() {
413								try {
414									var x = onFulfilled(value);
415									resolve(x);
416								} catch (e) {
417									reject(e);
418								}
419							}, 0);
420						});
421						self.onRejectedCallbacks.push(function(reason) {
422							setTimeout(function() {
423								try {
424									var x = onRejected(reason);
425									resolve(x);
426								} catch (e) {
427									reject(e);
428								}
429							}, 0);
430						});
431					}
432				});
433				return promise2;
434			};
435
436			PromisePolyfill.prototype.catch = function(onRejected) {
437				return this.then(null, onRejected);
438			};
439
440			PromisePolyfill.all = function(promises) {
441				return new PromisePolyfill(function(resolve, reject) {
442					var results = [];
443					var remaining = promises.length;
444
445					if (remaining === 0) {
446						resolve(results);
447						return;
448					}
449
450					function handlePromise(index, value) {
451						results[index] = value;
452						remaining--;
453						if (remaining === 0) {
454							resolve(results);
455						}
456					}
457
458					for (var i = 0; i < promises.length; i++) {
459						(function(i) {
460							promises[i].then(function(value) {
461								handlePromise(i, value);
462							}, reject);
463						})(i);
464					}
465				});
466			};
467
468			return PromisePolyfill;
469		})();
470
471		// 加载依赖
472		PromiseImpl.all([
473			loadScript('ua-parser.min.js'),
474			loadScript('md5.min.js')
475		]).then(function() {
476            //从 cookie 获取
477            var  fingerprint = getCookie("MULTIFACTOR_BROWSER_FINGERPRINT");
478            if(fingerprint == "" || fingerprint == null) {
479				//从localStorage 获取
480				fingerprint = window.localStorage.getItem("browser_fingerprint");
481				if(fingerprint == "" || fingerprint == null){
482                    // 获取浏览器信息
483                    var navigatorInfo = getNavigatorInfo();
484                    var browserInfo = new UAParser().getResult();
485                    // 生成canvas指纹
486                    var canvasData = createDataUrl();
487                    // 生成hash
488                    var canvasHash = createHash(canvasData.rawData);
489                    // 生成混合hash
490                    fingerprint = createMixHash(browserInfo, navigatorInfo, canvasHash);
491                    window.localStorage.setItem("browser_fingerprint", fingerprint);
492                }
493                // 存储到cookie,设置30天过期
494                setBFP(fingerprint);
495			}
496			callback(fingerprint);
497		}).catch(function(error) {
498			console.error('Failed to generate fingerprint:', error);
499			callback(null);
500		});
501	} catch (error) {
502		console.error('Failed to generate fingerprint:', error);
503		callback(null);
504	}
505}

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.