144 lines
3.1 KiB
HTML
144 lines
3.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
|
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
|
|
|
|
|
|
<style type="text/css">
|
|
body {
|
|
padding: 0;
|
|
margin: 0;
|
|
}
|
|
|
|
html, body {
|
|
height: 100%;
|
|
width: 100%
|
|
|
|
}
|
|
#main {
|
|
height: 95%;
|
|
|
|
}
|
|
#bottombar {
|
|
height: 5%;
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div id ="main">
|
|
</div>
|
|
|
|
<div id="bottombar">
|
|
<a href="cams.html" class="w3-button w3-black">Cam List</a>
|
|
<a href="map.html" class="w3-button w3-black">Cam Map</a>
|
|
<a href="admin.html" class="w3-button w3-black">Add Camera</a>
|
|
<a href="db.html" class="w3-button w3-black">WU obs</a>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
function addZero(i) {
|
|
if (i < 10) {
|
|
i = "0" + i;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
|
|
//STATIONS KCRW,KHTS,KPKB,KCKB,KEKN,KBKW,KPIT,KAGC,KZZV,KMGW,KHLG,KDUJ,KFKL,KLBE,KBVI,KJKL,KLOZ,KSME,KSJS,KSYM
|
|
//LOCAL STATIONS KCRW,KHTS,KPKB,KCKB,KEKN,KBKW
|
|
var icao = ["KCRW","KHTS","KPKB","KCKB","KEKN","KBKW"];
|
|
var metars = {}
|
|
stnid = icao.join();
|
|
|
|
|
|
|
|
|
|
for (var m = 0; m < icao.length; m++) {
|
|
metars[icao[m]] = null;
|
|
|
|
}
|
|
|
|
|
|
let url = 'https://api.synopticdata.com/v2/stations/latest?&token=5b49fa1894c04c1a91e621cefa783bfa&within=15&timeformat=%25Y%25m%25d&obtimezone=utc&units=english&output=json&status=active&stid=' + stnid;
|
|
//let url = 'https://api.synopticdata.com/v2/stations/latest?&token=5b49fa1894c04c1a91e621cefa783bfa&within=15&timeformat=%25Y%25m%25d&obtimezone=utc&units=english&output=json&status=active&stid=KCRW,KHTS,KPKB,KCKB,KEKN,KBKW';
|
|
grab_update(url);
|
|
setInterval(grab_update,60000,url);
|
|
|
|
function grab_update(url) {
|
|
|
|
fetch(url)
|
|
.then(res => res.json())
|
|
.then((out) => {
|
|
|
|
|
|
for (var i = 0; i < out["STATION"].length; i++) {
|
|
//document.write(out["STATION"][i].OBSERVATIONS.metar_value_1.value);
|
|
//document.write('<br>');
|
|
metars[out["STATION"][i].STID] = out["STATION"][i].OBSERVATIONS.metar_value_1.value;
|
|
//$("#main").html($('#main').html() + out["STATION"][i].OBSERVATIONS.metar_value_1.value + '<br>');
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
var currentdate = new Date();
|
|
var datetime = "Last Update: "
|
|
+ addZero((currentdate.getUTCMonth()+1)) + "/"
|
|
+ addZero(currentdate.getUTCDate()) + "/"
|
|
+ currentdate.getUTCFullYear() + " @ "
|
|
+ addZero(currentdate.getUTCHours()) + ":"
|
|
+ addZero(currentdate.getUTCMinutes()) + ":"
|
|
+ addZero(currentdate.getUTCSeconds()) + "Z";
|
|
|
|
|
|
var div = document.getElementById('main');
|
|
div.innerHTML = "";
|
|
for (l in metars) {
|
|
if (metars[l] != null) {
|
|
div.innerHTML += metars[l];
|
|
div.innerHTML += '<br>';
|
|
}
|
|
|
|
}
|
|
div.innerHTML += datetime;
|
|
div.innerHTML += '<br>';
|
|
div.innerHTML += '<br>';
|
|
div.innerHTML += "Data courtesy of SynopticLabs (MesoWest) - 5 minute obs will run 10-15 minutes behind real-time, but any METAR/SPECI should update immediately"
|
|
div.innerHTML += '<br>';
|
|
div.innerHTML += 'Leave this page open and obs will update automatically';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</body>
|
|
</html> |