=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-08-16 14:47:08 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-08-16 15:08:00 +0000 @@ -204,54 +204,6 @@ return false; } -function ajax_login() { - $("#login_button").bind("click", function() { - var username = prompt("Please enter username"); - var password = prompt("Please enter password"); - - $.post("../dhis-web-commons-security/login.action", { - "j_username": username, - "j_password": password - }).success(function() { - alert("login attempt successful, TODO check if login was successful with checkAvailability"); - }) - }) -} - -$(document).ready(function() { - dhis2.availability.startAvailabilityCheck(); - - $("#orgUnitTree").one("ouwtLoaded", function() { - saveDataValuesInLocalStorage(); - }); - - $(document).bind("dhis2.online", function(event, loggedIn) { - if(loggedIn) { - if(isHeaderMessageVisible()) { - updateHeaderMessage( "Successful connection with server." ) - } else { - setHeaderMessage( "Successful connection with server." ) - } - } else { - if(isHeaderMessageVisible()) { - updateHeaderMessage( "Successfully connected with server. Please " ) - ajax_login(); - } else { - setHeaderMessage( "Successfully connected with server. Please " ) - ajax_login(); - } - } - }) - - $(document).bind("dhis2.offline", function() { - if(isHeaderMessageVisible()) { - updateHeaderMessage( "Unable to contact server. Data will be stored locally." ) - } else { - setHeaderMessage( "Unable to contact server. Data will be stored locally." ) - } - }) -}) - function saveDataValuesInLocalStorage() { var dataValues = storageManager.getAllDataValues(); === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2011-08-16 13:40:15 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2011-08-16 15:08:00 +0000 @@ -53,12 +53,56 @@ $( document ).ready( function() { selection.setListenerFunction( organisationUnitSelected ); - - $( '#orgUnitTree' ).bind( 'ouwtLoaded', function() { + + $( '#orgUnitTree' ).one( 'ouwtLoaded', function() { setTimeout( "updateForms();", 1500 ); // TODO improve + saveDataValuesInLocalStorage(); } ); + + $(document).bind("dhis2.online", function(event, loggedIn) { + if(loggedIn) { + if(isHeaderMessageVisible()) { + updateHeaderMessage( "Successful connection with server." ) + } else { + setHeaderMessage( "Successful connection with server." ) + } + } else { + if(isHeaderMessageVisible()) { + updateHeaderMessage( "Successfully connected with server. Please " ) + ajax_login(); + } else { + setHeaderMessage( "Successfully connected with server. Please " ) + ajax_login(); + } + } + }) + + + $(document).bind("dhis2.offline", function() { + if(isHeaderMessageVisible()) { + updateHeaderMessage( "Unable to contact server. Data will be stored locally." ) + } else { + setHeaderMessage( "Unable to contact server. Data will be stored locally." ) + } + }) + + dhis2.availability.startAvailabilityCheck(); } ); +function ajax_login() { + $("#login_button").bind("click", function() { + var username = prompt("Please enter username"); + var password = prompt("Please enter password"); + + $.post("../dhis-web-commons-security/login.action", { + "j_username": username, + "j_password": password + }).success(function() { + alert("login attempt successful, TODO check if login was successful with checkAvailability"); + }) + }) +} + function addEventListeners() { $( '[name="ef"]' ).each( function( i )