mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +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();
|
var distance = time.getTime() - now.getTime();
|
||||||
if (distance < 0)
|
if (distance < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
if (this.options.alarm > 0 && this.options.alarm == distance / 1000 && typeof this.onAlarm == 'function') {
|
||||||
|
this.onAlarm();
|
||||||
|
}
|
||||||
var values = {
|
var values = {
|
||||||
days: Math.floor(distance / (1000 * 60 * 60 * 24)),
|
days: Math.floor(distance / (1000 * 60 * 60 * 24)),
|
||||||
hours: Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)),
|
hours: Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)),
|
||||||
@ -136,6 +139,18 @@ var et2_countdown = /** @class */ (function (_super) {
|
|||||||
type: "string",
|
type: "string",
|
||||||
default: true,
|
default: true,
|
||||||
description: "Only displays none empty values."
|
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;
|
return et2_countdown;
|
||||||
|
@ -47,7 +47,20 @@ export class et2_countdown extends et2_baseWidget {
|
|||||||
type: "string",
|
type: "string",
|
||||||
default: true,
|
default: true,
|
||||||
description: "Only displays none empty values."
|
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;
|
private time : et2_date;
|
||||||
@ -113,7 +126,10 @@ export class et2_countdown extends et2_baseWidget {
|
|||||||
let distance = time.getTime() - now.getTime();
|
let distance = time.getTime() - now.getTime();
|
||||||
|
|
||||||
if (distance < 0) return 0;
|
if (distance < 0) return 0;
|
||||||
|
if (this.options.alarm > 0 && this.options.alarm == distance/1000 && typeof this.onAlarm == 'function')
|
||||||
|
{
|
||||||
|
this.onAlarm();
|
||||||
|
}
|
||||||
let values = {
|
let values = {
|
||||||
days: Math.floor(distance / (1000 * 60 * 60 * 24)),
|
days: Math.floor(distance / (1000 * 60 * 60 * 24)),
|
||||||
hours: Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)),
|
hours: Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)),
|
||||||
|
Loading…
Reference in New Issue
Block a user