Skip to content

Commit 48791fb

Browse files
committed
add meta
1 parent 637b2b1 commit 48791fb

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

static/index.html

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4+
<meta charset="utf-8">
45
<title>日志阅读</title>
56
<style>
67
html, body {
@@ -40,14 +41,17 @@
4041
display: inline-block;
4142
color: #0ba9b9;
4243
border: 1px solid #0ba9b9;
43-
opacity: 0.5;
4444
background: transparent;
4545
cursor: pointer;
4646
outline: none;
47-
transition: all ease .1s;
47+
transition: background ease .15s, color ease .15s;
4848
}
4949
#panel fieldset button:hover {
50-
opacity: 1;
50+
background: #0ba9b9;
51+
color: #152d30;
52+
}
53+
#panel fieldset button:active {
54+
transform: translate(1px, 1px);
5155
}
5256
#panel fieldset textarea {
5357
width: 100%;
@@ -95,6 +99,9 @@
9599
.type.ERROR {
96100
background: rgb(107, 35, 35);
97101
}
102+
.type.SYSTEM {
103+
background: rgb(80, 14, 80);
104+
}
98105
.path {
99106
color: #777;
100107
}
@@ -144,11 +151,13 @@
144151
document.body.onclick = e => handleJsonClick(e.target);
145152
loadValue(includeInput);
146153
loadValue(excludeInput);
154+
autoGrow(includeInput);
155+
autoGrow(excludeInput);
147156
connect();
148157
requestAnimationFrame(autoRender);
149158

150159
function connect() {
151-
appendMessage('[INFO] WebSocket connecting...');
160+
appendMessage('[INFO] WebSocket connecting...', true);
152161
ws = new WebSocket('ws://' + location.host);
153162
install();
154163
function install() {
@@ -169,24 +178,24 @@
169178
}
170179
function open() {
171180
connected = true;
172-
appendMessage('[INFO] WebSocket connected!');
181+
appendMessage('[INFO] WebSocket connected!', true);
173182
}
174183
function close() {
175184
connected = false;
176-
appendMessage('[INFO] WebSocket closed! Trying to reconnect in 1 sec.');
185+
appendMessage('[INFO] WebSocket closed! Trying to reconnect in 1 sec.', true);
177186
reconnect();
178187
}
179188
function error() {
180189
connected = false;
181-
appendMessage('[ERROR] WebSocket error! Trying to reconnect in 1 sec.');
190+
appendMessage('[ERROR] WebSocket error! Trying to reconnect in 1 sec.', true);
182191
reconnect();
183192
}
184193
function message(e) {
185194
appendMessage(e.data)
186195
}
187196
};
188197

189-
function appendMessage(content) {
198+
function appendMessage(content, system = false) {
190199
const id = nextMessageId++;
191200
const element = document.createElement('p');
192201
element.setAttribute('data-message-id', id);
@@ -195,6 +204,7 @@
195204
id,
196205
content,
197206
element,
207+
system,
198208
});
199209
const shouldScroll = isScrollOnBottom();
200210
while (messages.length > MAX_MESSAGE_COUNT) {
@@ -247,6 +257,7 @@
247257
const keywords = message.keywords;
248258
let content = message.content;
249259
let html = content;
260+
250261
// 实体转换
251262
html = html.replace(/\</g, '&lt;');
252263
html = html.replace(/\>/g, '&gt;');
@@ -294,6 +305,11 @@
294305
+ html.substr(end + 1);
295306
}
296307

308+
// 系统消息
309+
if (message.system) {
310+
html = '<span class="type SYSTEM">SYSTEM</span>' + html;
311+
}
312+
297313
message.element.innerHTML = html;
298314
return message;
299315
}
@@ -318,6 +334,7 @@
318334
content.indexOf(condition) > -1;
319335

320336
return messages.filter(message => {
337+
if (message.system) return true;
321338
const content = message.content;
322339
message.keywords = null;
323340
if (includes.length) {
@@ -363,6 +380,10 @@
363380

364381
function handleTextAreaInput(textField) {
365382
saveValue(textField);
383+
autoGrow(textField);
384+
}
385+
386+
function autoGrow(textField) {
366387
if (textField.clientHeight < textField.scrollHeight) {
367388
textField.style.height = textField.scrollHeight + "px";
368389
if (textField.clientHeight < textField.scrollHeight) {

0 commit comments

Comments
 (0)