// Generated by CoffeeScript 1.7.1
(function() {
  var fOnLoad;

  fOnLoad = function() {
    document.title = 'Administrate';
    $('#pagetitle').text('Hi {{{user.username}}}, issue your commands please:');
    return $('#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);
      });
    });
  };

  window.addEventListener('load', fOnLoad, true);

}).call(this);
