summaryrefslogtreecommitdiff
path: root/APRSStdPages.c
diff options
context:
space:
mode:
authorDave Hibberd <hibby@debian.org>2024-10-11 15:37:11 +0100
committerDave Hibberd <hibby@debian.org>2024-10-11 15:37:11 +0100
commiteb0d36d3f67be13de74023adb6d30362d47805fe (patch)
treeccf33618ee66710ce3b3a84108d125e15e07b8dc /APRSStdPages.c
parent6dfe32758e1a995b1241af8c981798c22cd70439 (diff)
New upstream version 6.0.24.45upstream/6.0.24.45
Diffstat (limited to 'APRSStdPages.c')
-rw-r--r--APRSStdPages.c168
1 files changed, 168 insertions, 0 deletions
diff --git a/APRSStdPages.c b/APRSStdPages.c
index 300df3c..456e8ba 100644
--- a/APRSStdPages.c
+++ b/APRSStdPages.c
@@ -3225,6 +3225,170 @@ char * get_plane(int * Len)
return ptr;
}
+char * get_portstats()
+{
+ char Msg[] =
+ "<!DOCTYPE html>\n"
+ "<html>\n"
+ "\n"
+ "<head>\n"
+ "<script src=\"https://code.jquery.com/jquery-3.6.0.min.js\"> </script>\n"
+ "</head>\n"
+ "\n"
+ "\n"
+ "<body>\n"
+ "<H2 id=\"h1\"> Last hour's stats for Port </h2>\n"
+ "<p>\n"
+ "<canvas id=\"myCanvas\" width=\"600\" height=\"250\" style=\"border:1px solid #d3d3d3;\">\n"
+ "Your browser does not support the HTML canvas tag.</canvas>\n"
+ "<br>\n"
+ "<canvas id=\"myCanvas2\" width=\"600\" height=\"250\" style=\"border:1px solid #d3d3d3;\">\n"
+ "Your browser does not support the HTML canvas tag.</canvas>\n"
+ "\n"
+ "<script>\n"
+ "var c = document.getElementById(\"myCanvas\");\n"
+ "var ctx = c.getContext(\"2d\");\n"
+ "\n"
+ "var port = window.location.search.slice(1);\n"
+ "\n"
+ "document.getElementById(\"h1\").innerHTML = \"Last hour's stats for Port \" + port;;\n"
+ "\n"
+ "var oReq = new XMLHttpRequest();\n"
+ "oReq.open(\"GET\", \"/portstats.txt?\" + port, true);\n"
+ "oReq.responseType = \"arraybuffer\";\n"
+ "\n"
+ "oReq.onload = function(oEvent)\n"
+ " {\n"
+ " var arrayBuffer = oReq.response;\n"
+ "\n"
+ " var byteArray = new Uint8Array(arrayBuffer);\n"
+ " \n"
+ " \n"
+ " // Draw it. Do last hour for testing. Plot each value for 10 pixels\n"
+ " \n"
+ "\tctx.strokeStyle = \"green\";\n"
+ "\tctx.beginPath();\n"
+ "\t\n"
+ "\tctx.moveTo(0,200);\n"
+ "\tvar y = 2880 - 60;\n"
+ "\tvar val;\n"
+ "\t\n"
+ "\tfor (i = 0; i < 600; i+=10)\n"
+ "\t{\n"
+ "\t\tval = byteArray[y] * 2;\n"
+ "\t\t\n"
+ "\t\tctx.lineTo(i, 200 - val);\n"
+ "\t\tctx.lineTo(i+10, 200 - val);\n"
+ "\t\ty++;\n"
+ "\t}\n"
+ "\t\n"
+ "\tctx.stroke();\n"
+ "\t\n"
+ "\tctx.strokeStyle = \"gray\";\n"
+ "\tctx.setLineDash([5, 3]);\n"
+ "\t\n"
+ "\tctx.beginPath();\n"
+ " \tctx.moveTo(0,100);\n"
+ "\tctx.lineTo(600,100);\n"
+ " \tctx.moveTo(0,50);\n"
+ "\tctx.lineTo(600,50);\n"
+ " \tctx.moveTo(0,150);\n"
+ "\tctx.lineTo(600,150);\n"
+ "\tctx.stroke();\n"
+ "\n"
+ "\n"
+ "\t\n"
+ "\tctx.fillText(\"100%\",0,10);\n"
+ "\tctx.fillText(\"50%\",0,100);\n"
+ "\tctx.fillText(\"0%\",0,200);\t\n"
+ "\tctx.fillText(\"-60 mins\",0,220);\t\n"
+ "\tctx.fillText(\"-30 mins\",300,220);\t\n"
+ "\tctx.fillText(\"Now\",580,220);\t\n"
+ "\n"
+ "\t\n"
+ "\t// Do TX\n"
+ "\t\n"
+ "\t\n"
+ "\tc = document.getElementById(\"myCanvas2\");\n"
+ "\tctx = c.getContext(\"2d\");\n"
+ "\n"
+ "\tctx.fillText(\"100%\",0,10);\n"
+ "\tctx.fillText(\"50%\",0,100);\n"
+ "\tctx.fillText(\"0%\",0,200);\t\n"
+ "\tctx.fillText(\"-60 mins\",0,220);\t\n"
+ "\tctx.fillText(\"-30 mins\",300,220);\t\n"
+ "\tctx.fillText(\"Now\",580,220);\t\n"
+ "\n"
+ "\n"
+ "\tctx.strokeStyle = \"red\";\n"
+ "\tctx.beginPath();\n"
+ "\t\n"
+ "\tctx.moveTo(0,200);\n"
+ "\tvar y = 1440 - 60;\n"
+ "\tvar val;\n"
+ "\t\n"
+ "\tfor (i = 0; i < 600; i+=10)\n"
+ "\t\n"
+ "\t{\n"
+ "\t\tval = byteArray[y] * 2;\n"
+ "\t\t\n"
+ "\t\tctx.lineTo(i, 200 - val);\n"
+ "\t\tctx.lineTo(i+10, 200 - val);\n"
+ "\t\ty++;\n"
+ "\t}\n"
+ "\t\n"
+ "\tctx.stroke();\n"
+ "\n"
+ "\tctx.strokeStyle = \"gray\";\n"
+ "\tctx.setLineDash([5, 3]);\n"
+ "\t\n"
+ "\tctx.beginPath();\n"
+ " \tctx.moveTo(0,100);\n"
+ "\tctx.lineTo(600,100);\n"
+ " \tctx.moveTo(0,50);\n"
+ "\tctx.lineTo(600,50);\n"
+ " \tctx.moveTo(0,150);\n"
+ "\tctx.lineTo(600,150);\n"
+ "\tctx.stroke();\n"
+ "\n"
+ "\n"
+ "};\n"
+ "\n"
+ "oReq.send();\n"
+ "\n"
+ "\n"
+ "function draw(Data)\n"
+ "{\n"
+ "\n"
+ "\t// Data has 4 bytes of index to current position the 1440 bytes of load info\n"
+ "\t\n"
+ "\n"
+ "\tview = new Int8Array(Data);\n"
+ "\t\n"
+ "alert(view[3]);\n"
+ "\n"
+ "ctx.moveTo(0,200);\n"
+ "var y = 0;\n"
+ "for (i = 0; i < 720; i+=30)\n"
+ "{\n"
+ "\tctx.lineTo(i, 200 - y);\n"
+ "\tctx.lineTo(i+30, 200 - y);\n"
+ "\ty += 10;\n"
+ "}\n"
+ "\n"
+ "\n"
+ "ctx.stroke();\n"
+ "}\n"
+ "\n"
+ "</script>\n"
+ "\n"
+ "</body>\n"
+ "</html>\n"
+ "\n"
+ "";
+
+ return _strdup(Msg);;
+}
char * get_aprs()
{
@@ -3638,6 +3802,10 @@ char * GetStandardPage(char * FN, int * Len)
if (_stricmp(FN, "leaflet.rotatedMarker.js") == 0)
return get_rotatedMarker();
+ if (_stricmp(FN, "PortStats.html") == 0)
+ return get_portstats();
+
+
if (_stricmp(FN, "info_call.html") == 0)
return get_info_call();