2013-05-29 12:17:44 -04:00
|
|
|
(function() {
|
|
|
|
|
// Alternate Logins
|
|
|
|
|
var altLoginEl = document.querySelector('.alt-logins');
|
|
|
|
|
altLoginEl.addEventListener('click', function(e) {
|
2013-05-29 14:55:43 -04:00
|
|
|
var target;
|
2013-09-17 13:05:54 -04:00
|
|
|
switch (e.target.nodeName) {
|
|
|
|
|
case 'LI':
|
|
|
|
|
target = e.target;
|
|
|
|
|
break;
|
|
|
|
|
case 'I':
|
|
|
|
|
target = e.target.parentNode;
|
|
|
|
|
break;
|
2013-05-29 14:55:43 -04:00
|
|
|
}
|
|
|
|
|
if (target) {
|
|
|
|
|
document.location.href = target.getAttribute('data-url');
|
2013-05-29 12:17:44 -04:00
|
|
|
}
|
2013-08-23 14:30:58 -04:00
|
|
|
});
|
|
|
|
|
|
2013-06-25 20:55:02 -04:00
|
|
|
$('#login').on('click', function() {
|
|
|
|
|
var loginData = {
|
|
|
|
|
'username': $('#username').val(),
|
|
|
|
|
'password': $('#password').val(),
|
|
|
|
|
'_csrf': $('#csrf-token').val()
|
|
|
|
|
};
|
2013-08-23 14:30:58 -04:00
|
|
|
|
2013-06-25 20:55:02 -04:00
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
2013-07-10 21:31:58 -04:00
|
|
|
url: RELATIVE_PATH + '/login',
|
2013-06-25 20:55:02 -04:00
|
|
|
data: loginData,
|
|
|
|
|
success: function(data, textStatus, jqXHR) {
|
2013-09-17 13:05:54 -04:00
|
|
|
if (!data.success) {
|
2013-08-28 17:22:48 -04:00
|
|
|
$('#login-error-notify').show();
|
2013-08-14 15:49:56 -04:00
|
|
|
} else {
|
|
|
|
|
$('#login-error-notify').hide();
|
2013-09-24 14:56:51 -04:00
|
|
|
//window.location.replace(RELATIVE_PATH + "/?loggedin");
|
|
|
|
|
history.go(-1);
|
|
|
|
|
//setTimeout(function(){
|
|
|
|
|
app.loadConfig();
|
|
|
|
|
//}, 500);
|
|
|
|
|
//socket.emit('api:updateHeader');
|
2013-08-14 15:49:56 -04:00
|
|
|
}
|
2013-06-25 20:55:02 -04:00
|
|
|
},
|
2013-09-17 13:05:54 -04:00
|
|
|
error: function(data, textStatus, jqXHR) {
|
2013-08-14 15:49:56 -04:00
|
|
|
$('#login-error-notify').show();
|
2013-06-25 20:55:02 -04:00
|
|
|
},
|
2013-06-26 13:18:19 -04:00
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
timeout: 2000
|
2013-06-25 20:55:02 -04:00
|
|
|
});
|
2013-06-26 13:18:19 -04:00
|
|
|
|
2013-06-25 20:55:02 -04:00
|
|
|
return false;
|
|
|
|
|
});
|
2013-08-23 14:30:58 -04:00
|
|
|
|
2013-08-28 17:22:48 -04:00
|
|
|
$('#login-error-notify button').on('click', function() {
|
|
|
|
|
$('#login-error-notify').hide();
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
2013-08-23 14:30:58 -04:00
|
|
|
document.querySelector('#content input').focus();
|
2013-09-17 13:05:54 -04:00
|
|
|
}());
|