-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.htm
105 lines (87 loc) · 2.92 KB
/
log.htm
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Log output</title>
<link Content-Type="text/css" href="/iotstyle.css" rel="stylesheet" />
<link rel="icon" type="image/png" href="/favicon48.png" sizes="48x48">
<meta name="application-name" content="Ding" />
<meta name="msapplication-config" content="/browserconfig.xml" />
<meta name="msapplication-TileColor" content="#2b5797" />
<meta name="msapplication-TileImage" content="/favicon144.png" />
<link rel="apple-touch-icon" sizes="180x180" href="/favicon180.png" />
<meta name="mobile-web-app-capable" content="yes" />
<link rel="manifest" href="/site.webmanifest" />
<meta name="theme-color" content="#ffffff" />
<script src="micro.js"></script>
<script src="/sfc/loader.js"></script>
<script>
var allSFCLoaded = window.loadComponent('u-toast', '/sfc');
</script>
<style>
pre.code {
padding: 0.2em;
font-size: 0.75rem;
line-height: 1.2;
background-color: #fffff8;
color: black;
border: 1px solid black;
overflow-x: hidden;
overflow-y: scroll;
}
</style>
</head>
<body style="margin:0;padding:0">
<u-toast></u-toast>
<div class="u-header">
<h1>Log output</h1>
</div>
<div class="u-navbar">
<a href="/">Home</a>
<a href="/board.htm">Board</a>
<a href="/microide.htm">IDE</a>
<a href="/log.htm">Log</a>
<span class="gap"></span>
<button id="clearButton">clear</button>
</div>
<pre class="code" id="logtext"></pre>
<script>
var clearObj = document.getElementById('clearButton');
var logTextObj = document.getElementById('logtext');
var toastObj = document.querySelector('u-toast');
var lastText = "";
function appendLog(logtext) {
var newText = logtext;
if (logtext == lastText) {
return;
} else if ((lastText.length > 0) && (logtext.lastIndexOf(lastText, 0) === 0)) {
newText = logtext.substring(lastText.length);
}
lastText = logtext;
logTextObj.insertAdjacentText('beforeend', newText);
logTextObj.scrollTop = logTextObj.scrollHeight;
}
async function updateLog() {
fetchText('/log.txt')
.then(function(txt) {
appendLog(txt);
});
}
window.addEventListener('load', async function() {
await fetchText('/log_old.txt')
.then(function(txt) {
appendLog(txt);
});
await updateLog();
window.setInterval(updateLog, 1000);
clearObj.addEventListener('click', async () => {
toastObj.info('deleting log files...');
await fetch("/log_old.txt", { method: 'DELETE' });
await fetch("/log.txt", { method: 'DELETE' });
toastObj.info('log files deleted.');
});
});
</script>
</body>
</html>