PageSourceSearch

https://www.mfa.gov.cn/eng/static/common/js/rem.js

js mfa.gov.cn collected 2026-10-02 02:16:39 UTC 1,512 bytes, 59 lines download raw bytes

1;(function (designWidth, maxWidth) {
2	let doc = document,
3		win = window;
4	let docEl = doc.documentElement;
5	let tid;
6	let rootItem, rootStyle;
7
8	function refreshRem() {
9		let width = docEl.getBoundingClientRect().width;
10		if (width > maxWidth) {
11			width = maxWidth;
12		}
13		//2rem=1px
14		// let rem = width / 2 / designWidth;
15
16		//1rem=1px
17		let rem = width / designWidth;
18		//兼容UC开始
19		rootStyle = "html{font-size:" + rem + 'px !important}';
20		rootItem = document.getElementById('rootsize') || document.createElement("style");
21		if (!document.getElementById('rootsize')) {
22			document.getElementsByTagName("head")[0].appendChild(rootItem);
23			rootItem.id = 'rootsize';
24		}
25		if (rootItem.styleSheet) {
26			rootItem.styleSheet.disabled || (rootItem.styleSheet.cssText = rootStyle)
27		} else {
28			try {
29				rootItem.innerHTML = rootStyle
30			} catch (f) {
31				rootItem.innerText = rootStyle
32			}
33		}
34		//兼容UC结束
35		docEl.style.fontSize = rem + "px";
36	}
37
38	refreshRem();
39
40	win.addEventListener("resize", function () {
41		clearTimeout(tid); //防止执行两次
42		tid = setTimeout(refreshRem, 100);
43	}, false);
44
45	win.addEventListener("pageshow", function (e) {
46		if (e.persisted) { // 浏览器后退的时候重新计算
47			clearTimeout(tid);
48			tid = setTimeout(refreshRem, 100);
49		}
50	}, false);
51
52	if (doc.readyState === "complete") {
53		doc.body.style.fontSize = "16px";
54	} else {
55		doc.addEventListener("DOMContentLoaded", function (e) {
56			doc.body.style.fontSize = "16px";
57		}, false);
58	}
59})(768, 768);

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.