mirror of
https://github.com/koel/koel
synced 2024-12-20 17:43:36 +00:00
26 lines
796 B
TypeScript
26 lines
796 B
TypeScript
import alertify from 'alertify.js'
|
|
|
|
type LogType = 'success' | 'error' | 'log'
|
|
|
|
const encodeEntities = (str: string) => str.replace(/&/g, '&')
|
|
.replace(/</g, '<')
|
|
.replace(/>/g, '>')
|
|
|
|
export const alerts = {
|
|
alert: (message: string) => alertify.alert(encodeEntities(message)),
|
|
confirm: (message: string, onOk: Closure, onCancel?: Closure) => alertify.confirm(message, onOk, onCancel),
|
|
|
|
log: (message: string, type: LogType, callback?: Closure) => {
|
|
alertify.logPosition('top right')
|
|
alertify.closeLogOnClick(true)
|
|
alertify[type](encodeEntities(message), callback)
|
|
},
|
|
|
|
success (message: string, callback?: Closure) {
|
|
this.log(message, 'success', callback)
|
|
},
|
|
|
|
error (message: string, callback?: Closure) {
|
|
this.log(message, 'error', callback)
|
|
}
|
|
}
|