-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
239 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* Alert handler | ||
*/ | ||
export declare class AlertHandler { | ||
/** | ||
* Structures alert handler | ||
* @param mode | ||
* @returns structure | ||
*/ | ||
private structure; | ||
/** | ||
* Fires warning | ||
* @param [message] | ||
*/ | ||
fireWarning(message?: string): void; | ||
/** | ||
* Fires success | ||
* @param [message] | ||
*/ | ||
fireSuccess(message?: string): void; | ||
/** | ||
* Fires danger | ||
* @param [message] | ||
*/ | ||
fireDanger(message?: string): void; | ||
/** | ||
* Fires info | ||
* @param [message] | ||
*/ | ||
fireInfo(message?: string): void; | ||
/** | ||
* Fires light | ||
* @param [message] | ||
*/ | ||
fireLight(message?: string): void; | ||
/** | ||
* Fires dark | ||
* @param [message] | ||
*/ | ||
fireDark(message?: string): void; | ||
/** | ||
* Fires primary | ||
* @param [message] | ||
*/ | ||
firePrimary(message?: string): void; | ||
/** | ||
* Fires secondary | ||
* @param [message] | ||
*/ | ||
fireSecondary(message?: string): void; | ||
/** | ||
* Fires timer | ||
* @param alert | ||
*/ | ||
private fireTimer; | ||
private sleep; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,121 @@ | ||
import { TMode } from '../model/TMode' | ||
|
||
/** | ||
* Alert handler | ||
*/ | ||
export class AlertHandler { | ||
constructor(parameters) { | ||
|
||
|
||
/** | ||
* Structures alert handler | ||
* @param mode | ||
* @returns structure | ||
*/ | ||
private structure(mode: TMode, content: string): string { | ||
return '<div class="alert alert-' + mode + '" role="alert">' + content + '</div>' | ||
} | ||
|
||
/** | ||
* Fires warning | ||
* @param [message] | ||
*/ | ||
public fireWarning(message?:string): void { | ||
if (message == undefined) { | ||
message = "Warning: Something went wrong!"; | ||
} | ||
this.fireTimer(this.structure('warning', message )); | ||
} | ||
|
||
/** | ||
* Fires success | ||
* @param [message] | ||
*/ | ||
public fireSuccess(message?:string): void { | ||
if (message == undefined) { | ||
message = "Success: Something went right!"; | ||
} | ||
this.fireTimer(this.structure('success', message )); | ||
} | ||
|
||
/** | ||
* Fires danger | ||
* @param [message] | ||
*/ | ||
public fireDanger(message?:string): void { | ||
if (message == undefined) { | ||
message = "Danger: Something went wrong!"; | ||
} | ||
this.fireTimer(this.structure('danger', message )); | ||
} | ||
|
||
/** | ||
* Fires info | ||
* @param [message] | ||
*/ | ||
public fireInfo(message?:string): void { | ||
if (message == undefined) { | ||
message = "Info: Something went right!"; | ||
} | ||
this.fireTimer(this.structure('info', message )); | ||
} | ||
|
||
/** | ||
* Fires light | ||
* @param [message] | ||
*/ | ||
public fireLight(message?:string): void { | ||
if (message == undefined) { | ||
message = "Light: Something went right!"; | ||
} | ||
this.fireTimer(this.structure('light', message )); | ||
} | ||
|
||
/** | ||
* Fires dark | ||
* @param [message] | ||
*/ | ||
public fireDark(message?:string): void { | ||
if (message == undefined) { | ||
message = "Dark: Something went right!"; | ||
} | ||
this.fireTimer(this.structure('dark', message )); | ||
} | ||
|
||
/** | ||
* Fires primary | ||
* @param [message] | ||
*/ | ||
public firePrimary(message?:string): void { | ||
if (message == undefined) { | ||
message = "Primary: Something went right!"; | ||
} | ||
this.fireTimer(this.structure('primary', message )); | ||
} | ||
|
||
/** | ||
* Fires secondary | ||
* @param [message] | ||
*/ | ||
public fireSecondary(message?:string): void { | ||
if (message == undefined) { | ||
message = "Secondary: Something went right!"; | ||
} | ||
this.fireTimer(this.structure('secondary', message )); | ||
} | ||
|
||
/** | ||
* Fires timer | ||
* @param alert | ||
*/ | ||
private async fireTimer(alert: string): Promise<void> { | ||
let response = document.createElement('div'); | ||
response.innerHTML = alert; | ||
document.getElementsByTagName('footer')[0]?.appendChild(response); | ||
await this.sleep(5000); | ||
document.getElementsByTagName('footer')[0]?.removeChild(response) | ||
} | ||
|
||
//generate a sleep function | ||
private async sleep(ms: number) { | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export declare type TMode = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type TMode = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.