summaryrefslogtreecommitdiff
path: root/js/codeq
diff options
context:
space:
mode:
Diffstat (limited to 'js/codeq')
-rw-r--r--js/codeq/core.js4
-rw-r--r--js/codeq/init.js8
-rw-r--r--js/codeq/login.js24
-rw-r--r--js/codeq/misc.js71
-rw-r--r--js/codeq/profile.js16
5 files changed, 104 insertions, 19 deletions
diff --git a/js/codeq/core.js b/js/codeq/core.js
index a3e9589..309195b 100644
--- a/js/codeq/core.js
+++ b/js/codeq/core.js
@@ -391,6 +391,10 @@
'line-layout',
'square-layout'
],
+
+ 'runningOnPhone': false, // default value, will be changed if detected otherwise
+ 'browserType': 'unknown',
+ 'platformType': 'unknown',
'isWebApp': false, // this is a PhoneGap/Cordova build, will be overridden in cordova.js for webapp
'setLayout': function(newLayout){
diff --git a/js/codeq/init.js b/js/codeq/init.js
index 811d781..98a41a2 100644
--- a/js/codeq/init.js
+++ b/js/codeq/init.js
@@ -94,8 +94,12 @@
else {
// we are a phonegap native app
document.addEventListener("deviceready", Boot, false);
- codeq.ajaxPrefix = 'http://codeq.si/';
- codeq.eioHost= 'wss://codeq.si';
+ // production
+ //codeq.ajaxPrefix = 'http://codeq.si/';
+ //codeq.eioHost= 'ws://codeq.si';
+ // dev
+ codeq.ajaxPrefix = 'http://212.235.189.51:22180/';
+ codeq.eioHost= 'ws://212.235.189.51:22180';
}
})();
diff --git a/js/codeq/login.js b/js/codeq/login.js
index 61f248d..db90b43 100644
--- a/js/codeq/login.js
+++ b/js/codeq/login.js
@@ -7,19 +7,21 @@
jqNavigationHomeBtn = $('#navigation-home'),
jqAAILoginBtn = $('#aai_login_button'),
jqSignupBtn = $('#signup_button'),
- jqSubmitLoginBtn = $("#submit");
+ jqSubmitLoginBtn = $("#submit"),
+ jqDisabled = $('#disabled');
//the loginCallbackFunction is used here and in the AAI login as well
codeq.loginCallbackFunction = function (data) {
- $('#disabled').css('display', 'none');
- $('#disabled').css('cursor', '');
+ jqDisabled.css('display', 'none');
+ jqDisabled.css('cursor', '');
if (data.code !== 0) throw new Error('Login failed, code: ' + data.code + ', message: ' + data.message);
//nav signed in...
- $('#signed-in-title').html(data.name||$('#username').val());
+ $('#signed-in-title').html(data.name||data.username||data.email||'undefined');
//merge with profile page
- $('#profileUsername').html($('#username').val());
+ $('#profileUsername').html(data.username||data.email||'undefined');
$('#profileName').html(data.name||'undefined');
+ $('#profileEmail').html(data.email||'undefined');
$('#profileJoined').html(new Date(data.joined).toLocaleString());
$('#profileLastLogin').html(new Date(data["last-login"]).toLocaleString());
@@ -42,19 +44,19 @@
var loginFun = function(){
$('.saml-login-hide').css('display','');//if we login the normal way we want to show the change password buttons. if we enter the saml login they will be hidden
- $('#disabled').css('display', '');
- $('#disabled').css('cursor', 'wait');
+ jqDisabled.css('display', '');
+ jqDisabled.css('cursor', 'wait');
codeq.comms.connect()
.then(function () {
return codeq.comms.login($('#username').val(), $('#password').val());
})
.then(codeq.loginCallbackFunction)
.fail(function (reason) {
- $('#disabled').css('display', 'none');
- $('#disabled').css('cursor', '');
+ jqDisabled.css('display', 'none');
+ jqDisabled.css('cursor', '');
codeq.log.error('Login failed: ' + reason, reason);
alert('Login request failed: ' + reason);
- $('#disabled').css('display', 'none');
+ jqDisabled.css('display', 'none');
})
.done();
},
@@ -85,7 +87,7 @@
});
//$('#modalLogIn').modal();
$("#screen_login").css('display', '');
- $('#disabled').css('display', 'none');
+ jqDisabled.css('display', 'none');
},
'exit' : function(){
//remove the listener from the buttons specific to this page
diff --git a/js/codeq/misc.js b/js/codeq/misc.js
new file mode 100644
index 0000000..b83f271
--- /dev/null
+++ b/js/codeq/misc.js
@@ -0,0 +1,71 @@
+/* Detect if we're on a phone, browser and platform type */
+(function browserDetection() {
+ var platform = navigator.platform,
+ userAgent = navigator.userAgent,
+ runningOnPhone = false, // default value, will be changed if detected otherwise
+ browserType = 'unknown',
+ platformType = 'unknown';
+
+ // Apple platforms
+ if ((/iPod/.test(platform)) || (/iPhone/.test(platform))) {
+ runningOnPhone = true;
+ browserType = 'safari';
+ platformType = 'iapple';
+ }
+ else if (/iPad/.test(platform)) {
+ runningOnPhone = false;
+ browserType = 'safari';
+ platformType = 'iapple';
+ }
+ else {
+ // general test for phones
+ if (/[Mm]obile/.test(userAgent)) {
+ runningOnPhone = true;
+ }
+
+ if ((/MSIE/.test(userAgent) && /Touch/.test(userAgent)) || (/IEMobile/.test(userAgent))) {
+ platformType = 'ietouch';
+ }
+
+ if (/BlackBerry/.test(userAgent) || /BB10/.test(userAgent)) {
+ platformType = 'blackberry';
+ }
+
+ // general browser tests
+ if (/Presto/.test(userAgent)) {
+ browserType = 'opera';
+ }
+ else if (/Android/.test(userAgent)) {
+ // Android platform: only firefox, webkit, and chrome are possible
+ platformType = 'android';
+ if (/Chrome/.test(userAgent)) {
+ browserType = 'chrome';
+ }
+ else if (/Firefox/.test(userAgent)) {
+ browserType = 'firefox';
+ }
+ else if (/Safari/.test(userAgent)) {
+ browserType = 'webkit';
+ }
+ }
+ else {
+ // desktop, or other mobile platforms
+ if (/Chrome/.test(userAgent)) {
+ browserType = 'chrome';
+ }
+ else if (/Firefox/.test(userAgent)) {
+ browserType = 'firefox';
+ }
+ else if (/Safari/.test(userAgent)) {
+ browserType = 'webkit';
+ }
+ else if (/MSIE/.test(userAgent)) {
+ browserType = 'ie';
+ }
+ }
+ }
+
+ codeq.runningOnPhone = runningOnPhone;
+ codeq.browserType = browserType;
+ codeq.platformType = platformType;
+})(); \ No newline at end of file
diff --git a/js/codeq/profile.js b/js/codeq/profile.js
index 133c947..36c5ccf 100644
--- a/js/codeq/profile.js
+++ b/js/codeq/profile.js
@@ -4,13 +4,20 @@
(function(){
- var jqBtnChangePass = $("#change_pass_profile");
+ var jqBtnChangePass = $("#change_pass_profile"),
+ jqBtnGoBack = $("#btnProfileGoBack");
codeq.profile = {
};
codeq.globalStateMachine.register('profile',{
'enter': function(){
+ jqBtnChangePass.on('click',function(){
+ codeq.globalStateMachine.transition('changePassword');
+ });
+ jqBtnGoBack.on('click',function(){
+ history.back();//forces a transition to the previous state
+ });
$("#screen_profile").css('display', '');
$('#disabled').css('display', 'none');
codeq.comms.getUserStat()
@@ -19,7 +26,6 @@
data = data.stat;
var columns = ['language', 'problem_group', 'problems_count', 'done', 'in_progress'],
- labels = ['Language', 'Problem group', 'All', 'Done', 'In progress'],
items='<thead><tr>',
tr_gui = codeq.tr.getDictionary('gui');
@@ -53,13 +59,11 @@
alert('GetUserStat failed: ' + reason);
})
.done();
- jqBtnChangePass.on('click',function(){
- codeq.globalStateMachine.transition('changePassword');
- });
},
'exit' : function(){
- $("#screen_profile").css('display', 'none');
jqBtnChangePass.off('click');
+ jqBtnGoBack.off('click');
+ $("#screen_profile").css('display', 'none');
}
});
})(); \ No newline at end of file