aboutsummaryrefslogtreecommitdiff
path: root/src/js/main.js
blob: 1f869c4065dd338d50032d34fdb5ef6beff97df1 (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
27
28
29
30
$(document).ready(function(){

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

function setupLoginMenu() {
    $('#nav .login-link').remove();
    
    if ($('#nav').find('[href="/profile"]').length == 0) {
        $('<li>').append(
            $('<a>')
                .attr('role', 'presentation')
                .attr('title', 'User profile')
                .attr('href', '/profile')
                .text('Profile'))
            .appendTo($('#nav'));
    }
    
    $('<li>').append(
        $('<a>')
            .attr('role', 'presentation')
            .attr('title', 'Logout')
            .attr('href', '/logout')
            .text('Logout'))
        .appendTo($('#nav'));
}