-
Notifications
You must be signed in to change notification settings - Fork 169
/
nomodule.ts
53 lines (53 loc) · 1.43 KB
/
nomodule.ts
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
/// <reference lib="dom" />
var el = document.createElement('div')
var hEl = document.createElement('h2')
var pEl = document.createElement('p')
var style: Partial<CSSStyleDeclaration> = {
position: 'fixed',
top: '0',
left: '0',
zIndex: '999',
width: '100%',
margin: '0',
padding: '24px 0',
lineHeight: '1.5',
fontSize: '14px',
color: '#666',
backgroundColor: '#fff9cc',
textAlign: 'center',
boxShadow: '0 1px 5px rgba(0,0,0,0.1)'
}
var hStyle: Partial<CSSStyleDeclaration> = {
margin: '0',
padding: '0',
lineHeight: '1.2',
fontSize: '24px',
fontWeight: '700',
color: '#000',
}
for (var key in style) {
(el.style as any)[key] = style[key]
}
for (var key in hStyle) {
(hEl.style as any)[key] = hStyle[key]
}
var isDev = false
var scripts = document.getElementsByTagName('script')
for (var i = 0; i < scripts.length; i++) {
var s = scripts[i]
if (/nomodule\.js\?dev$/.test(s.src)) {
isDev = true
break
}
}
// todo: i18n
// todo: add browser info
hEl.innerText = 'Your browser is out of date.'
if (isDev) {
pEl.innerHTML = 'Aleph.js requires <a href="https://caniuse.com/es6-module" style="font-weight:500;color:#000;">ES module</a> support during development.'
} else {
pEl.innerHTML = 'Update your browser for more security, speed and the best experience on this site.'
}
el.appendChild(hEl)
el.appendChild(pEl)
document.body.appendChild(el)