mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-25 16:19:00 +01:00
Implement an alarm callback for countdown widget
This commit is contained in:
parent
5d6965a2e9
commit
d957ed41d0
@ -84,6 +84,9 @@ var et2_countdown = /** @class */ (function (_super) {
|
||||
var distance = time.getTime() - now.getTime();
|
||||
if (distance < 0)
|
||||
return 0;
|
||||
if (this.options.alarm > 0 && this.options.alarm == distance / 1000 && typeof this.onAlarm == 'function') {
|
||||
this.onAlarm();
|
||||
}
|
||||
var values = {
|
||||
days: Math.floor(distance / (1000 * 60 * 60 * 24)),
|
||||
hours: Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)),
|
||||
@ -136,6 +139,18 @@ var et2_countdown = /** @class */ (function (_super) {
|
||||
type: "string",
|
||||
default: true,
|
||||
description: "Only displays none empty values."
|
||||
},
|
||||
alarm: {
|
||||
name: "alarm",
|
||||
type: "any",
|
||||
default: "",
|
||||
description: "Defines an alarm set before the countdown is finished, it should be in seconds"
|
||||
},
|
||||
onAlarm: {
|
||||
name: "alarm callback",
|
||||
type: "js",
|
||||
default: "",
|
||||
description: "Defines a callback to gets called at alarm - timer. This only will work if there's an alarm set."
|
||||
}
|
||||
};
|
||||
return et2_countdown;
|
||||
|
@ -47,7 +47,20 @@ export class et2_countdown extends et2_baseWidget {
|
||||
type: "string",
|
||||
default: true,
|
||||
description: "Only displays none empty values."
|
||||
},
|
||||
alarm: {
|
||||
name: "alarm",
|
||||
type: "any",
|
||||
default: "",
|
||||
description: "Defines an alarm set before the countdown is finished, it should be in seconds"
|
||||
},
|
||||
onAlarm: {
|
||||
name: "alarm callback",
|
||||
type: "js",
|
||||
default: "",
|
||||
description: "Defines a callback to gets called at alarm - timer. This only will work if there's an alarm set."
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private time : et2_date;
|
||||
@ -113,7 +126,10 @@ export class et2_countdown extends et2_baseWidget {
|
||||
let distance = time.getTime() - now.getTime();
|
||||
|
||||
if (distance < 0) return 0;
|
||||
|
||||
if (this.options.alarm > 0 && this.options.alarm == 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)),
|
||||
|
Loading…
Reference in New Issue
Block a user