aboutsummaryrefslogtreecommitdiff
path: root/www/js/autologin.js
blob: cacf8dcc25095fb29f04672a822829f705d251d4 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
jQuery(function($) {
    document.getElementsByTagName("body")[0]
        .insertAdjacentHTML(
            'beforeend',
            '<iframe id="autologin" src="login.php?autologin=1"'
            + ' width="10" height="10" style="display: none"'
            + '></iframe>'
        );
    /*;
    $.ajax("../login.php?autologin=1")
        .done(function() {
            alert("success");
        })
        .fail(function() {
            alert("error");
        });
    */
});

function notifyAutologin(data)
{
    if (data.status != 'ok') {
        return;
    }
    document.getElementsByTagName("body")[0]
        .insertAdjacentHTML(
            'beforeend',
            '<div id="autologinnotifier" class="alert alert-success"'
            + ' style="display: none; position: fixed; top: 0px; left: 0px; width: 100%; text-align: center">'
            + 'Welcome, ' + data.name + '.'
            + ' You have been logged in - '
            + '<a href="' + document.location + '">reload</a> to see it.'
            + '</div>'
        );
    $('#autologinnotifier').click(function(event) {
        $(this).fadeOut();
    });
    $('#autologinnotifier').hide().fadeIn('slow');
}