--- /dev/null
+(function(){
+ 'use strict';
+
+ $( document ).ready(function(){
+ $('#login').detach().prependTo($('#sidebar')).removeClass('hidden');
+
+ document.cookie = "cookietest=1";
+ var cookie = document.cookie.indexOf("cookietest=") != -1;
+ document.cookie = "cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT";
+
+ if(!cookie) return;
+ var username = document.cookie.replace(/(?:(?:^|.*;\s*)username\s*\=\s*([^;]*).*$)|^.*$/, "$1");
+ if(username) {
+ sessionStorage.setItem('login_username', username);
+ document.cookie = "username=; expires=Thu, 01-Jan-1970 00:00:01 GMT";
+ start_tracking(username);
+ }
+ username = sessionStorage.getItem('login_username');
+ if(username)
+ $('#login').replaceWith('<span id="login">Probably logged in as ' + username + '</span>');
+ });
+})();
}, 10
},
+ sub (/login) {
+ forbid !remote_user;
+
+ [204, ['Set-Cookie' => "username=".remote_user->id], []]
+ },
+
sub (/ct/:contest/log/st) { redirect "/st/$_{contest}" },
sub (/us/) { response us => 'Users', {us => db->user_list} },
<div id="content">Content goes here</div>
+<a href="/login" id="login" class="hidden">Log in</a>
+
<div id="tracker" class="hidden">
<h1>Track user</h1>
<div id="tracker_form">