jqwidgets-framework
Version:
jQWidgets is an advanced Angular, Vue, Blazor, React, Web Components, jquery, ASP .NET MVC, Custom Elements and HTML5 UI framework.
66 lines (52 loc) • 2.33 kB
text/typescript
import { Component, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
import { jqxNotificationComponent } from 'jqwidgets-ng/jqxnotification';
import { jqxButtonComponent } from 'jqwidgets-ng/jqxbuttons';
import { jqxInputComponent } from 'jqwidgets-ng/jqxinput';
export class AppComponent implements AfterViewInit {
timerNotification: jqxNotificationComponent;
correctNotification: jqxNotificationComponent;
wrongNotification: jqxNotificationComponent;
errorTimeOutNotification: jqxNotificationComponent;
answerInput: jqxInputComponent;
timerNotificationContent: ElementRef;
notificationWidth: number = 300;
position: string = 'top-right';
interval: any = null;
seconds = 30;
intervalStart() {
let interval = setInterval(() => {
if (this.seconds > 1) {
this.seconds--;
let innerSpan = this.timerNotificationContent.nativeElement.getElementsByTagName('SPAN')[0];
innerSpan.innerText = this.seconds;
// TODO: Try to create better solution
this.timerNotification.closeLast();
this.timerNotification.open();
} else {
clearInterval(interval);
this.timerNotification.closeLast();
}
}, 1000);
return interval;
}
ngAfterViewInit() {
this.interval = this.intervalStart();
}
submitAnswerClick(): void {
if (this.seconds > 1) {
if (this.answerInput.val() == 8) {
this.correctNotification.open()
clearInterval(this.interval);
this.timerNotification.closeLast();
} else {
this.wrongNotification.open();
}
} else {
this.errorTimeOutNotification.open();
}
};
}