summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-12-12 16:21:01 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-12-12 16:21:01 -0500
commitc569756a0c0d923f2e229f2a516cf8e41f7920d2 (patch)
tree85ccec8f0fd4934073242dbf1b3a7b0c70840497
parenteae1880ef45f0a4a1cd9c92d403f78f3ae1e0df8 (diff)
Make the default time span configurable.
-rw-r--r--jarmon/jarmon.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/jarmon/jarmon.js b/jarmon/jarmon.js
index 3357864..cef338b 100644
--- a/jarmon/jarmon.js
+++ b/jarmon/jarmon.js
@@ -1280,7 +1280,10 @@ jarmon.Chart.STACKED_OPTIONS = {
/**
* A selection of useful time ranges
*
- * This is an array of `["human description", function]` pairs.
+ * For the most part, this is an array of `["human description", function]`
+ * pairs. However, if a third member of a tuple is `===true`, then that tuple
+ * is used as the default option. If no tuple is identified as the default this
+ * way, then the default is the first tuple.
*
* @todo This should probably be a member of jarmon.ChartCoordinator.
*
@@ -1334,14 +1337,18 @@ jarmon.ChartCoordinator = function(ui, charts) {
};
var options = this.ui.find('select[name="from_standard"]');
+ var default_index = 0; // Select the first shortcut by default
for(var i=0; i<jarmon.timeRangeShortcuts.length; i++) {
options.append($('<option />').text(jarmon.timeRangeShortcuts[i][0]));
+ if (jarmon.timeRangeShortcuts[i][2] === true) {
+ default_index = i;
+ }
}
// Append a custom option for when the user selects an area of the graph
options.append($('<option />').text('custom'));
- // Select the first shortcut by default
- options.val(jarmon.timeRangeShortcuts[0][0]);
+ // Select whichever timeRangeShortcut is the default
+ options.val(jarmon.timeRangeShortcuts[default_index][0]);
options.bind('change', function(e) {
// No point in updating if the user chose custom.
@@ -1638,7 +1645,7 @@ jarmon.ChartCoordinator.prototype.setTimeRange = function(from, to) {
};
/**
- * Reset all charts and the input form to the default time range - last hour
+ * Reset all charts and the input form to the default time range.
*
* @method
**/