← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4180: Ajax Request stuff don't work does not work with IE9 ( Patient module ).

 

------------------------------------------------------------
revno: 4180
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-07-21 14:54:54 +0700
message:
  Ajax Request stuff don't work does not work with IE9 ( Patient module ).
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.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-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2011-07-21 07:18:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2011-07-21 07:54:54 +0000
@@ -397,7 +397,7 @@
 no_of_char = Number of characters
 letter = Letter
 date_of_incident_invalid = Date of Enrollment should be greater and equals to Date of incident
-no_max_days_allowed_input_data = Number of max days allowed to input data
+no_max_days_allowed_input_data = Maximum number of days allowed to input data
 program_attribute = Program Attribute
 program_attribute_management = Program Attribute Management
 add_new_program_attribute = Add New Program Attribute

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js	2011-07-07 08:40:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js	2011-07-21 07:54:54 +0000
@@ -29,6 +29,7 @@
 // -----------------------------------------------------------------------------
 // Create validation for dataelements into program-stages
 // -----------------------------------------------------------------------------
+
 var dataelementId;
 function getDataElementsFromStage(stageId, dataelementId){
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js	2011-06-02 02:34:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js	2011-07-21 07:54:54 +0000
@@ -18,8 +18,6 @@
 	}
 }
 
-
-
 function showSortProgramStage()
 {
 	var programId = document.getElementById('id').value;
@@ -40,10 +38,12 @@
 
 function showProgramStageDetails( programStageId )
 {
-    var request = new Request();
-    request.setResponseTypeXML( 'programStage' );
-    request.setCallbackSuccess( programStageReceived );
-    request.send( 'getProgramStage.action?id=' + programStageId );
+	$.ajax({
+		url: 'getProgramStage.action?id=' + programStageId,
+		cache: false,
+		dataType: "xml",
+		success: programStageReceived
+	});
 }
 
 function programStageReceived( programStageElement )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js	2011-07-08 05:52:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js	2011-07-21 07:54:54 +0000
@@ -11,19 +11,21 @@
 
 function showProgramValidationDetails ( programValidationId )
 {
-    var request = new Request();
-    request.setResponseTypeXML( 'programValdiation' );
-    request.setCallbackSuccess( programValdiationReceived );
-    request.send( 'getProgramValidation.action?validationId=' + programValidationId );
+    $.ajax({
+		url: 'getProgramValidation.action?validationId=' + programValidationId,
+		cache: false,
+		dataType: "xml",
+		success: programValdiationReceived
+	});
 }
 
 function programValdiationReceived( programValidationElement )
 {
-	setInnerHTML( 'idField', getElementValue( programValidationElement, 'id' ) );
-	setInnerHTML( 'descriptionField', getElementValue( programValidationElement, 'description' ) );	
-    setInnerHTML( 'leftSideField', getElementValue( programValidationElement, 'leftSide' ) );
-	setInnerHTML( 'rightSideField', getElementValue( programValidationElement, 'rightSide' ) );
-	setInnerHTML( 'programField', getElementValue( programValidationElement, 'program' ) );
+	setInnerHTML( 'idField', $( programValidationElement).find('id').text() );
+	setInnerHTML( 'descriptionField', $( programValidationElement).find('description' ).text() );	
+    setInnerHTML( 'leftSideField', $( programValidationElement).find('leftSide').text() );
+	setInnerHTML( 'rightSideField', $( programValidationElement).find('rightSide').text() );
+	setInnerHTML( 'programField', $( programValidationElement).find('program').text() );
     
     showDetails();
 }
@@ -82,43 +84,37 @@
 
 function getLeftPrgramStageDataElements()
 {
-  var programStage = document.getElementById( 'leftStage' );
-  var psId = programStage.options[ programStage.selectedIndex ].value;
-  if( psId == '')
-  {
-	return;
-  }
+	clearListById( 'leftSideDE' );
+	
+	var programStage = document.getElementById( 'leftStage' );
+	var psId = programStage.options[ programStage.selectedIndex ].value;
+	if( psId == '') return;
   
-  var requestString = 'getPSDataElements.action?psId=' + psId;
-
-  var request = new Request();
-  request.setResponseTypeXML( 'leftSideDE' );
-  request.setCallbackSuccess( getLeftPrgramStageDataElementsCompleted );
-
-  request.send( requestString );	
+	$.ajax({
+		url: 'getPSDataElements.action?psId=' + psId,
+		dataType: "xml",
+		success: getLeftPrgramStageDataElementsCompleted
+	});  
 }
 
 function getLeftPrgramStageDataElementsCompleted( dataelementElement )
 {
-  var programstageDE = document.getElementById( 'leftSideDE' );
-  
-  clearList( programstageDE );
-  	
-  var programstageDEList = dataelementElement.getElementsByTagName( 'dataelement' );
+	var programstageDE = byId( 'leftSideDE' );
+	var programstageDEList = $(dataelementElement).find( 'dataelement' );
  
-  for ( var i = 0; i < programstageDEList.length; i++ )
-  {
-    var id = programstageDEList[ i ].getElementsByTagName("id")[0].firstChild.nodeValue;
-    var name = programstageDEList[ i ].getElementsByTagName("name")[0].firstChild.nodeValue;
-	var type = programstageDEList[ i ].getElementsByTagName("type")[0].firstChild.nodeValue;
+	$( programstageDEList ).each( function( i, item )
+        {
+            var id = $( item ).find("id").text();
+			var name = $( item ).find("name").text();
+			var type = $( item ).find("type").text(); 
 
-    var option = document.createElement("option");
-    option.value = id;
-    option.text = name;
-    option.title = name;
-    jQuery(option).attr({data:"{type:'"+type+"'}"});
-    programstageDE.add(option, null);       	
-  }	    
+			var option = document.createElement("option");
+			option.value = id;
+			option.text = name;
+			option.title = name;
+			jQuery(option).attr({data:"{type:'"+type+"'}"});
+			programstageDE.add(option, null);  			
+        } );
 }
 
 //------------------------------------------------------------------------------
@@ -127,60 +123,35 @@
 
 function getRightPrgramStageDataElements()
 {
-  var programStage = document.getElementById( 'rightStage' );
-  var psId = programStage.options[ programStage.selectedIndex ].value;
-  if( psId == '')
-  {
-	return;
-  }
+	clearListById( 'rightSideDE' );
+  	
+	var programStage = document.getElementById( 'rightStage' );
+	var psId = programStage.options[ programStage.selectedIndex ].value;
+	if( psId == '') return;
   
-  var requestString = 'getPSDataElements.action?psId=' + psId;
-
-  var request = new Request();
-  request.setResponseTypeXML( 'rightSideDE' );
-  request.setCallbackSuccess( getRightPrgramStageDataElementsCompleted );
-
-  request.send( requestString );	
+	$.ajax({
+		url: 'getPSDataElements.action?psId=' + psId,
+		dataType: "xml",
+		success: getRightPrgramStageDataElementsCompleted
+	});  
 }
 
 function getRightPrgramStageDataElementsCompleted( dataelementElement )
 {
-  var programstageDE = document.getElementById( 'rightSideDE' );
-  
-  clearList( programstageDE );
-  	
-  var programstageDEList = dataelementElement.getElementsByTagName( 'dataelement' );
+	var programstageDE = document.getElementById( 'rightSideDE' );
+	var programstageDEList = $(dataelementElement).find( 'dataelement' );
  
-  for ( var i = 0; i < programstageDEList.length; i++ )
-  {
-    var id = programstageDEList[ i ].getElementsByTagName("id")[0].firstChild.nodeValue;
-    var name = programstageDEList[ i ].getElementsByTagName("name")[0].firstChild.nodeValue;
-	var type = programstageDEList[ i ].getElementsByTagName("type")[0].firstChild.nodeValue;
-
-    var option = document.createElement("option");
-    option.value = id;
-    option.text = name;
-    option.title = name;
-    jQuery(option).attr({data:"{type:'"+type+"'}"});
-    programstageDE.add(option, null);       	
-  }	    
-}
-
-
-$.extend({
-  getUrlVars: function(){
-    var vars = [], hash;
-    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
-    for(var i = 0; i < hashes.length; i++)
+	$( programstageDEList ).each( function( i, item )
     {
-      hash = hashes[i].split('=');
-      vars.push(hash[0]);
-      vars[hash[0]] = hash[1];
-    }
-    return vars;
-  },
-  getUrlVar: function(name){
-    return $.getUrlVars()[name];
-  }
-});
-
+		var id = $( item ).find("id").text();
+		var name = $( item ).find("name").text();
+		var type = $( item ).find("type").text(); 
+		
+		var option = document.createElement("option");
+		option.value = id;
+		option.text = name;
+		option.title = name;
+		jQuery(option).attr({data:"{type:'"+type+"'}"});
+		programstageDE.add(option, null); 
+	});
+}