← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4320: moved pageinit stuff from form.js to entry.js

 

------------------------------------------------------------
revno: 4320
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-08-16 17:08:00 +0200
message:
  moved pageinit stuff from form.js to entry.js
modified:
  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/form.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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 <button id='login_button'>Login</button> " )
-                ajax_login();
-            } else {
-                setHeaderMessage( "Successfully connected with server. Please <button id='login_button'>Login</button> " )
-                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 <button id='login_button'>Login</button> " )
+                ajax_login();
+            } else {
+                setHeaderMessage( "Successfully connected with server. Please <button id='login_button'>Login</button> " )
+                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 )