taobin_project/webs/index.html
2024-04-04 22:33:13 +07:00

78 lines
1.9 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" type="text/css" href="/css/minimal2.css">
</head>
<body>
<div id="begin"> begin </div>
</body>
<script>
function readFile(filePath) {
var result = null;
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", filePath, false);
xmlhttp.send();
if (xmlhttp.status==200) {
result = xmlhttp.responseText;
}
xmlhttp.abort();
return result;
}
function show_table_one_row( str_req){
var all_out = ""
var str1 = readFile("?"+str_req+"&concat");
console.log("["+ str1+"]")
const sp1 = str1.split("|");
if( sp1.length > 0){
all_out += "<H2>" + sp1[0] + "</H2>"
const sp2 = sp1[1].split(",");
all_out += "<table>";
all_out += "<tr>";
for (let i = 0; i < sp2.length; i++) {
const sp3 = sp2[i].split("=");
if( sp3.length == 2){
all_out += "<th>" + sp3[0] + "</th>"
}
}
all_out += "</tr>";
all_out += "<tr>";
for (let i = 0; i < sp2.length; i++) {
const sp3 = sp2[i].split("=");
if( sp3.length == 2){
all_out += "<td>" + sp3[1] + "</td>"
}
}
all_out += "</tr>";
all_out += "</table>";
}
return all_out;
}
function RereshAll(){
var all_out = ""
all_out += show_table_one_row("machine")
//console.log("Test readFile " + str_out)
all_out += show_table_one_row("order-position")
all_out += show_table_one_row("stock")
document.getElementById("begin").innerHTML = all_out;
}
setInterval( RereshAll, 1000);
</script>
</html>