chore: clean up alerts

This commit is contained in:
Phan An 2022-05-14 17:54:26 +02:00
parent 6f0d6e8abc
commit 2acd1c2317
No known key found for this signature in database
GPG key ID: A81E4477F0BB6FDC

View file

@ -7,23 +7,20 @@ const encodeEntities = (str: string) => str.replace(/&/g, '&')
.replace(/>/g, '>') .replace(/>/g, '>')
export const alerts = { export const alerts = {
alert: (msg: string) => alertify.alert(encodeEntities(msg)), alert: (message: string) => alertify.alert(encodeEntities(message)),
confirm: (message: string, onOk: Closure, onCancel?: Closure) => alertify.confirm(message, onOk, onCancel),
confirm: (msg: string, okFunc: Closure, cancelFunc?: Closure) => { log: (message: string, type: LogType, callback?: Closure) => {
alertify.confirm(msg, okFunc, cancelFunc)
},
log: (msg: string, type: LogType = 'log', cb?: Closure) => {
alertify.logPosition('top right') alertify.logPosition('top right')
alertify.closeLogOnClick(true) alertify.closeLogOnClick(true)
alertify[type](encodeEntities(msg), cb) alertify[type](encodeEntities(message), callback)
}, },
success (msg: string, cb?: Closure) { success (message: string, callback?: Closure) {
this.log(msg, 'success', cb) this.log(message, 'success', callback)
}, },
error (msg: string, cb?: Closure) { error (message: string, callback?: Closure) {
this.log(msg, 'error', cb) this.log(message, 'error', callback)
} }
} }