-__DATA__
-
-@@ index.html.ep
-<!DOCTYPE html>
-<html>
- <head><title>DWeather</title></head>
- <body>
- <script>
- var ws;
- if ("WebSocket" in window) {
- ws = new WebSocket('<%= url_for('index')->to_abs %>');
- //ws = new WebSocket();
- }
- if(typeof(ws) !== 'undefined') {
- ws.onmessage = function (event) {
- document.body.innerHTML += JSON.parse(event.data).test;
- };
- ws.onopen = function (event) {
- ws.send(JSON.stringify({weather: 'WebSocket support works! ♥'}));
- };
- }
- else {
- document.body.innerHTML += 'Browser does not support WebSockets.';
- }
-
- var ws = new WebSocket('<%= url_for('weather')->to_abs %>');
-
- // Incoming messages
- ws.onmessage = function(event) {
- document.body.innerHTML += event.data + '<br/>';
- };
-
- </script>
- <h1>DWeather</h1>
-
- </body>
-</html>
+sub grab_history
+{
+ my $lg = shift;
+ my $let = shift;
+ my $start = shift || time - 86400;
+ my $dayno = shift;
+ my @out;
+
+ if ($lg->open($dayno, 'r+')) {
+ while (my $l = $lg->read) {
+ next unless $l =~ /,"$let":/;
+ my ($t) = $l =~ /"t":(\d+)/;
+ if ($t && $t >= $start) {
+ push @out, $l;
+ }
+ }
+ $lg->close;
+ }
+ return @out;
+}