var authNS = odkmaker.namespace.load('odkmaker.auth'); var signinBtnClick = function(submitform){ if(jQuery.trim($('.secure-login #SZUsername').val()) == ''){ $('.secure-login .errorMessage') .empty() .append('

' + lbl_input_email + '

') .slideDown(); return; } if(jQuery.trim($('.secure-login #SZPassword').val()) == ''){ $('.secure-login .errorMessage') .empty() .append('

' + lbl_input_pass + '

') .slideDown(); return; } $('.secure-login .errorMessage').slideUp(); $('.secure-login .signin_section #signin_username').val($('.secure-login #SZUsername').val()); $('.secure-login .signin_section #signin_password').val($('.secure-login #SZPassword').val()); waitForDataLoadingWithMsg(true, ''); $.ajax({ url: '/user/login', dataType: 'json', type: 'POST', data: $('.secure-login .signin_section').find(':input'), cache: false, complete: function() { waitForDataLoadingWithMsg(false, ''); }, success: function(response, status) { waitForDataLoadingWithMsg(false, ''); if (submitform) { submitform.submit(); } else { redirectPage(); } }, error: function(request, status, error) { waitForDataLoadingWithMsg(false, ''); if(getStatus(request) == 901){ $('.secure-login .errorMessage') .empty() .append('

' + lbl_account_not_found + '

') .slideDown(); }else if(getStatus(request) == 906 || getStatus(request) == 908){ $('.secure-login .errorMessage') .empty() .append('

' + lbl_invalid_email_pass + '

') .slideDown(); }else if(getStatus(request) == CONST_ERROR_CODE_TOO_MANY_FAILED_LOGIN){ $('.secure-login .errorMessage') .empty() .append('

' + lbl_too_many_failed_login + '

') .slideDown(); }else if(getStatus(request) == 907){ $('.secure-login .errorMessage') .empty() .append('

' + lbl_enter_acc + '

') .slideDown(); }else if(getStatus(request) == 917){ $('.secure-login .errorMessage') .empty() .append('

' + lbl_acc_not_active + '

') .slideDown(); }else{ $('.secure-login .errorMessage') .empty() .append('

' + lbl_could_not_login + '

') .slideDown(); } } }); } var signOut = function() { waitForDataLoadingWithMsg(true, ''); $.ajax({ url: '/user/logout', cache: false, complete: function() { waitForDataLoadingWithMsg(false, ''); window.location.replace("http://www.doforms.com/LogOutProcess.aspx"); }, success: function(response, status) { waitForDataLoadingWithMsg(false, ''); authNS.currentUser = null; noAuthMessage(); }, error: function(request, status, error) { waitForDataLoadingWithMsg(false, ''); authNS.currentUser = null; noAuthMessage(); } }); }; var signinSuccessful = function(response, status) { $('.whoslogged') .empty() .append(authNS.currentUser.FirstName + ' ' + authNS.currentUser.LastName + ' ' + lbl_logged_in + '' + lbl_log_out + '') .fadeIn('slow' ); }; authNS.verify = function(callback) { /*waitForDataLoadingWithMsg(true, ''); // Get current user status from server $.ajax({ url: '/user/user', dataType: 'json', type: 'GET', data: '{}', cache: false, complete: function() { waitForDataLoadingWithMsg(false, ''); setTimeout(function() { $('.loadingScreen') .fadeOut('normal', function() { $(this).remove(); }); $('.preloadImages').remove(); }, 200); // give a bit of extra time in case the load was instantaneous changeTitle(); }, success: function(response, status) { waitForDataLoadingWithMsg(false, ''); authNS.currentUser = response; initBC(); (callback || signinSuccessful)(response, status); }, error: function(request, status, error) { waitForDataLoadingWithMsg(false, ''); authNS.currentUser = null; noAuthMessage(); } });*/ }; var changeTitle = function() { $('title').text($('#signup_title').text()); } var initBC = function() { $('#FirstName').val(authNS.currentUser.FirstName); $('#LastName').val(authNS.currentUser.LastName); $('#EmailAddress').val(authNS.currentUser.Email); }; var noAuthMessage = function() { $('.whoslogged') .empty() .append('No one logged in.') .fadeIn('slow'); }; var initscreen = function() { authNS.verify(); if(window.location.protocol == 'https:') { $('head meta#upgrade_alert').remove(); } }