From f984c4071d963951d9176333db6737670356948f Mon Sep 17 00:00:00 2001 From: Timothy Martin Date: Sun, 2 Mar 2014 21:52:04 -0800 Subject: [PATCH] Wouldn't it be nice if the title was the date you were looking at? Now it is. And refresh_data now does the job of changing the url and the title both. --- Web Server/historical.html | 18 ++++++++++++------ Web Server/js/monitormate.js | 3 ++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Web Server/historical.html b/Web Server/historical.html index 3ab2882..de9ae35 100644 --- a/Web Server/historical.html +++ b/Web Server/historical.html @@ -53,6 +53,14 @@

PV Array Current:

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; // @@ -85,22 +93,20 @@

PV Array Current:

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(); } diff --git a/Web Server/js/monitormate.js b/Web Server/js/monitormate.js index 267e4a1..0908399 100644 --- a/Web Server/js/monitormate.js +++ b/Web Server/js/monitormate.js @@ -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; } }