last modified added

master
Tomek Dubrownik 2013-09-23 16:47:58 +02:00
parent 2680322afb
commit e00bd8b018
2 changed files with 9 additions and 4 deletions

View File

@ -3,13 +3,16 @@ window.onload = function() {
var today = new Date(), var today = new Date(),
year = 1900 + today.getYear(), year = 1900 + today.getYear(),
month = today.getMonth() + 1, month = today.getMonth() + 1,
urlBase = 'https://kasownik.hackerspace.pl/api/'; urlBase = 'https://kasownik.hackerspace.pl/api/',
modified;
for(i = 0; i < 12; ++i) { for(i = 0; i < 12; ++i) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open("GET", urlBase + 'month/'+ year + '/' + month + '.json', false); xhr.open("GET", urlBase + 'month/'+ year + '/' + month + '.json', false);
xhr.send(); xhr.send();
var res = JSON.parse(xhr.response).content, var data = JSON.parse(xhr.response),
date = new Date(year, month, 1); res = data.content,
date = new Date(year, month, 1);
modified = modified || data.modified;
required.unshift({ x: date.getTime() / 1000, y: res.required }); required.unshift({ x: date.getTime() / 1000, y: res.required });
paid.unshift({ x: date.getTime() / 1000, y: res.paid }); paid.unshift({ x: date.getTime() / 1000, y: res.paid });
@ -25,6 +28,8 @@ window.onload = function() {
} }
} }
console.log(required, paid); console.log(required, paid);
var lastmod = document.getElementById("lastmod");
lastmod.innerHTML = modified;
var palette = new Rickshaw.Color.Palette( { scheme: 'munin' } ); var palette = new Rickshaw.Color.Palette( { scheme: 'munin' } );
var graph = new Rickshaw.Graph({ var graph = new Rickshaw.Graph({
element: document.getElementById("plot"), element: document.getElementById("plot"),

View File

@ -11,7 +11,7 @@
<body> <body>
<div id="legend"></div> <div id="legend"></div>
<div id="plot"></div> <div id="plot"></div>
Last modified: <span id="lastmod">-</span>
<style> <style>
#legend { #legend {
display: inline-block; display: inline-block;