diff --git a/api/js/etemplate/et2_widget_countdown.js b/api/js/etemplate/et2_widget_countdown.js index 509bce8e48..f52db3aea4 100644 --- a/api/js/etemplate/et2_widget_countdown.js +++ b/api/js/etemplate/et2_widget_countdown.js @@ -112,6 +112,20 @@ var et2_countdown = /** @class */ (function (_super) { } } } + if (this.options.precision) { + var units = ['days', 'hours', 'minutes', 'seconds']; + for (var u = 0; u < 4; ++u) { + if (values[units[u]]) { + for (var n = u + this.options.precision; n < 4; n++) { + this[units[n]].hide(); + } + break; + } + else { + this[units[u]].hide(); + } + } + } return distance; }; et2_countdown.prototype._getIndicator = function (_v) { @@ -136,6 +150,12 @@ var et2_countdown = /** @class */ (function (_super) { default: true, description: "Only displays none empty values." }, + precision: { + name: "how many counters to show", + type: "integer", + default: 0, + description: "Limit number of counters, eg. 2 does not show minutes and seconds, if days are displayed" + }, alarm: { name: "alarm", type: "any", diff --git a/api/js/etemplate/et2_widget_countdown.ts b/api/js/etemplate/et2_widget_countdown.ts index d0c313d36c..6b20d4f4e8 100644 --- a/api/js/etemplate/et2_widget_countdown.ts +++ b/api/js/etemplate/et2_widget_countdown.ts @@ -47,6 +47,12 @@ export class et2_countdown extends et2_valueWidget { default: true, description: "Only displays none empty values." }, + precision: { + name: "how many counters to show", + type: "integer", + default: 0, // =all + description: "Limit number of counters, eg. 2 does not show minutes and seconds, if days are displayed" + }, alarm: { name: "alarm", type: "any", @@ -146,6 +152,25 @@ export class et2_countdown extends et2_valueWidget { } } } + if (this.options.precision) + { + const units = ['days','hours','minutes','seconds']; + for (let u=0; u < 4; ++u) + { + if (values[units[u]]) + { + for(let n=u+this.options.precision; n < 4; n++) + { + this[units[n]].hide(); + } + break; + } + else + { + this[units[u]].hide(); + } + } + } return distance; }