mirror of https://github.com/lumapu/ahoy.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.7 KiB
70 lines
2.7 KiB
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>Serial Console</title>
|
|
<link rel="stylesheet" type="text/css" href="style.css"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<script type="text/javascript" src="api.js"></script>
|
|
</head>
|
|
<body>
|
|
<h1>Serial Console</h1>
|
|
<div id="content" class="content">
|
|
<div class="serial">
|
|
<textarea id="serial" cols="80" rows="20" readonly></textarea><br/>
|
|
conntected: <span class="dot" id="connected"></span><input type="button" value="clear" class="btn" id="clear"/> <input type="button" value="autoscroll" class="btn" id="scroll"/>
|
|
</div>
|
|
</div>
|
|
<div id="footer">
|
|
<p class="left">© 2022</p>
|
|
<p class="left"><a href="/">Home</a></p>
|
|
<p class="right" id="version"></p>
|
|
</div>
|
|
<script type="text/javascript">
|
|
var mPrintTime = true;
|
|
var mAutoScroll = true;
|
|
var con = document.getElementById("serial");
|
|
|
|
function parseSys(obj) {
|
|
document.getElementById("version").innerHTML = "Git SHA: " + obj["build"] + " :: " + obj["version"];
|
|
}
|
|
|
|
document.getElementById("clear").addEventListener("click", function() {
|
|
con.value = "";
|
|
});
|
|
document.getElementById("scroll").addEventListener("click", function() {
|
|
mAutoScroll = !mAutoScroll;
|
|
this.value = (mAutoScroll) ? "autoscroll" : "manual scoll";
|
|
});
|
|
|
|
if (!!window.EventSource) {
|
|
var source = new EventSource('/events');
|
|
source.addEventListener('open', function(e) {
|
|
document.getElementById("connected").style.backgroundColor = "#0c0";
|
|
}, false);
|
|
|
|
source.addEventListener('error', function(e) {
|
|
if (e.target.readyState != EventSource.OPEN) {
|
|
document.getElementById("connected").style.backgroundColor = "#f00";
|
|
}
|
|
}, false);
|
|
|
|
source.addEventListener('serial', function(e) {
|
|
if(mPrintTime) {
|
|
var d = new Date();
|
|
con.value += d.toLocaleTimeString() + ": ";
|
|
mPrintTime = false;
|
|
}
|
|
|
|
if(e.data.includes('<rn>'))
|
|
mPrintTime = true;
|
|
|
|
con.value += e.data.replace(/\<rn\>/g, '\r\n');
|
|
if(mAutoScroll)
|
|
con.scrollTop = con.scrollHeight;
|
|
}, false);
|
|
}
|
|
|
|
getAjax("/api/system", parseSys);
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|