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.
 
 
 
 
 
 

96 lines
3.8 KiB

<!doctype html>
<html lang="en">
<head>
<title>Serial Console</title>
{#HTML_HEADER}
</head>
<body>
{#HTML_NAV}
<div id="wrapper">
<div id="content" style="max-width: 100% !important;">
<div class="row">
<textarea id="serial" class="mt-3" cols="80" rows="40" readonly></textarea>
</div>
<div class="row my-3">
<div class="col-3">console active: <span class="dot" id="active"></span></div>
<div class="col-3 col-sm-4 my-3">Uptime: <span id="uptime"></span></div>
<div class="col-6 col-sm-4 a-r">
<input type="button" value="clear" class="btn" id="clear"/>
<input type="button" value="autoscroll" class="btn" id="scroll"/>
<!--<input type="button" value="copy" class="btn" id="copy"/>-->
</div>
</div>
</div>
</div>
{#HTML_FOOTER}
<script type="text/javascript">
var mAutoScroll = true;
var con = document.getElementById("serial");
var exeOnce = true;
function parseGeneric(obj) {
var up = obj["ts_uptime"];
var days = parseInt(up / 86400) % 365;
var hrs = parseInt(up / 3600) % 24;
var min = parseInt(up / 60) % 60;
var sec = up % 60;
document.getElementById("uptime").innerHTML = days + " Days, "
+ ("0"+hrs).substr(-2) + ":"
+ ("0"+min).substr(-2) + ":"
+ ("0"+sec).substr(-2);
parseRssi(obj);
if(true == exeOnce) {
parseNav(obj);
parseESP(obj);
window.setInterval("getAjax('/api/generic', parseGeneric)", 5000);
exeOnce = false;
setTimeOffset();
}
}
function setTimeOffset() {
// set time offset for serial console
var obj = new Object();
obj.cmd = "serial_utc_offset";
obj.val = new Date().getTimezoneOffset() * -60;
getAjax("/api/setup", null, "POST", JSON.stringify(obj));
}
document.getElementById("clear").addEventListener("click", function() {
con.value = "";
});
document.getElementById("scroll").addEventListener("click", function() {
mAutoScroll = !mAutoScroll;
this.value = (mAutoScroll) ? "autoscroll" : "manual scroll";
});
/*document.getElementById("copy").addEventListener("click", function() {
con.select();
con.setSelectionRange(0, 9999999);
navigator.clipboard.writeText(con.value);
alert("Copied to clipboard");
});*/
if (!!window.EventSource) {
var source = new EventSource('/events');
source.addEventListener('open', function(e) {
document.getElementById("active").style.backgroundColor = "#0c0";
}, false);
source.addEventListener('error', function(e) {
if (e.target.readyState != EventSource.OPEN) {
document.getElementById("active").style.backgroundColor = "#f00";
}
}, false);
source.addEventListener('serial', function(e) {
con.value += e.data.replace(/\<rn\>/g, '\r\n');
if(mAutoScroll)
con.scrollTop = con.scrollHeight;
}, false);
}
getAjax("/api/generic", parseGeneric);
</script>
</body>
</html>