Skip to content

Commit

Permalink
Wouldn't it be nice if the title was the date you were looking at?
Browse files Browse the repository at this point in the history
Now it is. And refresh_data now does the job of changing the url and
the title both.
  • Loading branch information
Timothy Martin committed Mar 3, 2014
1 parent 8a55463 commit f984c40
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
18 changes: 12 additions & 6 deletions Web Server/historical.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ <h2>PV Array Current:</h2>

function refresh_data() {

if (displayDate == get_formatted_date()) { // if it's today.
update_URL('historical.html');
document.title = "MonitorMate — Today";
} else {
update_URL('historical.html', displayDate);
document.title = "MonitorMate — " + displayDate;
}

// // FIXME: check if i need to redraw the charts, it's a waste of time otherwise.
// var chartDate = null;
//
Expand Down Expand Up @@ -85,22 +93,20 @@ <h2>PV Array Current:</h2>

if (delta == 0) {
displayDate = get_formatted_date();
update_URL('historical.html');
refresh_data();
} else {
split_date = displayDate.split(/[- :]/);
new_date = new Date(parseInt(split_date[0]), parseInt(split_date[1] - 1), parseInt(split_date[2]));
updated_date = new Date(new_date.getTime() + (delta * 86400000)); // one day in milliseconds

if (updated_date < (new Date())) { // make you're not sneaking into the future.
displayDate = get_formatted_date(updated_date);
update_URL('historical.html', displayDate);
refresh_data();
displayDate = get_formatted_date(updated_date);
} else {
alert("You can't predict the future...");
return;
}
}


refresh_data();

}

Expand Down
3 changes: 2 additions & 1 deletion Web Server/js/monitormate.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,10 +745,11 @@ function chart_days_of_month(date) {
case "historical.html":
displayDate = dateString;
update_URL('historical.html', displayDate);
document.title = "MonitorMate — " + displayDate;
refresh_data();
break;
default:
location.assign('historical.html?date=' + dateString);
location.assign('historical.html?date=' + displayDate);
break;
}
}
Expand Down

0 comments on commit f984c40

Please sign in to comment.