From 10de7241f22a10d65f53c891a8b07fe8650b4878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Pu=C5=A1nik?= Date: Tue, 29 Sep 2015 08:32:59 +0200 Subject: login removed from navbar --- js/codeq/language.js | 56 ++++++++++++++++---------------- js/codeq/login.js | 88 +++++++++++++++++++++++--------------------------- js/codeq/navigation.js | 4 --- js/codeq/problem.js | 2 -- js/codeq/prolog.js | 2 -- js/codeq/python.js | 2 -- 6 files changed, 68 insertions(+), 86 deletions(-) (limited to 'js/codeq') diff --git a/js/codeq/language.js b/js/codeq/language.js index be2a319..aac4e78 100644 --- a/js/codeq/language.js +++ b/js/codeq/language.js @@ -1,30 +1,28 @@ -/** - * Created by robert on 9/18/15. - */ - -(function(){ - var jqScreen = $('#screen_language'), - jqProlog = $('#choose-prolog'), - jqPython = $('#choose-python'), - chooseProlog = function () {codeq.globalStateMachine.transition('problem', 'prolog');}, - choosePython = function () {codeq.globalStateMachine.transition('problem', 'python');}; - - codeq.globalStateMachine.register('language',{ - 'enter': function(){ - $('#navigation-login').css('display', ''); - $("#navigation-language").addClass("active").css('display', ''); - - jqScreen.css('display', ''); - jqProlog.on('click', chooseProlog); - jqPython.on('click', choosePython); - }, - 'exit' : function(){ - jqProlog.off(); - jqPython.off(); - jqScreen.css('display', 'none'); - - $('#navigation-login').css('display', 'none'); - $('#navigation-language').css('display', 'none').removeClass("active"); - } - }); +/** + * Created by robert on 9/18/15. + */ + +(function(){ + var jqScreen = $('#screen_language'), + jqProlog = $('#choose-prolog'), + jqPython = $('#choose-python'), + chooseProlog = function () {codeq.globalStateMachine.transition('problem', 'prolog');}, + choosePython = function () {codeq.globalStateMachine.transition('problem', 'python');}; + + codeq.globalStateMachine.register('language',{ + 'enter': function(){ + $("#navigation-language").addClass("active").css('display', ''); + + jqScreen.css('display', ''); + jqProlog.on('click', chooseProlog); + jqPython.on('click', choosePython); + }, + 'exit' : function(){ + jqProlog.off(); + jqPython.off(); + jqScreen.css('display', 'none'); + + $('#navigation-language').css('display', 'none').removeClass("active"); + } + }); })(); \ No newline at end of file diff --git a/js/codeq/login.js b/js/codeq/login.js index bb92325..c400f06 100644 --- a/js/codeq/login.js +++ b/js/codeq/login.js @@ -1,48 +1,42 @@ -/** - * Created by robert on 9/17/15. - */ - -(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); - 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(){ - $("#submit").on('click', loginFun); - - $("#navigation-login").addClass("active"); - $('#navigation-login').css('display', ''); - - $("#screen_login").css('display', ''); - $('#disabled').css('display', 'none'); - }, - 'exit' : function(){ - $("#submit").off('click', loginFun); - $("#screen_login").css('display', 'none'); - $("#password").val(''); - - $('#navigation-login').css('display', 'none'); - $("#navigation-login").removeClass("active"); - } - }); +/** + * Created by robert on 9/17/15. + */ + +(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); + 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(){ + $("#submit").on('click', loginFun); + + $("#screen_login").css('display', ''); + $('#disabled').css('display', 'none'); + }, + 'exit' : function(){ + $("#submit").off('click', loginFun); + $("#screen_login").css('display', 'none'); + $("#password").val(''); + } + }); })(); \ No newline at end of file diff --git a/js/codeq/navigation.js b/js/codeq/navigation.js index 30503e0..1a7799f 100644 --- a/js/codeq/navigation.js +++ b/js/codeq/navigation.js @@ -81,10 +81,6 @@ //setup all the buttons in the banner - $('#navigation-login').on('click', function(e){ - codeq.globalStateMachine.transition('login'); - e.preventDefault();//prevent this since we'll trigger a page reload otherwise - }); $('#navigation-language').on('click', function(e){ codeq.globalStateMachine.transition('language'); e.preventDefault(); diff --git a/js/codeq/problem.js b/js/codeq/problem.js index 35b45af..464dc12 100644 --- a/js/codeq/problem.js +++ b/js/codeq/problem.js @@ -303,7 +303,6 @@ 'enter': function(language){ var data = null; // language data - $('#navigation-login').css('display', ''); $('#navigation-language').css('display', ''); $("#navigation-problem").addClass("active").css('display', ''); @@ -329,7 +328,6 @@ }, 'exit' : function(){ jqScreen.css('display', 'none'); - $('#navigation-login').css('display', 'none'); $('#navigation-language').css('display', 'none'); $('#navigation-problem').css('display', 'none').removeClass("active"); } diff --git a/js/codeq/prolog.js b/js/codeq/prolog.js index 980a60c..d827139 100644 --- a/js/codeq/prolog.js +++ b/js/codeq/prolog.js @@ -67,7 +67,6 @@ var prologHandler; //created when we enter the prolog state and destroyed once we leave it codeq.globalStateMachine.register('prolog', { 'enter': function (problemDef, commonHints, currentSolution) { - $('#navigation-login').css('display', ''); $('#navigation-language').css('display', ''); $('#navigation-problem').css('display', ''); $("#navigation-prolog").addClass("active"); @@ -99,7 +98,6 @@ subScreens = null; jqScreen.addClass('block1'); - $('#navigation-login').css('display', 'none'); $('#navigation-language').css('display', 'none'); $('#navigation-problem').css('display', 'none'); $("#navigation-prolog").removeClass("active"); diff --git a/js/codeq/python.js b/js/codeq/python.js index 009c4a5..cf2199a 100644 --- a/js/codeq/python.js +++ b/js/codeq/python.js @@ -72,7 +72,6 @@ var pythonHandler; //created when we enter the python state and destroyed once we leave it codeq.globalStateMachine.register('python', { 'enter': function (problemDef, commonHints, currentSolution) { - $('#navigation-login').css('display', ''); $('#navigation-language').css('display', ''); $('#navigation-problem').css('display', ''); $("#navigation-python").addClass("active"); @@ -109,7 +108,6 @@ subScreens = null; jqScreen.addClass('block1'); - $('#navigation-login').css('display', 'none'); $('#navigation-language').css('display', 'none'); $('#navigation-problem').css('display', 'none'); $("#navigation-python").removeClass("active"); -- cgit v1.2.1