-
Notifications
You must be signed in to change notification settings - Fork 3
/
utils.js
38 lines (32 loc) · 1.12 KB
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Utils {
static messagesToShow
static timerActive = null
// One-time initialization
static {
Utils.messagesToShow = []
}
static showMiniWarning( text, timeout) {
if ( text ) {
Utils.messagesToShow.push({text: text, timeout: timeout})
}
if ( !Utils.timerActive ) {
let curMessage = Utils.messagesToShow.pop();
document.getElementById('warning-message').innerHTML = curMessage.text
document.getElementById('warning-message').style.display = 'unset'
if ( curMessage.timeout ) {
Utils.timerActive = setTimeout ( () => {
Utils.timerActive = null
Utils.hideMiniWarning()
if ( Utils.messagesToShow.length > 0 ) {
Utils.showMiniWarning()
}
}, timeout);
}
}
}
static hideMiniWarning() {
document.getElementById('warning-message').innerHTML = ''
document.getElementById('warning-message').style.display = 'none'
}
}
module.exports = Utils;