mirror of
https://github.com/MCSManager/MCSManager.git
synced 2024-11-21 03:12:10 +08:00
新增 - 支持控制台简单的颜色
This commit is contained in:
parent
618cc83fd3
commit
d4b631c311
@ -107,4 +107,33 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Minecraft 服务器输出基本颜色
|
||||
TOOLS.encodeConsoleColor = function (text) {
|
||||
text = text.replace(/\[/igm, "<span class='color-green'>[ </span>");
|
||||
text = text.replace(/\]/igm, "<span class='color-green'> ]</span>");
|
||||
text = text.replace(/INFO/gm, "<span style='color:#03ea0a;'>INFO</span>");
|
||||
text = text.replace(/WANG/gm, "<span class='color-red'>WANG</span>");
|
||||
text = text.replace(/(\d{2,}:\d{2,}:\d{2,})/gm, "<span style='color:#017EBC;'> $1 </span>");
|
||||
RegExpStringArr = [
|
||||
["Unknown command", "Server", "Stopping"],
|
||||
["/help"],
|
||||
["WARN"]
|
||||
]
|
||||
for (var k in RegExpStringArr) {
|
||||
for (var y in RegExpStringArr[k]) {
|
||||
|
||||
var reg = new RegExp("(" + RegExpStringArr[k][y] + ")", "igm");
|
||||
console.log("当前:", k, y, "正则是:", "(" + RegExpStringArr[k][y] + ")", reg)
|
||||
if (k == 0)
|
||||
text = text.replace(reg, "<span style='color:#017EBC;'>$1</span>");
|
||||
if (k == 1)
|
||||
text = text.replace(reg, "<span class='color-green'>$1</span>");
|
||||
if (k == 2)
|
||||
text = text.replace(reg, "<span class='color-red'>$1</span>");
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
})();
|
@ -140,6 +140,8 @@
|
||||
//判断用户是否自己移动了滚轴
|
||||
var BUFF_FONTIER_SIZE_DOWN = MinecraftConsole.scrollHeight - MinecraftConsole.clientHeight;
|
||||
flag = (MinecraftConsole.scrollTop + 354 >= BUFF_FONTIER_SIZE_DOWN);
|
||||
//color
|
||||
consoleSafe = TOOLS.encodeConsoleColor(consoleSafe);
|
||||
//add
|
||||
MinecraftConsole.innerHTML += consoleSafe;
|
||||
//unblive bt ths is t
|
||||
|
Loading…
Reference in New Issue
Block a user