]>
Commit | Line | Data |
---|---|---|
7093e9ba MG |
1 | $(function(){ |
2 | var sidebar = $('#sidebar')[0]; | |
3 | var login = document.createElement('div'); | |
4 | login.innerHTML = '<a role="button" id="login" class="show">Log in</a>'; | |
5 | sidebar.insertBefore(login, sidebar.firstChild); | |
8345760a | 6 | $('#login').on('click', e => { |
7093e9ba MG |
7 | var xhr = new XMLHttpRequest(); |
8 | xhr.open('GET', '/login'); | |
8345760a | 9 | xhr.onload = () => { |
7093e9ba MG |
10 | if(this.status != 200) |
11 | return; | |
12 | var username = this.responseText; | |
13 | sessionStorage.setItem('login_username', username); | |
14 | start_tracking(username); | |
15 | login.innerHTML = 'Probably logged in as ' + username; | |
16 | } | |
17 | xhr.send(); | |
18 | return false; | |
462db4aa | 19 | }); |
7093e9ba MG |
20 | |
21 | var username = sessionStorage.getItem('login_username'); | |
22 | if(username) | |
23 | login.innerHTML = 'Probably logged in as ' + username; | |
24 | }); |