summaryrefslogtreecommitdiff
path: root/Statics/Js/message.js
blob: fa8e6751f00bc6450a5ca9b1ae69d730251ee168 (plain)
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

// ****************************************************************************
// MESSAGES
// ****************************************************************************

// Redirection
function redirect(page) {
    window.location.href = `/${page}.php`;
}

// Timer pour message
function start_timer(page) {
    // var -> global, let -> local{}
    let seconds = 1;
    let text = document.getElementById("redirect").innerHTML;
    setInterval(() => {
        if (seconds > 0) {
            document.getElementById("redirect").innerHTML = `${text} ${seconds} .`;
            seconds --;
        } else {
            document.getElementById("redirect").innerHTML = `${text} ${seconds} .`;
            redirect(page);
        }
    },
    1000);
}