webapi-eca/webpages/handlers/js/admin.js
2014-04-21 14:42:26 +02:00

46 lines
1.4 KiB
JavaScript

// Generated by CoffeeScript 1.7.1
(function() {
var fOnLoad;
fOnLoad = function() {
document.title = 'Administrate';
$('#pagetitle').text('Hi {{{user.username}}}, issue your commands please:');
if (!window.CryptoJS) {
$('#info').attr('class', 'error');
$('#info').text('CryptoJS library missing! Are you connected to the internet?');
}
$('#but_submit').click(function() {
var data;
data = {
command: $('#inp_command').val()
};
return $.post('admincommand', data).done(function(data) {
$('#info').text(data.message);
return $('#info').attr('class', 'success');
}).fail(function(err) {
var fDelayed;
fDelayed = function() {
if (err.responseText === '') {
err.responseText = 'No Response from Server!';
}
$('#info').text('Error: ' + err.responseText);
$('#info').attr('class', 'error');
if (err.status === 401) {
return window.location.href = 'admin';
}
};
return setTimeout(fDelayed, 500);
});
});
return $('#inp_password').keyup(function() {
var hp;
hp = CryptoJS.SHA3($(this).val(), {
outputLength: 512
});
return $('#display_hash').text(hp.toString());
});
};
window.addEventListener('load', fOnLoad, true);
}).call(this);