-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
185 lines (161 loc) · 5.56 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>水源社区兼容性检测</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #f5f5f5;
}
.detect-result, .user-agent-info, .suggestion {
margin: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
padding: 20px;
}
h1.result-title {
display: flex;
align-items: center;
font-size: 24px;
color: #333;
}
p.result-text {
font-size: 18px;
color: #666;
}
.inline-emoji {
height: 40px;
vertical-align: middle;
margin-left: 10px;
}
#browser-info {
font-size: 16px;
color: #666;
}
h2 {
font-size: 20px;
color: #333;
margin-bottom: 10px;
}
p.suggestion-text {
font-size: 16px;
color: #666;
margin-bottom: 10px;
}
img#logo {
height: 80px;
max-width: 75%;
margin: 50px auto;
display: block;
}
ul {
list-style-type: none;
padding: 0;
margin: 0;
}
li {
margin-bottom: 5px;
}
a {
color: #007bff;
text-decoration: none;
}
</style>
</head>
<body>
<div class="detect-result">
<div id="detect-support">
<h1 class="result-title">
恭喜
<img class="emoji inline-emoji" src="./assets/smiling_face_with_three_hearts.png" alt="smile">
</h1>
<p class="result-text">您的浏览器支持水源社区最新版本</p>
</div>
<div id="detect-unsupport">
<h1 class="result-title">
抱歉
<img class="emoji inline-emoji" src="./assets/sob.png" alt="cry">
</h1>
<p class="result-text">您的浏览器不支持水源社区最新版本,请升级您的浏览器</p>
</div>
</div>
<div class="user-agent-info">
<h2>关于您的浏览器</h2>
<p id="browser-info"></p>
</div>
<div class="suggestion">
<h2>我们的建议</h2>
<p class="suggestion-text" id="suggestion-android-jwb">
您当前正在使用 Android 版交我办,建议升级系统 WebView 到新版本:
<a href="https://jbox.sjtu.edu.cn/l/X17UBb">点击下载</a>,安装后重启手机
</p>
<p class="suggestion-text" id="suggestion-ios">
您当前正在使用 iOS,请升级到 iOS 15.7 及以上版本
</p>
<p class="suggestion-text" id="suggestion-common">
推荐使用最新版的下列浏览器:
<ul>
<li><a href="https://www.microsoft.com/zh-cn/edge/download">Microsoft Edge</a></li>
<li><a href="https://www.google.cn/intl/zh-CN/chrome/">Google Chrome</a></li>
<li><a href="https://www.mozilla.org/zh-CN/firefox/new/">Mozilla Firefox</a></li>
<li><a href="https://www.apple.com.cn/safari/">Apple Safari</a></li>
</ul>
</p>
</div>
<div>
<img id="logo" src="./assets/logo.svg" alt="水源社区">
</div>
</body>
<script>
// this function is from Discourse
function detectUnsupportedBrower() {
if (
!window.WeakMap ||
!window.Promise ||
typeof globalThis === "undefined" ||
!String.prototype.replaceAll ||
!CSS.supports ||
!CSS.supports("aspect-ratio: 1")
) {
return true;
} else {
// Some implementations of `WeakMap.prototype.has` do not accept false
// values and Ember's `isClassicDecorator` sometimes does that (it only
// checks for `null` and `undefined`).
try {
new WeakMap().has(0);
} catch (err) {
return true;
}
var match = window.navigator.userAgent.match(/Firefox\/([0-9]+)\./);
var firefoxVersion = match ? parseInt(match[1], 10) : null;
if (firefoxVersion && firefoxVersion < 89) {
// prior to v89, Firefox has bugs with document.execCommand("insertText")
// https://bugzil.la/1220696
return true;
}
}
return false;
};
function showSuggestion() {
const ua = window.navigator.userAgent.toLowerCase();
const isAndroid = ua.includes("android");
const isJwb = ua.includes("taskcenterapp");
const isIos = ua.includes("iphone") || ua.includes("ipad");
document.querySelector("#suggestion-ios").style.display = isIos ? "block" : "none";
document.querySelector("#suggestion-android-jwb").style.display = (isJwb && isAndroid) ? "block" : "none";
}
(function () {
document.querySelector("#browser-info").innerHTML = window.navigator.userAgent;
const unsupported = detectUnsupportedBrower();
document.querySelector("#detect-unsupport").style.display = unsupported ? "block" : "none";
document.querySelector("#detect-support").style.display = !unsupported ? "block" : "none";
showSuggestion();
})();
</script>
</html>