Correctly handle the end time being 0 in the URL. (#2290)

This commit is contained in:
Brian Brazil 2016-12-18 19:30:52 +00:00 committed by GitHub
parent f421ce0636
commit 2e3b42ad6c
2 changed files with 86 additions and 79 deletions

File diff suppressed because one or more lines are too long

View file

@ -109,7 +109,7 @@ PromConsole.TimeControl = function() {
this.durationElement.value = PromConsole.TimeControl.prototype.getHumanDuration( this.durationElement.value = PromConsole.TimeControl.prototype.getHumanDuration(
PromConsole.TimeControl._initialValues.duration); PromConsole.TimeControl._initialValues.duration);
if (PromConsole.TimeControl._initialValues.endTimeNow === undefined) { if (!PromConsole.TimeControl._initialValues.endTimeNow) {
this.endElement.value = PromConsole.TimeControl.prototype.getHumanDate( this.endElement.value = PromConsole.TimeControl.prototype.getHumanDate(
new Date(PromConsole.TimeControl._initialValues.endTime * 1000)); new Date(PromConsole.TimeControl._initialValues.endTime * 1000));
} }
@ -138,10 +138,17 @@ PromConsole.TimeControl.prototype._setHash = function() {
PromConsole.TimeControl._initialValues = function() { PromConsole.TimeControl._initialValues = function() {
var hash = window.location.hash; var hash = window.location.hash;
var values;
if (hash.indexOf('#pctc') === 0) { if (hash.indexOf('#pctc') === 0) {
return JSON.parse(decodeURIComponent(hash.substring(5))); values = JSON.parse(decodeURIComponent(hash.substring(5)));
} else {
values = {duration: 3600, endTime: 0};
} }
return {duration: 3600, endTime: new Date().getTime() / 1000, endTimeNow: true}; if (values.endTime == 0) {
values.endTime = new Date().getTime() / 1000;
values.endTimeNow = true;
}
return values;
}(); }();
PromConsole.TimeControl.prototype.parseDuration = function(durationText) { PromConsole.TimeControl.prototype.parseDuration = function(durationText) {