private static string MakeDocs() { string page; page = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html\">\n"; page += "<meta http-equiv=\"cache-control\" content=\"no-cache\">\n"; page += "<meta http-equiv=\"expires\" content=\"0\">\n"; page += "<meta http-equiv=\"pragma\" content=\"no-cache\">\n"; page += "<meta http-equiv=\"Content-Language\" content=\"en\">\n"; page += "<meta charset=\"UTF-8\">\n"; page += "<meta name=\"google\" content=\"notranslate\">\n"; page += "<style>\n"; page += " body { font-family: Sans-Serif; }\n"; page += "</style>\n"; page += "<title>WeatherFlow Nodeserver Web Interface</title>\n"; page += "</head><body>\n"; page += "<div align=\"center\" style=\"width: 920px; margin: 0 auto;\">\n"; page += WFNServer.MakeMenu(); foreach (string addr in WeatherFlowNS.NS.NodeList.Keys) { page += "<table border=\"1\" style=\"width: 900px; border-collapse:collapse; box-shadow: 4px 4px 4px #999; \">"; if (WeatherFlowNS.NS.NodeList[addr] == "WF_AirUS") { page += AirDoc(addr); } else if (WeatherFlowNS.NS.NodeList[addr] == "WF_Air") { page += AirDoc(addr); } else if (WeatherFlowNS.NS.NodeList[addr] == "WF_AirUK") { page += AirDoc(addr); } else if (WeatherFlowNS.NS.NodeList[addr] == "WF_AirD") { page += AirDeviceDoc(addr); } else if (WeatherFlowNS.NS.NodeList[addr] == "WF_SkyUS") { page += SkyDoc(addr); } else if (WeatherFlowNS.NS.NodeList[addr] == "WF_SkyUK") { page += SkyDoc(addr); } else if (WeatherFlowNS.NS.NodeList[addr] == "WF_Sky") { page += SkyDoc(addr); } else if (WeatherFlowNS.NS.NodeList[addr] == "WF_SkyD") { page += SkyDeviceDoc(addr); } else if (WeatherFlowNS.NS.NodeList[addr] == "WF_Hub") { page += HubDoc(addr); } else if (WeatherFlowNS.NS.NodeList[addr] == "WF_Lightning") { page += LightningDoc(addr); } else if (WeatherFlowNS.NS.NodeList[addr] == "WF_LightningUS") { page += LightningDoc(addr); } else if (WeatherFlowNS.NS.NodeList[addr] == "WF_LightningUK") { page += LightningDoc(addr); } else if (WeatherFlowNS.NS.NodeList[addr] == "WF_RapidWind") { page += RapidDoc(addr); } else if (WeatherFlowNS.NS.NodeList[addr] == "WF_RapidWindUS") { page += RapidDoc(addr); } else if (WeatherFlowNS.NS.NodeList[addr] == "WF_RapidWindUK") { page += RapidDoc(addr); } else { WFLogging.Log("Unknown node type " + WeatherFlowNS.NS.NodeList[addr]); } page += "</table>"; page += "<p>"; } page += "</div>"; page += "</body>\n"; page += "</html>\n"; return(page); }
private static string MakeLog() { string page; page = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html\">\n"; page += "<meta http-equiv=\"cache-control\" content=\"no-cache\">\n"; page += "<meta http-equiv=\"expires\" content=\"0\">\n"; page += "<meta http-equiv=\"pragma\" content=\"no-cache\">\n"; page += "<meta http-equiv=\"Content-Language\" content=\"en\">\n"; page += "<meta charset=\"UTF-8\">\n"; page += "<style>\n"; page += " body { font-family: Sans-Serif; }\n"; page += "</style>\n"; page += "<script>\n"; page += " var paused = false;\n"; page += " var pause_log = \"\";\n"; page += " var logSocket = new WebSocket(\"ws://" + ISYDetect.GetMyIPAddress() + ":8289\", \"Log\");"; page += " logSocket.onopen = function(event) {\n"; page += " //alert(\"Opened websocket connection\");\n"; page += " }\n"; page += " logSocket.onmessage = function(event) {\n"; page += " if (!paused) {\n"; page += " var elem = document.getElementById(\"log\");\n"; page += " elem.value += (event.data + \"\\n\");\n"; page += " var total = elem.value.split(\"\\n\");\n"; page += " if (total.length > 8000)\n"; page += " total = total.slice(-8000);\n"; page += " elem.value = total.join(\"\\n\");\n"; page += " elem.scrollTop = elem.scrollHeight;\n"; page += " } else {\n"; page += " pause_log += (event.data + \"\\r\\n\");\n"; page += " }\n"; page += " }\n"; page += " function PauseLog() {\n"; page += " if (!paused) {\n"; page += " document.getElementById(\"Pause\").value = \"Paused\";\n"; page += " paused = true;\n"; page += " } else {\n"; page += " document.getElementById(\"Pause\").value = \"Pause\";\n"; page += " var elem = document.getElementById(\"log\");\n"; page += " elem.innerHTML += pause_log;\n"; page += " elem.scrollTop = elem.scrollHeight;\n"; page += " paused = false;\n"; page += " pause_log = \"\";\n"; page += " }\n"; page += " }\n"; page += "</script>\n"; page += "<title>WeatherFlow Nodeserver Web Interface - Log</title>\n"; page += "</head><body>\n"; page += "<div align=\"center\" style=\"width: 900px; margin: 0 auto;\">\n"; page += WFNServer.MakeMenu(); page += "<textarea id=\"log\" rows=\"45\" cols=\"120\">"; page += "</textarea>\n"; page += "<hr>\n"; page += "<form name=\"log\" action=\"/log\" enctype=\"application/x-www-form-urlencoded\" method=\"post\">\n"; page += "<input type=\"Button\" id=\"Pause\" name=\"Pause\" value=\"Pause\" onclick=\"PauseLog();\"> "; page += "<input type=\"submit\" id=\"Clear\" name=\"Clear\" value=\"Clear\"> "; page += "<input type=\"submit\" name=\"Save\" value=\"Save to\"> "; page += "<input id=\"the-file-input\" type=\"text\" name=\"filename\"> "; page += "Log Level: "; page += "<select name=\"sLogLevel\" onchange=\"this.form.submit()\">"; page += "<option value=\"0\" " + ((WF_Config.LogLevel == 0) ? "selected" : "") + ">Updates</option>"; page += "<option value=\"1\" " + ((WF_Config.LogLevel == 1) ? "selected" : "") + ">Errors</option>"; page += "<option value=\"2\" " + ((WF_Config.LogLevel == 2) ? "selected" : "") + ">Warnings</option>"; page += "<option value=\"3\" " + ((WF_Config.LogLevel == 3) ? "selected" : "") + ">Info</option>"; page += "<option value=\"4\" " + ((WF_Config.LogLevel == 4) ? "selected" : "") + ">Debug</option>"; page += "</select>\n"; page += "</form>\n"; page += "</div>\n"; page += "</body></html>\n"; return(page); }