summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Pušnik <marko.pusnik@guru.si>2015-09-30 19:08:10 +0200
committerMarko Pušnik <marko.pusnik@guru.si>2015-09-30 19:08:10 +0200
commitd198bfef31cb1fad78c5848ef052322dce0e873b (patch)
tree09c44c56b029c8f00acc783c8366ceed93205e9c
parent8bb68a1e979022ead00535c25403b341f2cb24bb (diff)
parent5ad56dfc6e8ababaa61c69265a30a95a7772e995 (diff)
Merge branch 'master' of ssh://212.235.189.51:22122/codeq-web
-rw-r--r--js/codeq/login.js66
1 files changed, 37 insertions, 29 deletions
diff --git a/js/codeq/login.js b/js/codeq/login.js
index 7844dc4..7db2c8c 100644
--- a/js/codeq/login.js
+++ b/js/codeq/login.js
@@ -4,40 +4,47 @@
(function(){
var loginFun = function(){
- $('#disabled').css('display', '');
- $('#disabled').css('cursor', 'wait');
- codeq.comms.connect()
- .then(function () {
- return codeq.comms.login($('#username').val(), $('#password').val());
- })
- .then(function (data) {
- $('#disabled').css('display', 'none');
- $('#disabled').css('cursor', '');
- if (data.code !== 0) throw new Error('Login failed, code: ' + data.code + ', message: ' + data.message);
+ $('#disabled').css('display', '');
+ $('#disabled').css('cursor', 'wait');
+ codeq.comms.connect()
+ .then(function () {
+ return codeq.comms.login($('#username').val(), $('#password').val());
+ })
+ .then(function (data) {
+ $('#disabled').css('display', 'none');
+ $('#disabled').css('cursor', '');
+ if (data.code !== 0) throw new Error('Login failed, code: ' + data.code + ', message: ' + data.message);
- //merge these settings into the already existing default settings
- var sett = data.settings;
- $.merge(true, codeq.settings, sett);
- if('lan' in sett && sett['lan'] in codeq.supportedLangs){
- codeq.setLang(sett['lan']);
- }
+ //merge these settings into the already existing default settings
+ var sett = data.settings;
+ $.merge(true, codeq.settings, sett);
+ if('lan' in sett && sett['lan'] in codeq.supportedLangs){
+ codeq.setLang(sett['lan']);
+ }
+
+ codeq.globalStateMachine.transition('language');
+ //codeq.activateState('language');
+ })
+ .fail(function (reason) {
+ $('#disabled').css('display', 'none');
+ $('#disabled').css('cursor', '');
+ codeq.log.error('Login failed: ' + reason, reason);
+ alert('Login request failed: ' + reason);
+ $('#disabled').css('display', 'none');
+ })
+ .done();
+ },
+ formInputs = $('#username').add('#password');
- codeq.globalStateMachine.transition('language');
- //codeq.activateState('language');
- })
- .fail(function (reason) {
- $('#disabled').css('display', 'none');
- $('#disabled').css('cursor', '');
- codeq.log.error('Login failed: ' + reason, reason);
- alert('Login request failed: ' + reason);
- $('#disabled').css('display', 'none');
- })
- .done();
- };
codeq.globalStateMachine.register('login',{
'enter': function(){
$('#signed-in-title').html('');
$("#submit").on('click', loginFun);
+ formInputs.on('keyup', function (ev) {
+ if ((ev.keyCode || ev.which) == 13) {
+ $('#submit').trigger('click');
+ }
+ });
$('#modalLogIn').modal();
$("#screen_login").css('display', '');
@@ -45,9 +52,10 @@
},
'exit' : function(){
$("#submit").off('click', loginFun);
+ formInputs.off('keyup');
$("#screen_login").css('display', 'none');
$('#signed-in-title').html('Signed in as '+$('#username').val());
$("#password").val('');
}
});
-})(); \ No newline at end of file
+})();