forked from EtomonUSA/etomon-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
234 lines (206 loc) · 8.36 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
231
232
233
234
<!DOCTYPE html>
<html>
<head>
<style>
body {
background: white;
}
ul {
background: white;
display: flex;
padding: 0;
margin: 0;
flex-direction: row;
}
ol {
padding: 0;
margin: 3.5px 16px;
cursor: pointer;
}
webview {
width: 100%;
height: 100%;
border: none;
position: fixed;
/* top: 0; */
left: 0;
}
webview > iframe {
height: 100%;
}
#nav-ctrls-url {
visibility: hidden;
}
#help {
width: 25px;
height: 25px;
cursor: pointer;
}
#help > * {
width: 100%;
height: 100%;
fill: #3F3F3F;
}
#record.recording circle {
fill: red;
}
</style>
<script>
let {remote} = require('electron');
const siteUri = remote.getGlobal('siteUri');
window.toggleRecord = () => {
let button = document.querySelector('#record');
if (button.classList.contains('recording')) {
button.classList.remove('recording');
} else {
button.classList.add('recording');
}
}
window.doNavigate = function (url = '') {
let u = siteUri+url;
try {
document.querySelector('webview').setAttribute('src', u);
} catch (e) {
}
try { document.querySelector('webview').loadUrl(u); }
catch (err) {}
}
window.doNavigateToContactUs = async function () {
const getLog = require('electron').remote.getGlobal('getLog');
const log = await getLog();
document.querySelector('body').setAttribute('style', 'cursor: wait');
doNavigate('/contact-us');
await document.querySelector('webview').executeJavaScript(`
((log) => {
const b64toBlob = (b64Data, contentType='', sliceSize=512) => {
const byteCharacters = atob(b64Data);
const byteArrays = [];
for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
const slice = byteCharacters.slice(offset, offset + sliceSize);
const byteNumbers = new Array(slice.length);
for (let i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
const blob = new Blob(byteArrays, {type: contentType});
return blob;
}
window.log = b64toBlob('${log.toString('base64')}', 'application/msgpack');
})()
`);
// await document.querySelector('webview').addEventListener('ipc-message', (event) => {
// if (event.channel === 'send-log')
// document.querySelector('webview').send('log', log);
// });
document.querySelector('body').setAttribute('style', 'cursor: unset');
}
window.onload = () => {
document.querySelector('webview').addEventListener('dom-ready', async () => {
await remote.getGlobal('har')(
document.querySelector('webview').getWebContentsId()
);
});
remote.getGlobal('setFn')(
{
forwardWebview,
backWebview,
reloadWebview,
doNavigate,
doNavigateToContactUs
}
);
}
function reloadWebview() {
return document.querySelector('webview').executeJavaScript(`
(() => {
document.location.reload();
})()
`)
}
async function backWebview() {
await document.querySelector('webview').executeJavaScript(`
(() => {
history.back()
})()
`);
return document.querySelector('webview').executeJavaScript(`
(() => {
if (document.location.toString() === 'about:blank')
document.location = '${siteUri}';
})()
`);
}
function forwardWebview() {
return document.querySelector('webview').executeJavaScript(`
(() => {
history.forward()
})()
`)
}
</script><script src="../etomon-backend/utils/delete-user.js"></script>
</head>
<body>
<ul>
<ol onclick="backWebview()">
<svg width="14" height="23" viewBox="0 0 14 23" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 2.05606L11.8766 0L0 11.5L11.8766 23L14 20.9439L4.24679 11.5L14 2.05606Z" fill="#3F3F3F"/>
</svg>
</ol>
<ol onclick="forwardWebview()">
<svg width="14" height="23" viewBox="0 0 14 23" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 20.9439L2.12339 23L14 11.5L2.12339 0L0 2.05606L9.75321 11.5L0 20.9439Z" fill="#3F3F3F"/>
</svg>
</ol>
<ol onclick="reloadWebview()">
<svg width="23" height="23" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M19.6198 3.37812C17.5341 1.29375 14.6717 0 11.4928 0C5.13508 0 0 5.14625 0 11.5C0 17.8538 5.13508 23 11.4928 23C16.858 23 21.3315 19.3344 22.6116 14.375H19.6198C18.4403 17.7244 15.247 20.125 11.4928 20.125C6.73171 20.125 2.86241 16.2581 2.86241 11.5C2.86241 6.74188 6.73171 2.875 11.4928 2.875C13.8806 2.875 16.0094 3.86687 17.5629 5.43375L12.9312 10.0625H23V0L19.6198 3.37812Z" fill="#3F3F3F"/>
</svg>
</ol>
<ol onclick="doNavigateToContactUs()">
<svg id="help" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 459.668 459.668" style="enable-background:new 0 0 459.668 459.668;" xml:space="preserve">
<g id="XMLID_2_">
<g>
<g>
<path d="M359.574,297.043c-18.204,25.002-47.692,41.286-80.916,41.286h-46.618c-16.104,0-29.818-10.224-35.011-24.534 c-6.41-1.912-12.696-4.394-18.83-7.442c-12.99-6.454-24.785-15.198-35.168-26.03c-67.35,14.796-117.757,74.808-117.757,146.603 v9.384c0,12.9,10.458,23.358,23.358,23.358h362.403c12.9,0,23.358-10.458,23.358-23.358v-9.384 C434.392,371.464,404.309,323.032,359.574,297.043z"/>
<path d="M118.205,232.178c10.039,0,18.777-5.564,23.304-13.775c0.119,0.325,0.24,0.648,0.362,0.971 c0.036,0.097,0.072,0.194,0.108,0.291c10.62,27.954,31.284,51.388,58.532,61.627c6.59-10.471,18.243-17.435,31.53-17.435h46.618 c4.65,0,8.978-1.312,12.772-3.433c6.372-3.563,12.102-12.602,15.061-17.393c4.735-7.667,8.404-15.788,11.657-24.642 c1.828,3.32,4.342,6.208,7.354,8.471v11.431c0,25.83-21.014,46.845-46.845,46.845H232.04c-8.813,0-15.958,7.145-15.958,15.958 c0,8.814,7.145,15.958,15.958,15.958h46.618c43.429,0,78.761-35.332,78.761-78.761V226.86 c6.46-4.853,10.639-12.577,10.639-21.278v-48.119v-18.452c0-8.88-4.355-16.737-11.042-21.568C351.83,51.816,296.77,0,229.833,0 C162.895,0,107.836,51.816,102.65,117.442c-6.687,4.831-11.042,12.689-11.042,21.568v66.57 C91.608,220.311,103.575,232.178,118.205,232.178z M229.833,31.917c49.552,0,90.423,37.868,95.2,86.185 c-3.136,2.467-5.705,5.62-7.475,9.238c-15.058-39.286-48.672-66.638-87.726-66.638c-39.896,0-72.971,28.292-87.667,66.481 c-0.02,0.052-0.039,0.105-0.059,0.158c-1.77-3.618-4.339-6.771-7.475-9.238C139.411,69.785,180.281,31.917,229.833,31.917z"/>
</g>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>
</ol>
</ul>
<webview style="height: 100%; width: 100%;" src="about:blank" disablewebsecurity webpreferences="allowRunningInsecureContent"></webview>
</body>
</html>