]>
Commit | Line | Data |
---|---|---|
7093e9ba | 1 | $(function(){ |
dee46c5b | 2 | const sidebar = q('#sidebar'); |
65d5cb3b | 3 | const login = document.createElement('div'); |
7093e9ba MG |
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 => { |
65d5cb3b | 7 | const xhr = new XMLHttpRequest(); |
7093e9ba | 8 | xhr.open('GET', '/login'); |
8345760a | 9 | xhr.onload = () => { |
8e3f7d1e | 10 | if(xhr.status != 200) |
7093e9ba | 11 | return; |
65d5cb3b | 12 | const username = xhr.responseText; |
7093e9ba MG |
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 | 20 | |
65d5cb3b | 21 | const username = sessionStorage.getItem('login_username'); |
7093e9ba MG |
22 | if(username) |
23 | login.innerHTML = 'Probably logged in as ' + username; | |
24 | }); |