-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbottom_scripts.js
38 lines (34 loc) · 1.08 KB
/
bottom_scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* Scripts run once the page is loaded */
$(document).ready(function(){
$.ajax('http://thecloudonline.net/psusnowdepth/getdata.php', {
success: function(data) {
var rawdata = $.parseJSON(data);
var curdepthval = rawdata[rawdata.length - 1][1];
$('#currentdepth').text((curdepthval == -1) ? '< 1' : curdepthval);
var curdepthdate = new Date(rawdata[rawdata.length - 1][0]);
$('#currentdatelabel').text(" as of " + (curdepthdate.getUTCMonth()+1) + '/' + curdepthdate.getUTCDate() + '/' +
curdepthdate.getUTCFullYear());
var graphdata = rawdata;
for (var i = 0; i < graphdata.length; i++) {
if(graphdata[i][1] == -1) {
graphdata[i][1] = 0.5;
}
};
$.plot($("#depthgraph"), [graphdata], {
xaxis: {
mode: "time",
timeformat: "%m/%d/%y"
},
series: {
lines: {
show: true
},
points: {
show: true
}
},
colors: ['#000D56']
});
}
})
});