blob: 8f0389de9e791ca49872e4762f87f9188a426cb4 (
plain) (
tree)
|
|
<meta name=viewport content='width=device-width, initial-scale=1.0'>
<meta charset=utf-8 />
<style>
table, td, tr, th {
border: 1px solid red;
}
</style>
<title>napad/nadzor.py</title>
<h1>napad/nadzor.py</h1>
<table>
<tr>
<th>
ime podatka
</th>
<th>
vrednost
</th>
</tr>
<tr><td>čas zadnje ACCEPTED zastavice</td><td id=lastaccepteddate></td></tr>
<tr><td>neposlanih zastavic</td><td id=notsentcount></td></tr>
</table>
<div id=groupbymsg></div>
<label for=customquery>
<h3>custom query</h3>
</label>
<textarea cols=80 id=customquery placeholder="select * from flags limit 10">select flag,date,msg from flags limit 10</textarea>
<div id=customqueryres></div>
<script>
function htmltablefromquery (rows) {
let table = document.createElement("table");
for (let i = 0; i < rows.length; i++) {
let tr = document.createElement("tr");
for (let j = 0; j < rows[i].length; j++) {
let td = document.createElement("td");
td.innerText = rows[i][j];
tr.appendChild(td);
}
let td = document.createElement("td");
td.innerText = rows[i][1];
table.appendChild(tr);
}
return table;
}
async function refreshview () {
fetch("sql", {"method": "post", "body": "select count(flag) from flags where sent=0"}).then((r) => {r.json().then((t)=>{notsentcount.innerText = t[0][0]})});
let msgskip = 6; // 36 v dejanski igri
fetch("sql", {"method": "post", "body": "select substr(msg, " + msgskip + "),count(substr(msg, " + msgskip + ")) from flags group by substr(msg, " + msgskip + ")"}).then((r) => {r.json().then((rows)=>{
groupbymsg.innerHTML = "";
groupbymsg.appendChild(htmltablefromquery(rows));
})});
fetch("sql", {"method": "post", "body": "select submitted from flags where status='ACCEPTED' order by submitted desc limit 1"}).then((r) => {r.json().then((t)=>{lastaccepteddate.innerText = t[0][0]})});
fetch("sql", {"method": "post", "body": customquery.value}).then((r) => {r.json().then((rows)=>{
customqueryres.innerHTML = "";
customqueryres.appendChild(htmltablefromquery(rows));
})});
}
setInterval(refreshview, 5555);
</script>
|