-
Notifications
You must be signed in to change notification settings - Fork 97
/
headless-mode.html
79 lines (73 loc) · 2.08 KB
/
headless-mode.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Headless Mode</title>
<link rel="stylesheet" href="/css/examples.css?ver=1.0.0" />
<script src="/js/examples.js?ver=1.1.1"></script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/github.min.css" />
<script src="//cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js"></script>
</head>
<body>
<style>
.hljs-comment {
color: gray !important;
}
</style>
<style>
body {
overflow: unset;
background-color: #f8f8f8;
}
h1 {
margin-left: 10%;
margin-top: 32px;
margin-bottom: 32px;
}
#code {
margin-left: 10%;
margin-bottom: 32px;
}
#loading {
margin-left: 10%;
}
@media only screen and (max-width: 640px) {
#code {
margin-left: 0;
}
h1 {
margin-left: unset;
text-align: center;
}
}
</style>
<h1>Headless Mode <small>(Node.js)</small></h1>
<div id="loading">loading...</div>
<pre><code id="code"></code></pre>
<script>
const jsFile = window.location.href.replace(/\.html$/, '.js')
fetch(jsFile)
.then(res => {
if (res.status === 200) {
res.text().then(function (data) {
document.getElementById('loading').remove()
const node = document.getElementById('code')
const textNode = document.createTextNode(data)
node.appendChild(textNode)
document.querySelectorAll('pre code').forEach(block => {
hljs.highlightBlock(block)
})
})
}
})
.catch(err => {
console.log(err)
})
</script>
</body>
</html>