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

  fOnLoad = function() {
    document.title = 'Login';
    $('#pagetitle').text('Login!');
    if (!window.CryptoJS) {
      $('#info').text('CryptoJS library missing! Are you connected to the internet?');
    }
    return $('#but_submit').click(function() {
      var data, hp;
      hp = CryptoJS.SHA3($('#password').val(), {
        outputLength: 512
      });
      data = {
        username: $('#username').val(),
        password: hp.toString()
      };
      return $.post('/login', JSON.stringify(data)).done(function(data) {
        return window.location.href = document.URL;
      }).fail(function(err) {
        return alert('Authentication not successful!');
      });
    });
  };

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

}).call(this);
