]> iEval git - gruntmaster-page.git/blob - js/95-login.js
aad77d370682a1ad5b47eef8a9ec7f80f59197d0
[gruntmaster-page.git] / js / 95-login.js
1 $(function(){
2 const sidebar = $('#sidebar')[0];
3 const login = document.createElement('div');
4 login.innerHTML = '<a role="button" id="login" class="show">Log in</a>';
5 sidebar.insertBefore(login, sidebar.firstChild);
6 $('#login').on('click', e => {
7 const xhr = new XMLHttpRequest();
8 xhr.open('GET', '/login');
9 xhr.onload = () => {
10 if(xhr.status != 200)
11 return;
12 const username = xhr.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;
19 });
20
21 const username = sessionStorage.getItem('login_username');
22 if(username)
23 login.innerHTML = 'Probably logged in as ' + username;
24 });
This page took 0.046271 seconds and 4 git commands to generate.