/** * Javascript to do with the login screen * @author Tim Cooper & Daniel Dammann */ function logIntoDock() { $.ajax({ type: 'POST', url: '/main/ajax/log_into_dock.php', data: 'u_name=' + document.getElementById('u_name').value + '&p_word=' + document.getElementById('p_word').value + '&school=' + document.getElementById('school').value, timeout: 20000, success: function(arg_user_id) { if ( arg_user_id == 0 ) { displayErrorMessage('Sorry, username or password not
recognised. Please try again.'); } else { //alert('Logged in ok '+arg_user_id ); login(arg_user_id); } }, error: function(request, errorType, errorThrown) { // Output error alert('Unfortunately, your login details could not be checked. Please check your Internet connection and try logging into realsmart again. Should this keep happening even with a live Internet connection, please contact support@smartassess.com and quote: \n\n1. Error time: Fri, 03 Sep 10 00:31:36 +0000 \n2. Error type: ' + errorType + ' \n3. Error: ' + errorThrown + ' (should you see a yellow exclamation mark in the bottom left corner of your browser, please double-click it and also report us that error message) \n4. User id: 0 \n5. Web page: http://rlsmart.net/main/js/login_js.php'); } }); } function validateFormAndSubmit() { if (document.getElementById('u_name').value == '' && document.getElementById('p_word').value == '') { displayErrorMessage('You have missed filling in
your username & password.'); } else if (document.getElementById('u_name').value == '') { displayErrorMessage('You have missed filling in
your username.'); } else if (document.getElementById('p_word').value == '') { displayErrorMessage('You have missed filling in
your password.'); } else { displayLoginButton(); logIntoDock(); } return false; } function displayErrorMessage(argMsg) { document.getElementById('loginButtonAndErrorMessage').style.color = '#FFFFFF'; document.getElementById('loginButtonAndErrorMessage').innerHTML = '' + argMsg + ''; document.getElementById('openIdSentence').innerHTML = ''; } function displayLoginButton() { document.getElementById('loginButtonAndErrorMessage').innerHTML = ''; //document.getElementById('openIdSentence').innerHTML = 'Log in using an open id instead »»'; } // grabs a reference to the flash movie function thisMovie(movieName) { if (navigator.appName.indexOf("Microsoft") != -1) { return window[movieName]; } else { return document[movieName]; } } function writeErrorToPage(argWhatError) { document.write('
'); document.write('

 

'); document.write('

 

'); if (argWhatError == 'browser') { document.write(' browser error'); } else if (argWhatError == 'screen_resolution') { document.write(' screen resolution error'); } else if (argWhatError == 'cookies') { document.write(' cookies error'); } document.write('
'); } function writeFlashErrorToPage() { var flashMsg; flashMsg = '
'; flashMsg += '

 

'; flashMsg += '

 

'; flashMsg += ' '; flashMsg += ' flash error'; flashMsg += ' '; flashMsg += '
'; document.getElementById('divFlashContent').innerHTML = flashMsg; } function isUserHighTechEnough() { // Detect browser var br = new Array(4); br = getBrowser(); var brVersion = parseInt(getMajorVersion(br[1])); var isBrowserGood; if (br[0] == 'firefox' && brVersion >= 3){ isBrowserGood = true; } else if (br[0] == 'safari' && brVersion >= 530){ // Build version 522 is Safari 3 and build version 530 is Safari 4 // Build version 532 is Chrome 4.1 isBrowserGood = true; } else if (br[0] == 'msie' && brVersion >= 6){ isBrowserGood = true; } else { isBrowserGood = false; } // Detect cookies var tmpCookie = new Date(); chkCookie = (tmpCookie.getTime() + ''); document.cookie = "chkCookie=" + chkCookie; // Debugging //alert("

Browser '" + br[0] + "' version '" + getMajorVersion(br[1]) + "'

"); // Let em through ? if (isBrowserGood == false){ // Has browser ? writeErrorToPage('browser'); return false; } else if (screen.width < 800 || screen.height < 480){ // Has screen ? writeErrorToPage('screen_resolution'); return false; } else if (document.cookie.indexOf(chkCookie, 0) < 0) { // Has cookies ? writeErrorToPage('cookies'); return false; } else { return true; } } function login( userId ) { // begin the login process thisMovie('dock').login( userId ); showFlash(); } function showFlash() { // resize the flash content document.getElementById('htmlPage').style.display = 'none'; document.getElementById('divFlashContent').style.width = '100%'; document.getElementById('divFlashContent').style.height = '100%'; return false; } function userLoggedOutFromFlash() { // hide the flash content document.getElementById('divFlashContent').style.width = '10px'; document.getElementById('divFlashContent').style.height = '10px'; document.getElementById('htmlPage').style.display = 'block'; // make sure password removed from login form document.getElementById('u_name').value = ''; document.getElementById('p_word').value = ''; //document.getElementById('u_name').focus(); document.getElementById('u_name').style.background = 'url(/main/images/login/username_background.gif) no-repeat'; document.getElementById('p_word').style.background = 'url(/main/images/login/password_background.gif) no-repeat'; //alert('logged out'); return false; }