-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
230 lines (214 loc) · 8.08 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
<title>v2ex</title>
<meta name="description" content="V2EX redesign">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,minimal-ui">
<meta name="mobile-web-app-capable" content="yes">
<meta name="application-name" content="V2EX+">
<meta name="theme-color" content="#ffffff">
<meta name="referrer" content="same-origin">
<base href="/">
<!-- See https://goo.gl/OOhYW5 -->
<link rel="manifest" href="/manifest.json" />
<!-- insert global variables here -->
<script>
if (window.clientAddress) {
window.Polymer = {
rootPath: window.clientAddress + '/'
};
}
if (location.href.indexOf('debug') === -1 && location.hostname !== '127.0.0.1' ) {
// console.log = () => {};
}
</script>
<script>
let materialIconsFont = new FontFace('Material Icons', 'url(https://fonts.gstatic.com/s/materialicons/v38/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2)', {
style: 'normal',
weight: '400'
});
document.fonts.add(materialIconsFont);
materialIconsFont.load();
materialIconsFont.loaded
.then(function fn() {
setTimeout(() => {
if (!document.body) fn();
document.body.classList.add('material-icons-loaded');
}, 500);
})
.catch((fontface) => {
setTimeout(() => {
document.body.classList.add('material-icons-loaded');
}, 500);
});
</script>
<style>.material-icons {font-family: 'Material Icons';}</style>
<link href="./font.css" rel="stylesheet" />
<script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
<script src="https://unpkg.com/web-animations-js@^2.0.0/web-animations-next-lite.min.js"></script>
<script src="/src/bv-utils.js"></script>
<script src="/src/app-querys.js"></script>
<script type="module" src="./index.js"></script>
<style>
html {
height: 100%;
}
body {
background-image: url(../../assets/bg-big-lighter.png);
background-size: cover;
background-attachment: fixed;
margin: 0;
font-family: Roboto, "Noto Sans", "Noto Sans CJK";
color: var(--light-text-primary-color);
background-color: var(--surface);
/* font-size: 16px; */
}
body.theme-dark {
background-image: none;
}
* {
box-sizing: border-box;
-webkit-user-select: none;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
iron-overlay-backdrop {
overflow: auto;
overscroll-behavior: none;
}
</style>
</head>
<body>
<script type="module">
// settings
window.SETTINGS_FIELDS = {
compactMode: false,
themeColor: 'auto'
};
// rem
let resizeTimer;
window.addEventListener('resize', () => {
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(setRootFontSize, 200);
});
let initialFontSize = getComputedStyle(document.documentElement).fontSize;
document.body.style.fontSize = initialFontSize;
function setRootFontSize() {
document.documentElement.style.fontSize = document.documentElement.clientWidth / 36 + 'px';
}
setRootFontSize();
// add theme
const themeColor = window.BVUtils.settings.getItem('user-settings', 'themeColor', window.SETTINGS_FIELDS);
try {
const list = window.DARK_COLOR_SCHEME_QUERY = window.matchMedia('(prefers-color-scheme: dark)');
const metaThemeColor = document.querySelector("meta[name=theme-color]");
if (list.matches && themeColor === 'auto') {
document.body.classList.add('theme-dark');
metaThemeColor.setAttribute('content', '#121212');
}
list.onchange = window.APPLY_SYSTEM_COLOR_SCHEME = () => {
const themeColor = window.BVUtils.settings.getItem('user-settings', 'themeColor', window.SETTINGS_FIELDS);
if (themeColor !== 'auto') return;
if (list.matches) {
document.body.classList.add('theme-dark');
metaThemeColor.setAttribute('content', '#121212');
} else {
document.body.classList.remove('theme-dark');
metaThemeColor.setAttribute('content', '#ffffff');
}
};
} catch (ex) {}
if (themeColor === 'dark') {
document.body.classList.add('theme-dark');
}
</script>
<dom-bind id="t">
<template>
<template is="dom-if" if="{{inited}}">
<v2ex-app id="v2ex" app="{{app}}">
<bv-toolbar id="toolbar" app="{{app}}"></bv-toolbar>
<bv-bottom-navigation class="show" app="{{app}}"></bv-bottom-navigation>
<bv-timeline-page app="{{app}}" name="home"></bv-timeline-page>
<bv-topic-page app="{{app}}" name="topic"></bv-topic-page>
<bv-member-page app="{{app}}" name="member"></bv-member-page>
<bv-login-page app="{{app}}" name="login"></bv-login-page>
<bv-settings-page app="{{app}}" name="others"></bv-settings-page>
<bv-list-page app="{{app}}" name="list"></bv-list-page>
<bv-nodes-page app="{{app}}" name="nodes"></bv-nodes-page>
<bv-notifications-page app="{{app}}" name="notifications"></bv-notifications-page>
<bv-writing-page app="{{app}}" name="create-topic"></bv-writing-page>
<bv-today-page app="{{app}}" name="today"></bv-today-page>
</v2ex-app>
<paper-toast id="global-error-toast"></paper-toast>
<bv-dialog app="{{app}}"></bv-dialog>
<bv-loading-layer id="loading"></bv-loading-layer>
</template>
<bv-image-viewer id="image-viewer"></bv-image-viewer>
</template>
<script type="module">
// window.console.log = () => {};
window.console.warn = () => {};
document.addEventListener('contextmenu', (ev) => {
const composedPath = ev.composedPath();
// disable default image and a link
let target = (composedPath && composedPath[0]) || ev.target;
let nodeName;
while (target) {
nodeName = target.nodeName;
if (nodeName === 'A' || nodeName === 'IMG') {
ev.preventDefault();
return false;
}
target = target.parentElement;
}
// disable timeline page
target = ev.target;
while (target) {
if (target.nodeName === 'BV-TIMELINE-PAGE') {
return ev.preventDefault();
}
target = target.parentElement;
}
});
window.addEventListener('userinfo-change', (ev) => {
t.set('app.userInfo', ev.detail);
});
t.app = {
name: 'bv2ex',
notificationCount: 0,
pageName: t.pageName || 'Timeline',
userInfo: {
avatar: './assets/avatar/avatar-1.png'
},
mockItems: (() => {
let arr = [];
for (let i = 0; i < 100; i++) {
arr.push({
innerHTML: 'test paragrash ' + i
});
}
return arr;
})()
};
window.t = t;
t.inited = true;
</script>
</dom-bind>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/highlight.min.js"></script>
<script type="module">
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js')
.then(function(reg) {
// registration worked
console.log('Registration succeeded. Scope is ' + reg.scope);
}).catch(function(error) {
// registration failed
console.log('Registration failed with ' + error);
});
}
</script>
<!-- insert fcm here -->
</body>
</html>