aboutsummaryrefslogtreecommitdiff
path: root/src/js/main.js
blob: 4444273b120b134bec6d657dd63bf1564e3857a9 (plain) (blame)
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
$(document).ready(function(){

    // Show profile link instead of login if user is logged in
    var email = $.cookie(BotleaguesFrontend.cookie_login_email);
    if (typeof email != 'undefined' && $.cookie(BotleaguesFrontend.cookie_login_valid_till) > (new Date()).getTime()) {
        setupLoginMenu(email);
    }
});

function setupLoginMenu(email) {
    $('#nav .login-link').remove();
    $('<li>').append(
        $('<a>')
            .attr('role', 'presentation')
            .attr('title', 'User profile')
            .attr('href', '/profile')
            .text(email))
        .appendTo($('#nav'));
    $('<li>').append(
        $('<a>')
            .attr('role', 'presentation')
            .attr('title', 'Logout')
            .attr('href', '/logout')
            .text('Logout'))
        .appendTo($('#nav'));
}