Fix autologin in phar files and subdir installs
[phorkie.git] / www / js / autologin.js
1 jQuery(function($) {
2     document.getElementsByTagName("body")[0]
3         .insertAdjacentHTML(
4             'beforeend',
5             '<iframe id="autologin" src="login.php?autologin=1"'
6             + ' width="10" height="10" style="display: none"'
7             + '></iframe>'
8         );
9     /*;
10     $.ajax("../login.php?autologin=1")
11         .done(function() {
12             alert("success");
13         })
14         .fail(function() {
15             alert("error");
16         });
17     */
18 });
19
20 function notifyAutologin(data)
21 {
22     if (data.status != 'ok') {
23         return;
24     }
25     document.getElementsByTagName("body")[0]
26         .insertAdjacentHTML(
27             'beforeend',
28             '<div id="autologinnotifier" class="alert alert-success"'
29             + ' style="display: none; position: fixed; top: 0px; left: 0px; width: 100%; text-align: center">'
30             + 'Welcome, ' + data.name + '.'
31             + ' You have been logged in - '
32             + '<a href="#" onclick="document.location.reload();">reload</a> to see it.'
33             + '</div>'
34         );
35     $('#autologinnotifier').click(function(event) {
36         $(this).fadeOut();
37     });
38     $('#autologinnotifier').hide().fadeIn('slow');
39 }