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

« back to all changes in this revision

Viewing changes to dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/config.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
// -------------------------------------------------------------------------
 
3
// Dhis14 Configuration
 
4
// -------------------------------------------------------------------------
 
5
 
 
6
function validateConfigDhis14()
 
7
{
 
8
    var dataFile = htmlEncode( document.getElementById( "dataFile" ).value );
 
9
    
 
10
    var request = new Request();
 
11
    request.setResponseTypeXML( "message" );
 
12
    request.setCallbackSuccess( configDhis14Received );
 
13
    request.send( "validateConfigDhis14.action?dataFile=" + dataFile );
 
14
}
 
15
 
 
16
function configDhis14Received( messageElement )
 
17
{
 
18
    var message = getRootElementValue( messageElement );
 
19
    var type = getRootElementAttribute( messageElement, "type" );
 
20
    
 
21
    if ( type == "input" )
 
22
    {
 
23
        setMessage( message );
 
24
    }
 
25
    else
 
26
    {
 
27
        document.getElementById( "configForm" ).submit();
 
28
    }
 
29
}
 
30
 
 
31
// -------------------------------------------------------------------------
 
32
// IXF Configuration
 
33
// -------------------------------------------------------------------------
 
34
 
 
35
function addLevel()
 
36
{
 
37
    var list = document.getElementById( "levelNames" );
 
38
    var field = document.getElementById( "levelName" );
 
39
    
 
40
    var option = new Option( field.value, field.value );
 
41
    
 
42
    list.add( option, null );
 
43
}
 
44
 
 
45
function deleteLevel()
 
46
{
 
47
    var list = document.getElementById( "levelNames" );
 
48
    
 
49
    for ( var i = list.length - 1; i >= 0; i-- )
 
50
    {
 
51
        if ( list.options[ i ].selected )
 
52
        {
 
53
            list.remove( i );
 
54
        }
 
55
    }
 
56
}
 
57
 
 
58
function moveLevelUp()
 
59
{
 
60
    var list = document.getElementById( "levelNames" );
 
61
    
 
62
    for ( var i = 0; i < list.length; i++ )
 
63
    {
 
64
        if ( list.options[ i ].selected )
 
65
        {
 
66
            if ( i > 0 )
 
67
            {
 
68
                var precedingOption = new Option( list.options[ i - 1 ].text, list.options[ i - 1 ].value );
 
69
                var currentOption = new Option( list.options[ i ].text, list.options[ i ].value );
 
70
                
 
71
                list.options[ i - 1 ] = currentOption;
 
72
                list.options[ i - 1 ].selected = true;
 
73
                list.options[ i ] = precedingOption;
 
74
            }
 
75
        }
 
76
    }
 
77
}
 
78
 
 
79
function moveLevelDown()
 
80
{
 
81
    var list = document.getElementById( "levelNames" );
 
82
    
 
83
    for ( var i = list.options.length - 1; i >= 0; i-- )
 
84
    {
 
85
        if ( list.options[ i ].selected )
 
86
        {
 
87
            if ( i <= list.options.length - 1 )
 
88
            {
 
89
                var subsequentOption = new Option( list.options[ i + 1 ].text, list.options[ i + 1 ].value );
 
90
                var currentOption = new Option( list.options[ i ].text, list.options[ i ].value );
 
91
                
 
92
                list.options[ i + 1 ] = currentOption;
 
93
                list.options[ i + 1 ].selected = true;
 
94
                list.options[ i ] = subsequentOption;
 
95
            }
 
96
        }
 
97
    }
 
98
}
 
99
 
 
100
function submitConfigForm()
 
101
{
 
102
        selectAll( document.getElementById( "levelNames" ) );
 
103
        
 
104
        document.getElementById( "configForm" ).submit();
 
105
}