-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
66 lines (64 loc) · 1.83 KB
/
index.html
File metadata and controls
66 lines (64 loc) · 1.83 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Folder history</title>
<style>
html {
font-family: sans-serif;
background: #a1e5ee;
color: #014469;
}
pre {
margin: 0;
padding: 1em;
}
#console {
background: #ffffff;
border-radius: 15px;
padding: 0;
height: calc(100vh - 200px);
overflow-y: scroll;
}
textarea {
width: 90%;
}
</style>
</head>
<body>
<h2>Work history</h2>
<p>Watching folder <code id="path"></code></p>
<p>
<details>
<summary>Settings</summary>
<p>How often should I make a new version?</p>
<textarea id="commit-freq" onchange="sendData({commit_freq: this.value})"></textarea>
<p>What level of detail should I include in the descriptions?</p>
<textarea id="detail-level" onchange="sendData({detail_level: this.value})"></textarea>
</details>
</p>
<div id="console">
<pre id="log">Loading...</pre>
</div>
<script>
const ws = new WebSocket('ws://' + location.hostname + ':8765');
ws.onmessage = function(event) {
let {path, log, commit_freq, detail_level} = JSON.parse(event.data);
document.getElementById('commit-freq').textContent = commit_freq;
document.getElementById('detail-level').textContent = detail_level;
document.getElementById('path').textContent = path;
document.getElementById('log').textContent = log;
};
ws.onopen = function() { console.log('WebSocket connected'); };
ws.onclose = function() { document.getElementById('log').textContent = 'Disconnected from server.'; };
function sendData(obj) {
if (ws.readyState === WebSocket.OPEN) {
ws.send(JSON.stringify(obj));
} else {
console.warn('WebSocket not open');
}
}
window.sendData = sendData;
</script>
</body>
</html>