Merge pull request #344 from thecodingmachine/banned-message-modal
Banned message modal
This commit is contained in:
commit
54d4a1b1f8
@ -1,12 +1,26 @@
|
|||||||
import {TypeMessageInterface} from "./UserMessageManager";
|
import {TypeMessageInterface} from "./UserMessageManager";
|
||||||
import {HtmlUtils} from "../WebRtc/HtmlUtils";
|
import {HtmlUtils} from "../WebRtc/HtmlUtils";
|
||||||
|
|
||||||
|
let modalTimeOut : NodeJS.Timeout;
|
||||||
|
|
||||||
export class TypeMessageExt implements TypeMessageInterface{
|
export class TypeMessageExt implements TypeMessageInterface{
|
||||||
private nbSecond = 0;
|
private nbSecond = 0;
|
||||||
private maxNbSecond = 10;
|
private maxNbSecond = 10;
|
||||||
private titleMessage = 'IMPORTANT !';
|
private titleMessage = 'IMPORTANT !';
|
||||||
|
|
||||||
showMessage(message: string): void {
|
showMessage(message: string, canDeleteMessage: boolean = true): void {
|
||||||
|
//delete previous modal
|
||||||
|
try{
|
||||||
|
if(modalTimeOut){
|
||||||
|
clearTimeout(modalTimeOut);
|
||||||
|
}
|
||||||
|
const modal = HtmlUtils.getElementByIdOrFail('report-message-user');
|
||||||
|
modal.remove();
|
||||||
|
}catch (err){
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
//create new modal
|
||||||
const div : HTMLDivElement = document.createElement('div');
|
const div : HTMLDivElement = document.createElement('div');
|
||||||
div.classList.add('modal-report-user');
|
div.classList.add('modal-report-user');
|
||||||
div.id = 'report-message-user';
|
div.id = 'report-message-user';
|
||||||
@ -34,21 +48,24 @@ export class TypeMessageExt implements TypeMessageInterface{
|
|||||||
|
|
||||||
this.nbSecond = this.maxNbSecond;
|
this.nbSecond = this.maxNbSecond;
|
||||||
setTimeout((c) => {
|
setTimeout((c) => {
|
||||||
this.forMessage(title);
|
this.forMessage(title, canDeleteMessage);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
forMessage(title: HTMLParagraphElement){
|
forMessage(title: HTMLParagraphElement, canDeleteMessage: boolean = true){
|
||||||
this.nbSecond -= 1;
|
this.nbSecond -= 1;
|
||||||
title.innerText = `${this.titleMessage} (${this.nbSecond})`;
|
title.innerText = `${this.titleMessage} (${this.nbSecond})`;
|
||||||
if(this.nbSecond > 0){
|
if(this.nbSecond > 0){
|
||||||
setTimeout(() => {
|
modalTimeOut = setTimeout(() => {
|
||||||
this.forMessage(title);
|
this.forMessage(title, canDeleteMessage);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}else{
|
}else {
|
||||||
title.innerText = this.titleMessage;
|
title.innerText = this.titleMessage;
|
||||||
|
|
||||||
const imgCancel : HTMLImageElement = document.createElement('img');
|
if (!canDeleteMessage) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const imgCancel: HTMLImageElement = document.createElement('img');
|
||||||
imgCancel.id = 'cancel-report-user';
|
imgCancel.id = 'cancel-report-user';
|
||||||
imgCancel.src = 'resources/logos/close.svg';
|
imgCancel.src = 'resources/logos/close.svg';
|
||||||
|
|
||||||
@ -64,4 +81,7 @@ export class Ban extends TypeMessageExt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Banned extends TypeMessageExt {
|
export class Banned extends TypeMessageExt {
|
||||||
|
showMessage(message: string){
|
||||||
|
super.showMessage(message, false);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user