~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/javascript/ga.js

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
// OrgUnit GroupSet Change Function
 
3
function orgUnitGroupSetCB()
 
4
{
 
5
        var orgUnitGroupSetList = document.getElementById( 'orgUnitGroupSetListCB' );
 
6
        var orgUnitList = document.getElementById( 'orgUnitListCB' );
 
7
        if(document.getElementById( 'ougSetCB' ).checked)
 
8
        {
 
9
                orgUnitGroupSetList.disabled = false;
 
10
                getOrgUnitGroups();             
 
11
        }
 
12
        else
 
13
        {
 
14
                orgUnitGroupSetList.disabled = true;
 
15
        }
 
16
        clearList(orgUnitList);
 
17
}
 
18
 
 
19
// Removes slected orgunits from the Organisation List
 
20
function remOUFunction()
 
21
{
 
22
        var index = document.ChartGenerationForm.orgUnitListCB.options.length;
 
23
    var i=0;
 
24
    for(i=index-1;i>=0;i--)
 
25
    {
 
26
        if(document.ChartGenerationForm.orgUnitListCB.options[i].selected)
 
27
        document.ChartGenerationForm.orgUnitListCB.options[i] = null;
 
28
    }
 
29
}// remOUFunction end
 
30
 
 
31
// DataElement and Its options Change Function
 
32
function deSelectionChangeFuntion(evt)
 
33
{
 
34
    var availableDataElements = document.getElementById("availableDataElements");
 
35
    var selectedDataElements = document.getElementById("selectedDataElements");
 
36
 
 
37
        clearList(availableDataElements);
 
38
        clearList(selectedDataElements);
 
39
        
 
40
        getDataElements();
 
41
}
 
42
 
 
43
// Category ListBox Change function
 
44
function categoryChangeFunction(evt)
 
45
{
 
46
        selCategory = evt.target.value;
 
47
        if(selCategory == "period")
 
48
        {
 
49
                document.ChartGenerationForm.facilityLB.disabled = true;
 
50
                var index = document.ChartGenerationForm.orgUnitListCB.options.length;
 
51
        for(i=0;i<index;i++)
 
52
        {
 
53
                document.ChartGenerationForm.orgUnitListCB.options[0] = null;
 
54
        }
 
55
        }
 
56
        else
 
57
        {
 
58
                document.ChartGenerationForm.facilityLB.disabled = false;
 
59
        }
 
60
}// categoryChangeFunction end
 
61
                                  
 
62
//Facility ListBox Change Function
 
63
function facilityChangeFunction(evt)
 
64
{
 
65
        selFacility = evt.target.value;
 
66
        if(selFacility == "children")
 
67
        {
 
68
                var index = document.ChartGenerationForm.orgUnitListCB.options.length;
 
69
        for(i=0;i<index;i++)
 
70
        {
 
71
                document.ChartGenerationForm.orgUnitListCB.options[0] = null;
 
72
        }
 
73
        }
 
74
}// facilityChangeFunction end
 
75
 
 
76
// Indicator or Dataelement radio button changed function
 
77
function riradioSelection(evt)
 
78
{
 
79
        selriRadioButton = evt.target.value;
 
80
    if(selriRadioButton == "dataElementsRadio")
 
81
    {
 
82
                document.ChartGenerationForm.indicatorGroupId.disabled = true;
 
83
            document.ChartGenerationForm.availableIndicators.disabled = true;
 
84
            document.ChartGenerationForm.selectedIndicators.disabled = true;
 
85
            
 
86
            document.ChartGenerationForm.dataElementGroupId.disabled = false;
 
87
            document.ChartGenerationForm.availableDataElements.disabled = false;
 
88
            document.ChartGenerationForm.selectedDataElements.disabled = false;
 
89
        }// if block end
 
90
        else
 
91
        {
 
92
                document.ChartGenerationForm.indicatorGroupId.disabled = false;
 
93
            document.ChartGenerationForm.availableIndicators.disabled = false;
 
94
            document.ChartGenerationForm.selectedIndicators.disabled = false;
 
95
            
 
96
            document.ChartGenerationForm.dataElementGroupId.disabled = true;
 
97
            document.ChartGenerationForm.availableDataElements.disabled = true;
 
98
            document.ChartGenerationForm.selectedDataElements.disabled = true;
 
99
        }// else end
 
100
}// function riradioSelection end
 
101
 
 
102
// Selected Button (ie ViewSummary or ViewChart) Function
 
103
function selButtonFunction(selButton)
 
104
{
 
105
        document.ChartGenerationForm.selectedButton.value = selButton;
 
106
}// selButtonFunction end
 
107
 
 
108
 
 
109
//Graphical Analysis Form Validations
 
110
function formValidations()
 
111
{
 
112
                
 
113
        var selOUListLength = document.ChartGenerationForm.orgUnitListCB.options.length;
 
114
        var selDEListSize  = document.ChartGenerationForm.selectedDataElements.options.length;
 
115
        var selIndListSize  = document.ChartGenerationForm.selectedIndicators.options.length;
 
116
    sDateIndex    = document.ChartGenerationForm.sDateLB.selectedIndex;
 
117
    eDateIndex    = document.ChartGenerationForm.eDateLB.selectedIndex;
 
118
    category = document.ChartGenerationForm.categoryLB.selectedIndex;
 
119
    sDate = document.ChartGenerationForm.sDateLB.options[sDateIndex].text;
 
120
    eDate = document.ChartGenerationForm.eDateLB.options[eDateIndex].text;
 
121
    categoryName = document.ChartGenerationForm.categoryLB.options[category].text;
 
122
 
 
123
    if(selOUListLength <= 0) {alert("Please Select OrganisationUnit");return false;}
 
124
    else if(selriRadioButton == "dataElementsRadio" && selDEListSize <= 0)       {alert("Please Select DataElement(s)");return false;}
 
125
    else if(selriRadioButton == "indicatorsRadio" && selIndListSize <= 0) {alert("Please Select Indicator(s)");return false;}
 
126
    else if(sDateIndex < 0) {alert("Please Select Starting Period");return false;}
 
127
    else if(eDateIndex < 0) {alert("Please Select Ending Period");return false;}
 
128
    else if(category < 0) {alert("Please Select Category");return false;}
 
129
    else if(sDate > eDate) {alert("Starting Date is Greater");return false;}
 
130
 
 
131
        var k=0;
 
132
        if(selriRadioButton == "dataElementsRadio")
 
133
        {
 
134
                for(k=0;k<document.ChartGenerationForm.selectedDataElements.options.length;k++)
 
135
        {
 
136
                document.ChartGenerationForm.selectedDataElements.options[k].selected = true;
 
137
        } // for loop end
 
138
        }
 
139
        else
 
140
        {
 
141
                for(k=0;k<document.ChartGenerationForm.selectedIndicators.options.length;k++)
 
142
        {
 
143
                document.ChartGenerationForm.selectedIndicators.options[k].selected = true;
 
144
        } // for loop end
 
145
    }
 
146
    
 
147
    if(document.getElementById( 'ougSetCB' ).checked)
 
148
    {
 
149
        if(document.ChartGenerationForm.orgUnitListCB.selectedIndex <= -1) 
 
150
                {alert("Please Select OrganisationUnit");return false;}
 
151
    }
 
152
    else
 
153
    {
 
154
        for(k=0;k<selOUListLength;k++)
 
155
        {
 
156
                document.ChartGenerationForm.orgUnitListCB.options[k].selected = true;
 
157
        }
 
158
        }
 
159
        
 
160
    var sWidth = 850;
 
161
        var sHeight = 650;
 
162
    var LeftPosition=(screen.width)?(screen.width-sWidth)/2:100;
 
163
    var TopPosition=(screen.height)?(screen.height-sHeight)/2:100;
 
164
 
 
165
    window.open('','chartWindow1','width=' + sWidth + ', height=' + sHeight + ', ' + 'left=' + LeftPosition + ', top=' + TopPosition + ', ' + 'location=no, menubar=no, ' +  'status=no, toolbar=no, scrollbars=yes, resizable=yes');
 
166
        return true;
 
167
} // formValidations Function End
 
168