Files
jjx-web/static/gangcai-cal/flexible.js
T
2026-10-08 18:14:56 +08:00

52 lines
2.0 KiB
JavaScript

! function(e) {
var t, n = window.navigator.appVersion.match(/android/gi),
i = window.navigator.appVersion.match(/iphone/gi),
r = document,
a = r.documentElement,
o = r.querySelector('meta[name="viewport"]'),
d = e.freeze || o.hasAttribute("freeze"),
m = e.baseSize || 750,
s = e.baseFontSize || 100,
u = function() {
var e = document.createElement("div");
e.style.width = "1rem", e.style.display = "none", (document.head || document.getElementsByTagName("head")[
0]).appendChild(e);
var t = parseFloat(window.getComputedStyle(e, null).getPropertyValue("width"));
return e.parentNode.removeChild(e), t
}(),
c = window.devicePixelRatio || 1,
c = d ? 1 : c >= 3 ? 3 : c >= 2 ? 2 : 1,
l = 1 / c;
d || !n && !i || (o.setAttribute("content", "width=device-width,initial-scale=" + l + ",maximum-scale=" + l +
", minimum-scale=" + l + ",user-scalable=no"), a.setAttribute("data-dpr", c));
var p = function() {
var e = a.getBoundingClientRect().width;
e = n || i ? e > 540 * c ? 540 * c : e : 375;
var t = e / m * s;
a.style.fontSize = t / u * 100 + "%", window.rem = t
};
window.addEventListener("resize", function() {
clearTimeout(t), t = setTimeout(p, 300)
}, !1), window.addEventListener("pageshow", function(e) {
e.persisted && (clearTimeout(t), t = setTimeout(p, 300))
}, !1), "complete" === r.readyState ? r.body.style.fontSize = 12 * c + "px" : r.addEventListener(
"DOMContentLoaded",
function(e) {
r.body.style.fontSize = 12 * c + "px"
}, !1), p(), window.dpr = c, window.rem2px = function(e) {
var t = parseFloat(e) * this.rem;
return "string" == typeof e && e.match(/rem$/) && (t += "px")
}, window.px2rem = function(e) {
var t = parseFloat(e) / this.rem;
return "string" == typeof e && e.match(/px$/) && (t += "rem")
}
}(function() {
var e = document.getElementsByTagName("script"),
t = e[e.length - 1],
n = /flexible\.js\?(\d+)\&(\d+)(?:\&([01]))?/.exec(t.src);
return {
baseSize: n && Number(n[1]),
baseFontSize: n && Number(n[2]),
freeze: !(!n || !Number(n[3]))
}
}());