Files
test/summary.html
2025-12-11 02:34:10 +00:00

175 lines
3.9 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>RLX Power Outage Map</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js" integrity="sha256-6XMVI0zB8cRzfZjqKcD01PBsAy3FlDASrlC8SxCpInY=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.1/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link href="https://unpkg.com/tabulator-tables@5.4.4/dist/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" src="https://unpkg.com/tabulator-tables@5.4.4/dist/js/tabulator.min.js"></script>
</head>
<body>
<div id="dialog">
Enter Start/End Times in UTC
<input type="datetime-local" id="start" name="start">
<input type="datetime-local" id="end" name="end">
<button id="archive" onclick="rackandstack()">Load Data From Selected Time Period</button>
</div>
<div id="countysum"></div>
<script>
function googleMap(lat,lon){
return "http://maps.google.com/maps?t=k&q=loc:" + lat + "+" + lon + "&basemap=satellite";
}
var countysum;
function rackandstack() {
var start = document.getElementById("start").value;
var end = document.getElementById("end").value;
$.getJSON(`main.php?service=newpowerapi&max=potato&start=${start}&end=${end}`, function(data) {
$.getJSON('main.php?service=newpowerapi&county=r', function(data1) {
countylist(data,data1);
});
}
);
}
var wvstateout,kystateout,ohstateout,vastateout;
var wvstateserved,kystateserved,ohstateserved,vastateserved;
function countylist(data,data1) {
for (i=0; i< data.length; i++) {
for (j=0; j<data1.length;j++){
if (data[i].county == data1[j].county && data[i].state == data1[j].state) {
console.log(data[i]);
data[i]['served'] = data1[j]['served'];
data[i]['percent'] = Math.round(data[i]['max_outage']/data[i]['served']*1000)/10;
}
}
}
states = ['WV','KY','OH','VA'];
for (l in states) {
stateout = 0;
stateserved = 0;
statepercent = 0;
for (k=0; k<data.length; k++) {
if (states[l] == data[k]['state']) {
stateout = stateout + parseFloat(data[k]['max_outage']);
stateserved = stateserved + parseFloat(data[k]['served']);
statepercent = Math.round(stateout/stateserved*1000)/10;
if (states[l] == 'WV') {
wvstateout = stateout;
wvstateserved = stateserved;
}
if (states[l] == 'VA') {
vastateout = stateout;
vastateserved = stateserved;
}
if (states[l] == 'KY') {
kystateout = stateout;
kystateserved = stateserved;
}
if (states[l] == 'OH') {
ohstateout = stateout;
ohstateserved = stateserved;
}
}
}
}
for (m in data) {
if (data[m]['state'] == 'WV') {
data[m]['stateout'] = wvstateout;
data[m]['stateserved'] = wvstateserved;
data[m]['statepercent'] = Math.floor(wvstateout/wvstateserved*1000)/10;
}
if (data[m]['state'] == 'VA') {
data[m]['stateout'] = vastateout;
data[m]['stateserved'] = vastateserved;
data[m]['statepercent'] = Math.floor(vastateout/vastateserved*1000)/10;
}
if (data[m]['state'] == 'KY') {
data[m]['stateout'] = kystateout;
data[m]['stateserved'] = kystateserved;
data[m]['statepercent'] = Math.floor(kystateout/kystateserved*1000)/10;
}
if (data[m]['state'] == 'OH') {
data[m]['stateout'] = ohstateout;
data[m]['stateserved'] = ohstateserved;
data[m]['statepercent'] = Math.floor(ohstateout/ohstateserved*1000)/10;
}
}
buildtable(data);
}
function buildtable(data) {
table.setData(data);
}
var table = new Tabulator("#countysum", {
responsiveLayout:true,
tooltipsHeader:true,
columns:[
{title:"County", field:"county"},
{title:"State", field:"state"},
{title:"Max Outages", field:"max_outage"},
{title:"Served", field:"served"},
{title:"Max % Out", field:"percent"},
{title:"State Total Out", field:"stateout"},
{title:"State Total Served", field:"stateserved"},
{title:"State Total % Out", field:"statepercent"}
],
});
</script>
</body>
</html>