2019-01-24 10:33:11 +01:00
|
|
|
import { Widget } from "../core/widget";
|
2019-01-23 14:28:41 +01:00
|
|
|
import { Env } from "../env";
|
2019-01-24 13:48:31 +01:00
|
|
|
import { Clock } from "./clock";
|
|
|
|
|
import { Counter } from "./counter";
|
2019-01-22 10:38:44 +01:00
|
|
|
|
2019-01-28 21:32:21 +01:00
|
|
|
export class Discuss extends Widget<Env, {}> {
|
2019-02-02 11:41:19 +01:00
|
|
|
template = "discuss";
|
2019-01-31 15:14:26 +01:00
|
|
|
widgets = { Clock, Counter, ColorWidget };
|
|
|
|
|
state = { validcounter: true, color: "red" };
|
2019-01-22 10:38:44 +01:00
|
|
|
|
|
|
|
|
resetCounter(ev: MouseEvent) {
|
2019-01-25 10:25:42 +01:00
|
|
|
if (this.refs.counter instanceof Counter) {
|
|
|
|
|
this.refs.counter.updateState({ counter: 3 });
|
|
|
|
|
}
|
2019-01-22 10:38:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resetCounterAsync(ev: MouseEvent) {
|
|
|
|
|
setTimeout(() => {
|
2019-01-26 08:40:09 +01:00
|
|
|
if (this.refs.counter2 instanceof Counter) {
|
|
|
|
|
this.refs.counter2.updateState({ counter: 300 });
|
2019-01-25 10:25:42 +01:00
|
|
|
}
|
2019-01-22 10:38:44 +01:00
|
|
|
}, 3000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toggle() {
|
2019-01-26 08:40:09 +01:00
|
|
|
this.updateState({ validcounter: !this.state.validcounter });
|
2019-01-22 10:38:44 +01:00
|
|
|
}
|
2019-01-28 12:13:03 +01:00
|
|
|
|
|
|
|
|
toggleColor() {
|
|
|
|
|
const newColor = this.state.color === "red" ? "blue" : "red";
|
|
|
|
|
this.updateState({ color: newColor });
|
|
|
|
|
}
|
2019-01-29 15:19:02 +01:00
|
|
|
|
2019-01-29 16:13:05 +01:00
|
|
|
addNotif(sticky: boolean) {
|
2019-01-29 15:19:02 +01:00
|
|
|
const text = (<any>this.refs.textinput).value;
|
|
|
|
|
const message = `It is now ${new Date().toLocaleTimeString()}.<br/> Msg: ${text}`;
|
2019-01-29 16:13:05 +01:00
|
|
|
this.env.notifications.add({ title: "hey", message: message, sticky });
|
2019-01-29 15:19:02 +01:00
|
|
|
}
|
2019-01-28 12:13:03 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-28 21:32:21 +01:00
|
|
|
class ColorWidget extends Widget<Env, { color: "red" | "blue" }> {
|
2019-02-02 11:41:19 +01:00
|
|
|
template = "colorwidget";
|
2019-01-22 10:38:44 +01:00
|
|
|
}
|