Skip to content

Commit

Permalink
Merge pull request #2 from mateusgreg/master
Browse files Browse the repository at this point in the history
Using date interval to filter reports.
  • Loading branch information
vitor-costa committed Dec 5, 2014
2 parents 22cd7ab + 6df62f0 commit f3b0e2b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions public/relatorioCodigo.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,24 @@ window.onload = function() {

$(document).on('click', '#button', function() {
var selected = $('input[name="report"]:checked').val();
$.getJSON('http://localhost:3002/api/2014120410/2014120410', function(data, status) {
var dateNow = $("#dateNow");
var initialDate = $("#initialDate").val();
var finalDate = $("#finalDate").val();
var url;

if (dateNow.is(":checked") == true) {
url = "http://rest.riob.us/all?callback=?";
}
else {
url = "http://localhost:3002/api/" + initialDate + "/" + finalDate;
}

$.getJSON(url, function(data, status) {

if (dateNow.is(":checked")) {
data = [data];
}

switch (selected) {
case "empty-lines":
result = emptyLines(data)
Expand Down Expand Up @@ -217,7 +234,7 @@ window.onload = function() {
result = buses_in_speed_range(mins, maxs, data, lines);
break;
}
document.getElementById("resposta").innerHTML = "JSON.stringify(result)";
document.getElementById("resposta").innerHTML = JSON.stringify(result);
});
});
}
Expand Down

0 comments on commit f3b0e2b

Please sign in to comment.