From 1d559e9263191cc31ee497c75ea1ac898864fb39 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 15 Mar 2022 16:57:56 +0100 Subject: [PATCH] Allow multiple alarms being set for countdown widget --- api/js/etemplate/et2_widget_countdown.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/et2_widget_countdown.ts b/api/js/etemplate/et2_widget_countdown.ts index 87edbde553..b9d5e8d449 100644 --- a/api/js/etemplate/et2_widget_countdown.ts +++ b/api/js/etemplate/et2_widget_countdown.ts @@ -120,10 +120,17 @@ export class et2_countdown extends et2_valueWidget { let distance = this.time.getTime() - now.getTime(); if (distance < 0) return 0; - if (this.options.alarm > 0 && this.options.alarm == distance/1000 && typeof this.onAlarm == 'function') + + let alarms = Array.isArray(this.options.alarm) ? this.options.alarm : [this.options.alarm]; + + for (let i=0;i<=alarms.length;i++) { - this.onAlarm(); + if (alarms[i] > 0 && alarms[i] == distance/1000 && typeof this.onAlarm == 'function') + { + this.onAlarm(); + } } + let values = { days: Math.floor(distance / (1000 * 60 * 60 * 24)), hours: Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)),