-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
115 lines (81 loc) · 3.05 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
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>GemDrive Entreate</title>
<link rel="stylesheet"
href="//cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/default.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/lib/codemirror.min.css">
<link rel="stylesheet" type="text/css" href="./entreate.css">
<style>
* {
box-sizing: border-box;
font-family: Verdana;
}
.content {
margin: 0 auto;
max-width: 900px;
}
</style>
</head>
<body>
<div class='content'></div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/codemirror.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/mode/markdown/markdown.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="//cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js"></script>
<script type='module'>
import { Entreate } from './entreate.js';
(async () => {
if (window.opener) {
window.addEventListener('message', (message) => {
if (message.data.command === 'run') {
render(message.data.items);
}
});
window.opener.postMessage('child-ready');
}
else {
render();
}
})();
async function render(items) {
const urlParams = new URLSearchParams(window.location.search);
const token = localStorage.getItem('access_token');
let dir = urlParams.get('dir');
if (!dir) {
dir = prompt(`Enter a path to the source directory`);
urlParams.set('dir', dir);
history.pushState(null, '', window.location.pathname + '?' + decodeURIComponent(urlParams.toString()));
}
const entreateEl = Entreate(dir, token);
entreateEl.addEventListener('do-auth', async (e) => {
//const dest = dir;
//const email = prompt("Email to authorize:");
//const authUrl = dest + 'gemdrive/authorize';
//let res = await fetch(authUrl, {
// method: 'POST',
// body: JSON.stringify({
// idType: 'email',
// id: email,
// perm: 'write',
// path: '/',
// }),
//});
//const requestId = await res.text();
//const code = prompt("Check email for code:");
//res = await fetch(`${authUrl}?id=${requestId}&code=${code}`, {
// method: 'POST',
//});
//const accessToken = await res.text();
//localStorage.setItem('access_token', accessToken);
const key = prompt("Enter key:");
localStorage.setItem('access_token', key);
window.location.reload();
});
const content = document.querySelector('.content');
content.appendChild(entreateEl);
}
</script>
</body>
</html>