← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4272: minor fixes and indenting

 

------------------------------------------------------------
revno: 4272
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-08-10 12:56:58 +0200
message:
  minor fixes and indenting
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/cacheManifest.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js
  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
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.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-commons-resources/src/main/webapp/cacheManifest.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/cacheManifest.vm	2011-08-10 09:35:18 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/cacheManifest.vm	2011-08-10 10:56:58 +0000
@@ -1,5 +1,5 @@
 CACHE MANIFEST
-# 2.4-SNAPSHOT Version 9
+# 2.4-SNAPSHOT Version 10
 NETWORK:
 *
 CACHE:
@@ -14,6 +14,7 @@
 css/widgets.css
 ../dhis-web-dataentry/style/dhis-web-dataentry.css
 javascripts/jQuery/jquery-1.6.1.min.js
+javascripts/jQuery/ui/jquery-ui-1.8.12.custom.min.js
 javascripts/jQuery/jquery.metadata.js
 javascripts/jQuery/jquery.glob.js
 javascripts/jQuery/jquery.date.js

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2011-08-10 09:35:18 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2011-08-10 10:56:58 +0000
@@ -14,9 +14,10 @@
  * selection.setMultipleSelectionAllowed function to change this.
  */
 
+var organisationUnitTreePath = '../dhis-web-commons/ouwt/';
+
 var selection = new Selection();
 var subtree = new Subtree();
-var organisationUnitTreePath = '../dhis-web-commons/ouwt/';
 
 $( document ).ready( function()
 {
@@ -29,9 +30,7 @@
 
 function Selection()
 {
-    var listenerFunction;
-    var multipleSelectionAllowed = false;
-    var unselectAllowed = false;
+    var listenerFunction, multipleSelectionAllowed = false, unselectAllowed = false;
 
     this.setListenerFunction = function( listenerFunction_ )
     {
@@ -46,7 +45,7 @@
     this.setUnselectAllowed = function( allowed )
     {
         unselectAllowed = allowed;
-    }
+    };
 
     this.load = function()
     {
@@ -54,9 +53,9 @@
         {
             var roots = [];
 
-            for ( var i in data["organisationUnits"] )
+            for ( var i in data.organisationUnits )
             {
-                var ou = data["organisationUnits"][i];
+                var ou = data.organisationUnits[i];
                 roots.push( ou.id );
                 store_ou( ou );
             }
@@ -84,7 +83,7 @@
 
             $( "#ouwt_loader" ).hide();
         } );
-    }
+    };
 
     // server = true : sync from server
     // server = false : sync to server
@@ -158,7 +157,7 @@
                 }
             } );
         }
-    }
+    };
 
     this.clear = function()
     {
@@ -178,7 +177,7 @@
         subtree.reloadTree();
 
         $.post( organisationUnitTreePath + "clearselected.action" ).complete( this.responseReceived );
-    }
+    };
 
     function store_ou( ou )
     {
@@ -196,6 +195,7 @@
 
         localStorage[getTagId( ou.id )] = JSON.stringify( output );
     }
+    ;
 
     this.select = function( unitId )
     {
@@ -317,12 +317,13 @@
         }
 
         listenerFunction( ids, names );
-    }
+    };
 
     function getTagId( unitId )
     {
         return 'orgUnit' + unitId;
     }
+    ;
 
     this.findByCode = function()
     {
@@ -382,12 +383,12 @@
         {
             selectOrgUnit( item );
         } );
-    }
+    };
 
     selectOrgUnit = function( ou )
     {
         $( "#" + getTagId( ou ) + " > a" ).addClass( "selected" );
-    }
+    };
 
     expandTreeAtOrgUnits = function( ous )
     {
@@ -395,7 +396,7 @@
         {
             expandTreeAtOrgUnit( item );
         } );
-    }
+    };
 
     expandTreeAtOrgUnit = function( ou )
     {
@@ -449,7 +450,7 @@
             var expand = JSON.parse( localStorage[getTagId( item )] );
             processExpand( expand );
         } );
-    }
+    };
 
     this.reloadTree = function()
     {
@@ -483,7 +484,7 @@
     this.refreshTree = function()
     {
         selection.load();
-    }
+    };
 
     function processCollapse( parent )
     {
@@ -492,6 +493,7 @@
         setVisible( child, false );
         setToggle( $parentTag, false );
     }
+    ;
 
     function processExpand( parent )
     {
@@ -508,6 +510,7 @@
             setToggle( $parentTag, true );
         }
     }
+    ;
 
     function createChildren( parentTag, parent )
     {
@@ -524,6 +527,7 @@
 
         $( parentTag ).append( $childrenTag );
     }
+    ;
 
     function createTreeElementTag( ou )
     {
@@ -554,6 +558,7 @@
 
         return $childTag;
     }
+    ;
 
     function setToggle( unitTag, expanded )
     {
@@ -569,6 +574,7 @@
             $toggleTag.append( toggleImg );
         }
     }
+    ;
 
     function setVisible( tag, visible )
     {
@@ -581,34 +587,41 @@
             $( tag ).hide();
         }
     }
+    ;
 
     function isVisible( tag )
     {
         return $( tag ).is( ":visible" );
     }
+    ;
 
     function getTagId( unitId )
     {
         return 'orgUnit' + unitId;
     }
+    ;
 
     function getToggleExpand()
     {
         return getToggleImage().attr( "src", "../images/colapse.png" ).attr( "alt", "[+]" );
     }
+    ;
 
     function getToggleCollapse()
     {
         return getToggleImage().attr( "src", "../images/expand.png" ).attr( "alt", "[-]" );
     }
+    ;
 
     function getToggleBlank()
     {
         return getToggleImage().attr( "src", "../images/transparent.gif" ).removeAttr( "alt" );
     }
+    ;
 
     function getToggleImage()
     {
         return $( "<img/>" ).attr( "width", 9 ).attr( "height", 9 );
     }
+    ;
 }

=== 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-02 18:48:02 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2011-08-10 10:56:58 +0000
@@ -1,13 +1,11 @@
-
 /**
  * This file depends on form.js.
  * 
  * Format for the span/input identifiers for selectors:
  * 
- * {dataelementid}-{optioncomboid}-val // data value
- * {dataelementid}-dataelement // name of data element
- * {optioncomboid}-optioncombo // name of category option combo
- * {dataelementid}-cell // table cell for data element name
+ * {dataelementid}-{optioncomboid}-val // data value {dataelementid}-dataelement //
+ * name of data element {optioncomboid}-optioncombo // name of category option
+ * combo {dataelementid}-cell // table cell for data element name
  * {dataelementid}-{optioncomboid}-min // min value for data value
  * {dataelementid}-{optioncomboid}-max // max value for data value
  */
@@ -15,7 +13,6 @@
 // -----------------------------------------------------------------------------
 // Save
 // -----------------------------------------------------------------------------
-
 var FORMULA_PATTERN = /\[.+?\]/g;
 var SEPARATOR = '.';
 
@@ -71,7 +68,10 @@
     for ( k in matcher )
     {
         var match = matcher[k];
-        var operand = match.replace( /[\[\]]/g, '' ); // Remove brackets from expression to simplify extraction of identifiers
+        var operand = match.replace( /[\[\]]/g, '' ); // Remove brackets from
+                                                        // expression to
+                                                        // simplify extraction
+                                                        // of identifiers
 
         var dataElementId = operand.substring( 0, operand.indexOf( SEPARATOR ) );
         var categoryOptionComboId = operand.substring( operand.indexOf( SEPARATOR ) + 1, operand.length );
@@ -80,7 +80,8 @@
 
         var value = $( fieldId ) && $( fieldId ).val() ? $( fieldId ).val() : '0';
 
-        expression = expression.replace( match, value ); // TODO signed numbers
+        expression = expression.replace( match, value ); // TODO signed
+                                                            // numbers
     }
 
     return expression;
@@ -93,13 +94,13 @@
 {
     var dataElementName = dataElements[dataElementId].name;
     var fieldId = '#' + dataElementId + '-' + optionComboId + '-val';
-    var value =$( fieldId ).val();
+    var value = $( fieldId ).val();
     var type = dataElements[dataElementId].type;
 
     $( fieldId ).css( 'background-color', COLOR_YELLOW );
 
-	var periodId = $( '#selectedPeriodId' ).val();
-        
+    var periodId = $( '#selectedPeriodId' ).val();
+
     if ( value )
     {
         if ( type == 'int' || type == 'number' || type == 'positiveNumber' || type == 'negativeNumber' )
@@ -110,7 +111,7 @@
             }
             if ( type == 'int' && !isInt( value ) )
             {
-                return alertField( fieldId,  i18n_value_must_integer + '\n\n' + dataElementName );
+                return alertField( fieldId, i18n_value_must_integer + '\n\n' + dataElementName );
             }
             if ( type == 'number' && !isRealNumber( value ) )
             {
@@ -118,7 +119,7 @@
             }
             if ( type == 'positiveNumber' && !isPositiveInt( value ) )
             {
-                return alertField( fieldId,  i18n_value_must_positive_integer + '\n\n' + dataElementName );
+                return alertField( fieldId, i18n_value_must_positive_integer + '\n\n' + dataElementName );
             }
             if ( type == 'negativeNumber' && !isNegativeInt( value ) )
             {
@@ -126,7 +127,8 @@
             }
             if ( isValidZeroNumber( value ) )
             {
-                // If value is 0 and zero is not significant for data element, skip value
+                // If value is 0 and zero is not significant for data element,
+                // skip value
                 if ( significantZeros.indexOf( dataElementId ) == -1 )
                 {
                     $( fieldId ).css( 'background-color', COLOR_GREEN );
@@ -145,7 +147,8 @@
 
                 if ( valueNo < min )
                 {
-                    var valueSaver = new ValueSaver( dataElementId, optionComboId, currentOrganisationUnitId, periodId, value, COLOR_ORANGE );
+                    var valueSaver = new ValueSaver( dataElementId, optionComboId, currentOrganisationUnitId, periodId,
+                            value, COLOR_ORANGE );
                     valueSaver.save();
 
                     window.alert( i18n_value_of_data_element_less + ': ' + min + '\n\n' + dataElementName );
@@ -154,7 +157,8 @@
 
                 if ( valueNo > max )
                 {
-                    var valueSaver = new ValueSaver( dataElementId, optionComboId, currentOrganisationUnitId, periodId, value, COLOR_ORANGE );
+                    var valueSaver = new ValueSaver( dataElementId, optionComboId, currentOrganisationUnitId, periodId,
+                            value, COLOR_ORANGE );
                     valueSaver.save();
 
                     window.alert( i18n_value_of_data_element_greater + ': ' + max + '\n\n' + dataElementName );
@@ -162,11 +166,12 @@
                 }
             }
         }
-        
-	    var valueSaver = new ValueSaver( dataElementId, optionComboId, currentOrganisationUnitId, periodId, value, COLOR_GREEN );
-	    valueSaver.save();
-	    
-	    updateIndicators(); // Update indicators in case of custom form
+
+        var valueSaver = new ValueSaver( dataElementId, optionComboId, currentOrganisationUnitId, periodId, value,
+                COLOR_GREEN );
+        valueSaver.save();
+
+        updateIndicators(); // Update indicators in case of custom form
     }
 }
 
@@ -177,9 +182,10 @@
 
     $( fieldId ).css( 'background-color', COLOR_YELLOW );
 
-	var periodId = $( '#selectedPeriodId' ).val();
-        
-    var valueSaver = new ValueSaver( dataElementId, optionComboId, currentOrganisationUnitId, periodId, value, COLOR_GREEN );
+    var periodId = $( '#selectedPeriodId' ).val();
+
+    var valueSaver = new ValueSaver( dataElementId, optionComboId, currentOrganisationUnitId, periodId, value,
+            COLOR_GREEN );
     valueSaver.save();
 }
 
@@ -247,4 +253,4 @@
     {
         $( '#' + dataElementId + '-' + optionComboId + '-val' ).css( 'background-color', color );
     }
-}
\ No newline at end of file
+}

=== 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-08 17:57:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2011-08-10 10:56:58 +0000
@@ -4,19 +4,23 @@
 // Array with associative arrays for each data element, populated in select.vm
 var dataElements = [];
 
-// Associative array with [indicator id, expression] for indicators in form, also used in entry.js, populated in select.vm
+// Associative array with [indicator id, expression] for indicators in form,
+// also used in entry.js, populated in select.vm
 var indicatorFormulas = [];
 
 // Array with associative arrays for each data set, populated in select.vm
 var dataSets = [];
 
-// Associative array with identifier and array of assigned data sets, populated in select.vm
+// Associative array with identifier and array of assigned data sets, populated
+// in select.vm
 var dataSetAssociationSets = [];
 
-// Associate array with mapping between organisation unit identifier and data set association set identifier, populated in select.vm
+// Associate array with mapping between organisation unit identifier and data
+// set association set identifier, populated in select.vm
 var organisationUnitAssociationSetMap = [];
 
-// Array with keys on form {dataelementid}-{optioncomboid}-min/max with min/max values
+// Array with keys on form {dataelementid}-{optioncomboid}-min/max with min/max
+// values
 var currentMinMaxValueMap = [];
 
 // Indicates whether any data entry form has been loaded
@@ -28,7 +32,8 @@
 // Currently selected data set identifier
 var currentDataSetId = null;
 
-// Current offset, next or previous corresponding to increasing or decreasing value with one
+// Current offset, next or previous corresponding to increasing or decreasing
+// value with one
 var currentPeriodOffset = 0;
 
 // Period type object
@@ -40,68 +45,74 @@
 var COLOR_ORANGE = '#ff6600';
 var COLOR_WHITE = '#ffffff';
 
-//Page init
+// Page init
 
-$( document ).ready( function() {
-	selection.setListenerFunction( organisationUnitSelected );
+$( document ).ready( function()
+{
+    selection.setListenerFunction( organisationUnitSelected );
 } );
 
 function addEventListeners()
 {
-    $( '[name="entryfield"]' ).each( function( i ) 
+    $( '[name="entryfield"]' ).each( function( i )
     {
-    	var id = $( this ).attr( 'id' );    	
-		var dataElementId = id.split( '-' )[0];
-		var optionComboId = id.split( '-' )[1];
-		var type = dataElements[dataElementId].type;
-    	
-    	$( this ).unbind( 'focus' );
-    	$( this ).unbind( 'blur' );
-    	$( this ).unbind( 'change' );
-    	$( this ).unbind( 'dblclick' );
-    	$( this ).unbind( 'keyup' );
-    	
-    	$( this ).focus( valueFocus );
-    	
-    	$( this ).blur( valueBlur );
-    	
-    	$( this ).change( function() {
-    		saveVal( dataElementId, optionComboId );
-    	} );
-    	
-    	$( this ).dblclick( function() {
-    		viewHist( dataElementId, optionComboId );
-    	} );
-    	
-    	$( this ).keyup( function() {
-    		keyPress( event, this );
-    	} );
-    	
-    	$( this ).css( 'width', '100%' );
-    	$( this ).css( 'text-align', 'center' );
-    	
-    	if ( type == 'date' ) {
-    		$( this ).css( 'width', '80%' );    		
-    		datePicker( id );
-    	}
+        var id = $( this ).attr( 'id' );
+        var dataElementId = id.split( '-' )[0];
+        var optionComboId = id.split( '-' )[1];
+        var type = dataElements[dataElementId].type;
+
+        $( this ).unbind( 'focus' );
+        $( this ).unbind( 'blur' );
+        $( this ).unbind( 'change' );
+        $( this ).unbind( 'dblclick' );
+        $( this ).unbind( 'keyup' );
+
+        $( this ).focus( valueFocus );
+
+        $( this ).blur( valueBlur );
+
+        $( this ).change( function()
+        {
+            saveVal( dataElementId, optionComboId );
+        } );
+
+        $( this ).dblclick( function()
+        {
+            viewHist( dataElementId, optionComboId );
+        } );
+
+        $( this ).keyup( function()
+        {
+            keyPress( event, this );
+        } );
+
+        $( this ).css( 'width', '100%' );
+        $( this ).css( 'text-align', 'center' );
+
+        if ( type == 'date' )
+        {
+            $( this ).css( 'width', '80%' );
+            datePicker( id );
+        }
     } );
-    
+
     $( '[name="entryselect"]' ).each( function( i )
     {
-    	var id = $( this ).attr( 'id' );    	
-		var dataElementId = id.split( '-' )[0];
-		var optionComboId = id.split( '-' )[1];	
-		
-    	$( this ).unbind( 'focus' );
-    	$( this ).unbind( 'change' );
-    	
-    	$( this ).focus( valueFocus );
-    	
-    	$( this ).change( function() {
-    		saveBoolean( dataElementId, optionComboId );
-    	} );
-    	
-    	$( this ).css( 'width', '100%' );
+        var id = $( this ).attr( 'id' );
+        var dataElementId = id.split( '-' )[0];
+        var optionComboId = id.split( '-' )[1];
+
+        $( this ).unbind( 'focus' );
+        $( this ).unbind( 'change' );
+
+        $( this ).focus( valueFocus );
+
+        $( this ).change( function()
+        {
+            saveBoolean( dataElementId, optionComboId );
+        } );
+
+        $( this ).css( 'width', '100%' );
     } );
 }
 
@@ -114,17 +125,21 @@
 function clearEntryForm()
 {
     $( '#contentDiv' ).html( '' );
-    
-	currentPeriodOffset = 0;
-	
+
+    currentPeriodOffset = 0;
+
     dataEntryFormIsLoaded = false;
 }
 
 function loadForm( periodId, dataSetId )
 {
-	var defaultForm = $( '#defaultForm' ).is( ':checked' );
-	
-	$( '#contentDiv' ).load( 'loadForm.action', { periodId:periodId, dataSetId:dataSetId, defaultForm:defaultForm }, loadDataValues );
+    var defaultForm = $( '#defaultForm' ).is( ':checked' );
+
+    $( '#contentDiv' ).load( 'loadForm.action', {
+        periodId : periodId,
+        dataSetId : dataSetId,
+        defaultForm : defaultForm
+    }, loadDataValues );
 }
 
 function loadDefaultForm()
@@ -132,7 +147,7 @@
     var dataSetId = $( '#selectedDataSetId' ).val();
     var periodId = $( '#selectedPeriodId' ).val();
 
-	loadForm( periodId, dataSetId );
+    loadForm( periodId, dataSetId );
 }
 
 // -----------------------------------------------------------------------------
@@ -140,39 +155,40 @@
 // -----------------------------------------------------------------------------
 
 /**
- * Returns an array containing associative array elements with id and name 
+ * Returns an array containing associative array elements with id and name
  * properties. The array is sorted on the element name property.
  */
 function getSortedDataSetList()
 {
-	var associationSet = organisationUnitAssociationSetMap[currentOrganisationUnitId];
-	var orgUnitDataSets = dataSetAssociationSets[associationSet];
-	
-	var dataSetList = [];
-	
-	for ( i in orgUnitDataSets )
-	{
-		var dataSetId = orgUnitDataSets[i];
-		var dataSetName = dataSets[dataSetId].name;
-		
-		var row = [];
-		row['id'] = dataSetId;
-		row['name'] = dataSetName;
-		dataSetList[i] = row;		
-	}
-	
-	dataSetList.sort( function( a, b ) {
-		return a.name > b.name ? 1 : a.name < b.name ? -1 : 0;
-	} );
-	
-	return dataSetList;	
+    var associationSet = organisationUnitAssociationSetMap[currentOrganisationUnitId];
+    var orgUnitDataSets = dataSetAssociationSets[associationSet];
+
+    var dataSetList = [];
+
+    for ( i in orgUnitDataSets )
+    {
+        var dataSetId = orgUnitDataSets[i];
+        var dataSetName = dataSets[dataSetId].name;
+
+        var row = [];
+        row['id'] = dataSetId;
+        row['name'] = dataSetName;
+        dataSetList[i] = row;
+    }
+
+    dataSetList.sort( function( a, b )
+    {
+        return a.name > b.name ? 1 : a.name < b.name ? -1 : 0;
+    } );
+
+    return dataSetList;
 }
 
 function organisationUnitSelected( orgUnits, orgUnitNames )
 {
-	currentOrganisationUnitId = orgUnits[0];
-	var organisationUnitName = orgUnitNames[0];
-	
+    currentOrganisationUnitId = orgUnits[0];
+    var organisationUnitName = orgUnitNames[0];
+
     $( '#selectedDataSetId' ).removeAttr( 'disabled' );
 
     var dataSetId = $( '#selectedDataSetId' ).val();
@@ -180,37 +196,39 @@
 
     var url = 'loadDataSets.action';
 
-	$( '#selectedOrganisationUnit' ).val( organisationUnitName );
-	$( '#currentOrganisationUnit' ).html( organisationUnitName );
+    $( '#selectedOrganisationUnit' ).val( organisationUnitName );
+    $( '#currentOrganisationUnit' ).html( organisationUnitName );
 
     clearListById( 'selectedDataSetId' );
 
-	addOptionById( 'selectedDataSetId', '-1', '[ ' + i18n_select_data_set + ' ]' );
-	
-	var dataSetList = getSortedDataSetList();
-	
-	var dataSetValid = false;
-	
-	for ( i in dataSetList )
+    addOptionById( 'selectedDataSetId', '-1', '[ ' + i18n_select_data_set + ' ]' );
+
+    var dataSetList = getSortedDataSetList();
+
+    var dataSetValid = false;
+
+    for ( i in dataSetList )
     {
         addOptionById( 'selectedDataSetId', dataSetList[i].id, dataSetList[i].name );
-        
+
         if ( dataSetId == dataSetList[i].id )
         {
-        	dataSetValid = true;
+            dataSetValid = true;
         }
     }
 
-	if ( dataSetValid && dataSetId != null )
-	{
-		$( '#selectedDataSetId' ).val( dataSetId );
+    if ( dataSetValid && dataSetId != null )
+    {
+        $( '#selectedDataSetId' ).val( dataSetId );
 
-        if ( periodId && periodId != -1 && dataEntryFormIsLoaded ) //TODO if period valid
+        if ( periodId && periodId != -1 && dataEntryFormIsLoaded ) // TODO if
+                                                                    // period
+                                                                    // valid
         {
             showLoader();
             loadDataValues();
         }
-    } 
+    }
     else
     {
         clearPeriod();
@@ -223,11 +241,11 @@
 
 function nextPeriodsSelected()
 {
-	if ( currentPeriodOffset < 0 ) // Cannot display future periods
-	{
-    	currentPeriodOffset++;
-    	displayPeriodsInternal();
-	}
+    if ( currentPeriodOffset < 0 ) // Cannot display future periods
+    {
+        currentPeriodOffset++;
+        displayPeriodsInternal();
+    }
 }
 
 function previousPeriodsSelected()
@@ -238,14 +256,14 @@
 
 function displayPeriodsInternal()
 {
-    var dataSetId = $( '#selectedDataSetId' ).val();    
+    var dataSetId = $( '#selectedDataSetId' ).val();
     var periodType = dataSets[dataSetId].periodType;
     var periods = periodTypeFactory.get( periodType ).generatePeriods( currentPeriodOffset );
     periods = periodTypeFactory.filterFuturePeriods( periods );
 
-	clearListById( 'selectedPeriodId' );
+    clearListById( 'selectedPeriodId' );
 
-	addOptionById( 'selectedPeriodId', '-1', '[ ' + i18n_select_period + ' ]' );
+    addOptionById( 'selectedPeriodId', '-1', '[ ' + i18n_select_period + ' ]' );
 
     for ( i in periods )
     {
@@ -266,7 +284,7 @@
     var dataSetId = $( '#selectedDataSetId' ).val();
     var periodId = $( '#selectedPeriodId' ).val();
     var periodType = dataSets[dataSetId].periodType;
-	var periods = periodTypeFactory.get( periodType ).generatePeriods( currentPeriodOffset );
+    var periods = periodTypeFactory.get( periodType ).generatePeriods( currentPeriodOffset );
     periods = periodTypeFactory.filterFuturePeriods( periods );
 
     if ( dataSetId && dataSetId != -1 )
@@ -279,7 +297,7 @@
         {
             addOptionById( 'selectedPeriodId', periods[i].id, periods[i].name );
         }
-        
+
         var previousPeriodType = currentDataSetId ? dataSets[currentDataSetId].periodType : null;
 
         if ( periodId && periodId != -1 && previousPeriodType && previousPeriodType == periodType )
@@ -287,13 +305,13 @@
             showLoader();
             $( '#selectedPeriodId' ).val( periodId );
             loadForm( periodId, dataSetId );
-        } 
+        }
         else
         {
             clearEntryForm();
         }
-        
-    	currentDataSetId = dataSetId;
+
+        currentDataSetId = dataSetId;
     }
 }
 
@@ -309,18 +327,18 @@
     $( '#currentPeriod' ).html( periodName );
 
     var periodId = $( '#selectedPeriodId' ).val();
-    
+
     if ( periodId && periodId != -1 )
     {
         showLoader();
-        
+
         if ( dataEntryFormIsLoaded )
         {
-        	loadDataValues();
+            loadDataValues();
         }
         else
         {
-        	loadForm( periodId, dataSetId );
+            loadForm( periodId, dataSetId );
         }
     }
 }
@@ -331,104 +349,116 @@
 
 function loadDataValues()
 {
-	insertDataValues();
-	displayEntryFormCompleted();
+    insertDataValues();
+    displayEntryFormCompleted();
 }
 
 function insertDataValues()
 {
-	var dataValueMap = new Array();
-	
-	var periodId = $( '#selectedPeriodId' ).val();
+    var dataValueMap = new Array();
+
+    var periodId = $( '#selectedPeriodId' ).val();
     var dataSetId = $( '#selectedDataSetId' ).val();
-	
-	// Clear existing values and colors
-	
-	$( '[name="entryfield"]' ).val( '' );
-	$( '[name="entryselect"]' ).val( '' );
-	
-	$( '[name="entryfield"]' ).css( 'background-color', COLOR_WHITE );
-	$( '[name="entryselect"]' ).css( 'background-color', COLOR_WHITE );
-	
-	$( '[name="min"]' ).html( '' );
-	$( '[name="max"]' ).html( '' );
-	
-	$.getJSON( 'getDataValues.action', { periodId:periodId, dataSetId:dataSetId }, function( json ) 
-	{
-		// Set data values, works for select lists too as data value = select value
-	
-		$.each( json.dataValues, function( i, value )
-		{
-			var fieldId = '#' + value.id + '-val';
-			
-			if ( $( fieldId ) )
-			{
-				$( fieldId ).val( value.val );
-			}
-			
-			dataValueMap[value.id] = value.val;
-		} );
-		
-		// Set min-max values and colorize violation fields
-		
-		$.each( json.minMaxDataElements, function( i, value )
-		{
-			var minId = value.id + '-min';
-			var maxId = value.id + '-max';
-			
-			var valFieldId = '#' + value.id + '-val';
-			
-			var dataValue = dataValueMap[value.id];
-			
-			if ( dataValue && ( ( value.min && new Number( dataValue ) < new Number( value.min ) ) 
-				|| ( value.max && new Number( dataValue ) > new Number( value.max ) ) ) )
-			{
-				$( valFieldId ).css( 'background-color', COLOR_ORANGE );
-			}
-			
-			currentMinMaxValueMap[minId] = value.min;
-			currentMinMaxValueMap[maxId] = value.max;
-		} );
-		
-		// Update indicator values in form
-		
-		updateIndicators();
-	} );
+
+    // Clear existing values and colors
+
+    $( '[name="entryfield"]' ).val( '' );
+    $( '[name="entryselect"]' ).val( '' );
+
+    $( '[name="entryfield"]' ).css( 'background-color', COLOR_WHITE );
+    $( '[name="entryselect"]' ).css( 'background-color', COLOR_WHITE );
+
+    $( '[name="min"]' ).html( '' );
+    $( '[name="max"]' ).html( '' );
+
+    $
+            .getJSON(
+                    'getDataValues.action',
+                    {
+                        periodId : periodId,
+                        dataSetId : dataSetId
+                    },
+                    function( json )
+                    {
+                        // Set data values, works for select lists too as data
+                        // value = select value
+
+                        $.each( json.dataValues, function( i, value )
+                        {
+                            var fieldId = '#' + value.id + '-val';
+
+                            if ( $( fieldId ) )
+                            {
+                                $( fieldId ).val( value.val );
+                            }
+
+                            dataValueMap[value.id] = value.val;
+                        } );
+
+                        // Set min-max values and colorize violation fields
+
+                        $
+                                .each(
+                                        json.minMaxDataElements,
+                                        function( i, value )
+                                        {
+                                            var minId = value.id + '-min';
+                                            var maxId = value.id + '-max';
+
+                                            var valFieldId = '#' + value.id + '-val';
+
+                                            var dataValue = dataValueMap[value.id];
+
+                                            if ( dataValue
+                                                    && ( ( value.min && new Number( dataValue ) < new Number( value.min ) ) || ( value.max && new Number(
+                                                            dataValue ) > new Number( value.max ) ) ) )
+                                            {
+                                                $( valFieldId ).css( 'background-color', COLOR_ORANGE );
+                                            }
+
+                                            currentMinMaxValueMap[minId] = value.min;
+                                            currentMinMaxValueMap[maxId] = value.max;
+                                        } );
+
+                        // Update indicator values in form
+
+                        updateIndicators();
+                    } );
 }
 
 function displayEntryFormCompleted()
 {
     addEventListeners();
-    
+
     $( '#validationButton' ).removeAttr( 'disabled' );
     $( '#defaultForm' ).removeAttr( 'disabled' );
-    
+
     dataEntryFormIsLoaded = true;
     hideLoader();
 }
 
 function valueFocus( e )
 {
-	var id = e.target.id;
-
-	var dataElementId = id.split( '-' )[0];
-	var optionComboId = id.split( '-' )[1];
-	
-	var dataElementName = dataElements[dataElementId].name;
-	var optionComboName = $( '#' + optionComboId + '-optioncombo' ).text();
-	
-	$( '#currentDataElement' ).html( dataElementName + ' ' + optionComboName );
-	
-	$( '#' + dataElementId + '-cell' ).addClass( 'currentRow' );
+    var id = e.target.id;
+
+    var dataElementId = id.split( '-' )[0];
+    var optionComboId = id.split( '-' )[1];
+
+    var dataElementName = dataElements[dataElementId].name;
+    var optionComboName = $( '#' + optionComboId + '-optioncombo' ).text();
+
+    $( '#currentDataElement' ).html( dataElementName + ' ' + optionComboName );
+
+    $( '#' + dataElementId + '-cell' ).addClass( 'currentRow' );
 }
 
 function valueBlur( e )
 {
-	var id = e.target.id;
-
-	var dataElementId = id.split( '-' )[0];
-	
-	$( '#' + dataElementId + '-cell' ).removeClass( 'currentRow' );
+    var id = e.target.id;
+
+    var dataElementId = id.split( '-' )[0];
+
+    $( '#' + dataElementId + '-cell' ).removeClass( 'currentRow' );
 }
 
 function keyPress( event, field )
@@ -455,7 +485,7 @@
         if ( field.is( ':disabled' ) || field.is( ':hidden' ) )
         {
             field = $( 'input[name="entryfield"][tabindex="' + ( ++index ) + '"]' );
-        } 
+        }
         else
         {
             return field;
@@ -474,7 +504,7 @@
         if ( field.is( ':disabled' ) || field.is( ':hidden' ) )
         {
             field = $( 'input[name="entryfield"][tabindex="' + ( --index ) + '"]' );
-        } 
+        }
         else
         {
             return field;
@@ -492,13 +522,16 @@
 
     if ( confirmed )
     {
-		var periodId = $( '#selectedPeriodId' ).val();
-    	var dataSetId = $( '#selectedDataSetId' ).val();
-		
+        var periodId = $( '#selectedPeriodId' ).val();
+        var dataSetId = $( '#selectedDataSetId' ).val();
+
         $( '#completeButton' ).attr( 'disabled', 'disabled' );
         $( '#undoButton' ).removeAttr( 'disabled' );
 
-        $.getJSON( 'getValidationViolations.action', { periodId:periodId, dataSetId:dataSetId }, registerCompleteDataSet ).error( function()
+        $.getJSON( 'getValidationViolations.action', {
+            periodId : periodId,
+            dataSetId : dataSetId
+        }, registerCompleteDataSet ).error( function()
         {
             $( '#completeButton' ).removeAttr( 'disabled' );
             $( '#undoButton' ).attr( 'disabled', 'disabled' );
@@ -510,12 +543,15 @@
 
 function registerCompleteDataSet( json )
 {
-	var periodId = $( '#selectedPeriodId' ).val();
+    var periodId = $( '#selectedPeriodId' ).val();
     var dataSetId = $( '#selectedDataSetId' ).val();
-		
+
     if ( json.response == 'success' )
     {
-        $.getJSON( 'registerCompleteDataSet.action', { periodId:periodId, dataSetId:dataSetId }, function()
+        $.getJSON( 'registerCompleteDataSet.action', {
+            periodId : periodId,
+            dataSetId : dataSetId
+        }, function()
         {
         } ).error( function()
         {
@@ -524,10 +560,10 @@
 
             alert( i18n_no_response_from_server );
         } );
-    } 
+    }
     else
     {
-    	validate();
+        validate();
     }
 }
 
@@ -537,13 +573,16 @@
 
     if ( confirmed )
     {
-		var periodId = $( '#selectedPeriodId' ).val();
-    	var dataSetId = $( '#selectedDataSetId' ).val();
-		
+        var periodId = $( '#selectedPeriodId' ).val();
+        var dataSetId = $( '#selectedDataSetId' ).val();
+
         $( '#completeButton' ).removeAttr( 'disabled' );
         $( '#undoButton' ).attr( 'disabled', 'disabled' );
 
-        $.getJSON( 'undoCompleteDataSet.action', { periodId:periodId, dataSetId:dataSetId }, function()
+        $.getJSON( 'undoCompleteDataSet.action', {
+            periodId : periodId,
+            dataSetId : dataSetId
+        }, function()
         {
         } ).error( function()
         {
@@ -561,23 +600,23 @@
 
 function displayValidationDialog()
 {
-	$( '#validationDiv' ).dialog( {
-	    modal: true,
-	   	title: 'Validation',
-	   	width: 800,
-	   	height: 400
-	} );
+    $( '#validationDiv' ).dialog( {
+        modal : true,
+        title : 'Validation',
+        width : 800,
+        height : 400
+    } );
 }
 
 function validate()
 {
-	var periodId = $( '#selectedPeriodId' ).val();
+    var periodId = $( '#selectedPeriodId' ).val();
     var dataSetId = $( '#selectedDataSetId' ).val();
-	
-	$( '#validationDiv' ).load( 'validate.action', {
-		periodId: periodId, dataSetId: dataSetId },	
-		displayValidationDialog
-	);
+
+    $( '#validationDiv' ).load( 'validate.action', {
+        periodId : periodId,
+        dataSetId : dataSetId
+    }, displayValidationDialog );
 }
 
 // -----------------------------------------------------------------------------
@@ -586,27 +625,30 @@
 
 function displayHistoryDialog( operandName )
 {
-	$( '#historyDiv' ).dialog( {
-	    modal: true,
-	   	title: operandName,
-	   	width: 580,
-	   	height: 710
-	} );
+    $( '#historyDiv' ).dialog( {
+        modal : true,
+        title : operandName,
+        width : 580,
+        height : 710
+    } );
 }
 
 function viewHist( dataElementId, optionComboId )
 {
-	var periodId = $( '#selectedPeriodId' ).val();
-	
-	var dataElementName = dataElements[dataElementId].name;
-	var optionComboName = $( '#' + optionComboId + '-optioncombo' ).html();
-	var operandName = dataElementName + ' ' + optionComboName;
-	
+    var periodId = $( '#selectedPeriodId' ).val();
+
+    var dataElementName = dataElements[dataElementId].name;
+    var optionComboName = $( '#' + optionComboId + '-optioncombo' ).html();
+    var operandName = dataElementName + ' ' + optionComboName;
+
     $( '#historyDiv' ).load( 'viewHistory.action', {
-    	dataElementId: dataElementId, optionComboId: optionComboId, periodId: periodId }, function() {
-    		displayHistoryDialog( operandName );
-    	}
-    );
+        dataElementId : dataElementId,
+        optionComboId : optionComboId,
+        periodId : periodId
+    }, function()
+    {
+        displayHistoryDialog( operandName );
+    } );
 }
 
 function closeCurrentSelection()

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2011-07-28 07:15:09 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2011-08-10 10:56:58 +0000
@@ -1,43 +1,48 @@
-
 // -----------------------------------------------------------------------------
 // Comments
 // -----------------------------------------------------------------------------
 
 function saveComment()
 {
-	var commentValue = $( '#commentTextArea' ).val();
-	var periodId = $( '#selectedPeriodId' ).val();
-	
-	var commentSaver = new CommentSaver( currentDataElementId, currentOptionComboId, currentOrganisationUnitId, periodId, commentValue );
-	
-	commentSaver.save();
+    var commentValue = $( '#commentTextArea' ).val();
+    var periodId = $( '#selectedPeriodId' ).val();
+
+    var commentSaver = new CommentSaver( currentDataElementId, currentOptionComboId, currentOrganisationUnitId,
+            periodId, commentValue );
+
+    commentSaver.save();
 }
 
 function CommentSaver( dataElementId_, optionComboId_, organisationUnitId_, periodId_, value_ )
-{	
+{
     var dataElementId = dataElementId_;
     var optionComboId = optionComboId_;
     var organisationUnitId = organisationUnitId_;
     var periodId = periodId_;
     var value = value_;
-    
+
     this.save = function()
     {
-    	markComment( COLOR_YELLOW );
-    	
-        var url = 'saveComment.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' +
-                dataElementId + '&optionComboId=' + optionComboId + '&periodId=' + periodId + '&comment=' + value;
-        
-        $.ajax( { url: url, dataType: 'json', success: handleResponse, error: handleError } );
+        markComment( COLOR_YELLOW );
+
+        var url = 'saveComment.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId
+                + '&optionComboId=' + optionComboId + '&periodId=' + periodId + '&comment=' + value;
+
+        $.ajax( {
+            url : url,
+            dataType : 'json',
+            success : handleResponse,
+            error : handleError
+        } );
     };
-    
+
     function handleResponse( json )
     {
-    	var code = json.c;
-    	
+        var code = json.c;
+
         if ( code == 0 )
         {
-            markComment( COLOR_GREEN );           
+            markComment( COLOR_GREEN );
         }
         else
         {
@@ -45,105 +50,111 @@
             window.alert( i18n_saving_comment_failed_status_code + '\n\n' + code );
         }
     }
-    
+
     function handleError( jqXHR, textStatus, errorThrown )
     {
         markComment( COLOR_RED );
         window.alert( i18n_saving_comment_failed_error_code + '\n\n' + textStatus );
     }
-    
+
     function markComment( color )
     {
-    	$( '#commentTextArea' ).css( 'background-color', color );
+        $( '#commentTextArea' ).css( 'background-color', color );
     }
 }
 
 function removeMinMaxLimit()
 {
-	$( '#minLimit' ).val( '' );
-	$( '#maxLimit' ).val( '' );
-	
-	var url = 'removeMinMaxLimits.action?organisationUnitId=' + currentOrganisationUnitId + '&dataElementId=' + currentDataElementId + '&optionComboId=' + currentOptionComboId;
-	
-	$.get( url, refreshChart );
+    $( '#minLimit' ).val( '' );
+    $( '#maxLimit' ).val( '' );
+
+    var url = 'removeMinMaxLimits.action?organisationUnitId=' + currentOrganisationUnitId + '&dataElementId='
+            + currentDataElementId + '&optionComboId=' + currentOptionComboId;
+
+    $.get( url, refreshChart );
 }
 
 function saveMinMaxLimit()
 {
-	var minValue = $( '#minLimit' ).val();
-	var maxValue = $( '#maxLimit' ).val();
-	
-	if ( !minValue || minValue == '' ) 
-	{
-		return;
-	}
-	else if ( !isInt( minValue ) ) 
-	{
-		$( '#minSpan' ).html( i18n_enter_digits );
-		return;
-	}
-	else 
-	{
-		$( '#minSpan' ).html( '' );
-	}
-	
-	if ( !maxValue || maxValue == '' ) 
-	{
-		return;
-	}
-	else if ( !isInt( maxValue ) ) 
-	{
-		$( '#maxSpan' ).html( i18n_enter_digits );
-		return;
-	}
-	else 
-	{
-		$( '#maxSpan' ).html( '' );
-	}
-	
-	if ( eval(minValue) > eval(maxValue) ) 
-	{
-		$( '#maxSpan' ).html( i18n_max_must_be_greater_than_min );
-		return;
-	}
-	else 
-	{
-		$( '#maxSpan' ).html( '' );
-	}
-	
-	var minId = currentDataElementId + '-' + currentOptionComboId + '-min';
-	var maxId = currentDataElementId + '-' + currentOptionComboId + '-max';
-	
-	currentMinMaxValueMap[minId] = minValue;
-	currentMinMaxValueMap[maxId] = maxValue;
-	
-    var url = 'saveMinMaxLimits.action?organisationUnitId=' + currentOrganisationUnitId + '&dataElementId=' + currentDataElementId + 
-    	'&optionComboId=' + currentOptionComboId + '&minLimit=' + minValue + '&maxLimit=' + maxValue;
-    
+    var minValue = $( '#minLimit' ).val();
+    var maxValue = $( '#maxLimit' ).val();
+
+    if ( !minValue || minValue == '' )
+    {
+        return;
+    }
+    else if ( !isInt( minValue ) )
+    {
+        $( '#minSpan' ).html( i18n_enter_digits );
+        return;
+    }
+    else
+    {
+        $( '#minSpan' ).html( '' );
+    }
+
+    if ( !maxValue || maxValue == '' )
+    {
+        return;
+    }
+    else if ( !isInt( maxValue ) )
+    {
+        $( '#maxSpan' ).html( i18n_enter_digits );
+        return;
+    }
+    else
+    {
+        $( '#maxSpan' ).html( '' );
+    }
+
+    if ( eval( minValue ) > eval( maxValue ) )
+    {
+        $( '#maxSpan' ).html( i18n_max_must_be_greater_than_min );
+        return;
+    }
+    else
+    {
+        $( '#maxSpan' ).html( '' );
+    }
+
+    var minId = currentDataElementId + '-' + currentOptionComboId + '-min';
+    var maxId = currentDataElementId + '-' + currentOptionComboId + '-max';
+
+    currentMinMaxValueMap[minId] = minValue;
+    currentMinMaxValueMap[maxId] = maxValue;
+
+    var url = 'saveMinMaxLimits.action?organisationUnitId=' + currentOrganisationUnitId + '&dataElementId='
+            + currentDataElementId + '&optionComboId=' + currentOptionComboId + '&minLimit=' + minValue + '&maxLimit='
+            + maxValue;
+
     $.get( url, refreshChart );
 }
 
 function refreshChart()
 {
-	var source = 'getHistoryChart.action?dataElementId=' + currentDataElementId + '&categoryOptionComboId=' + currentOptionComboId + '&r=' + Math.random();
-	
-	$( '#historyChart' ).attr( 'src', source );
+    var source = 'getHistoryChart.action?dataElementId=' + currentDataElementId + '&categoryOptionComboId='
+            + currentOptionComboId + '&r=' + Math.random();
+
+    $( '#historyChart' ).attr( 'src', source );
 }
 
 function markValueForFollowup( dataElementId, periodId, sourceId, categoryOptionComboId )
 {
-    var url = 'markValueForFollowup.action?dataElementId=' + dataElementId + '&periodId=' + periodId +
-        '&sourceId=' + sourceId + '&categoryOptionComboId=' + categoryOptionComboId;
-    
-    $.getJSON( url, function( json ) {
-    	
-    	if ( json.message == 'marked' ) {
-    		$( '#followup' ).attr( 'src', '../images/marked.png' );
-    		$( '#followup' ).attr( 'alt', i18n_unmark_value_for_followup );
-    	}
-    	else if ( json.message == 'unmarked' ) {
-    		$( '#followup' ).attr( 'src', '../images/unmarked.png' );
-    		$( '#followup' ).attr( 'alt', i18n_mark_value_for_followup );
-    	}
+    var url = 'markValueForFollowup.action?dataElementId=' + dataElementId + '&periodId=' + periodId + '&sourceId='
+            + sourceId + '&categoryOptionComboId=' + categoryOptionComboId;
+
+    $.getJSON( url, function( json )
+    {
+
+        if ( json.message == 'marked' )
+        {
+            $( '#followup' ).attr( 'src', '../images/marked.png' );
+            $( '#followup' ).attr( 'alt', i18n_unmark_value_for_followup );
+        }
+        else if ( json.message == 'unmarked' )
+        {
+            $( '#followup' ).attr( 'src', '../images/unmarked.png' );
+            $( '#followup' ).attr( 'alt', i18n_mark_value_for_followup );
+        }
     } );
 }