Subversion Repositories DevTools

Rev

Rev 5102 | Rev 7287 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5048 dpurdie 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'   sdk_names_new.asp
4
'   This file is designed to be injected (loaded) into a 'div' on a window
5
'   It is a pop up dialog
6
%>
7
<script>
8
$( "#f1" ).dialog({
9
    autoOpen: true,
10
    width: 500,
5102 dpurdie 11
    position: { my: "top", at: "top+100", of: window },
5048 dpurdie 12
    modal: true,
13
    draggable: true,
14
    resizable: true,
15
    dialogClass: "rounded_box",
16
        buttons: [
17
            {
18
            text  : 'Add',
19
            class : 'hideOnError',
20
            click : function(){
21
                        clearInfo();
22
                        $( "#f1" ).submit();
23
                        },
24
            },
25
            {
26
            text : 'Cancel',
27
            click : function(){ 
28
                        $( this ).dialog( "close" ); 
29
                        },
30
            },
31
        ],
32
    open: function( event, ui ) {
5102 dpurdie 33
        populateProjects();
5048 dpurdie 34
        },
35
    close : function(event, ui ){
36
        // Need to remove DOM elements on close so that
37
        // When it is opened again - the binds occur correctly
38
        $(this).dialog('destroy').remove();
39
        },
40
    });
41
 
5102 dpurdie 42
//  Populate the Projects dropdown
43
function populateProjects() {
44
    getAjaxData (
45
        "sdk_opr_json.asp",
46
        { action: "getProjectList" },
47
        function(data){
48
            // Populate selection
49
            var $options = $("#sdk_projects").empty();
50
            var name
51
            $options.append($("<option disabled selected/>").val(null).text('Select One'));
52
            $.each(data.aaData, function (index, value) {
53
                $options.append($("<option />").val(value.PROJ_ID).text(value.PROJ_NAME));
54
            });
55
        });    
56
}
57
 
58
 
5048 dpurdie 59
function setInfo(txt) {
60
    $("#info").text( txt).addClass("error");
61
}
62
 
63
function clearInfo(txt) {
64
    $("#info").text("").removeClass("error");
65
}
66
 
67
$.validate({
68
    form: '#f1',
69
    validateOnBlur : false,
70
    onSuccess : function(f) {
71
        processSdkForm(f);
72
    },
73
});
74
 
75
// Severe Error processing
76
//  Disable all the inputs on a form
77
//  Hide dialog buttons marked to be hidden
78
//  All the user can do is read the erro message and close the form
79
function disableForm()
80
{   
81
    var form = $("#f1");
82
    form.dialog( "widget" ).find(".hideOnError").hide();
83
    form.find(":input").prop("disabled",true);
84
}
85
 
86
function processSdkForm(f)
87
{
5097 dpurdie 88
    getAjaxData (
89
        "sdk_opr_json.asp",
90
        f.serializeArray(),
91
        function(data){
92
            $("#sdk_version").trigger('sdkNameEdited');
93
            f.dialog( "close" );
94
        });    
95
}
96
 
97
$( "#f1" ).submit(function(e) {
98
        e.preventDefault(); //STOP default action
99
        return false;
100
        });
101
 
102
//  getAjaxData - with error processing
103
//      url - url to fetch
104
//      data    - additional data to pass to ajax request
105
//      success - function to call on success
106
function getAjaxData( url, data, success )
107
{
5048 dpurdie 108
    clearInfo();
109
    $("#progressBar").css('visibility', 'visible');
110
    $.ajax(
111
    {
5097 dpurdie 112
        url : url,
5048 dpurdie 113
        type: "POST",
5097 dpurdie 114
        data : data,
5048 dpurdie 115
        dataType : "json",
116
        cache: false,
117
        success:function(data, textStatus, jqXHR)
118
        {
119
            //data: return data from server
120
            //console.log ("UpdateData", data);
121
            if (data.result != 0)
122
            {
123
                setInfo("Error:" + ((data.error != 0) ? data.emsgSummary : "Reason not given"));
124
                if (data.error >= 0) disableForm();
125
                return;
126
            }
5097 dpurdie 127
            //  call user success function
128
            if (jQuery.isFunction(success))
129
            {
130
                success(data);
131
            }
5048 dpurdie 132
        },
133
        error: function(jqXHR, textStatus, errorThrown)
134
        {
135
            setInfo("Error:" + errorThrown);
136
            //if fails
137
        },
138
        complete : function()
139
        {
140
            $("#progressBar").css('visibility', 'hidden');
141
        }
142
    });
143
 
5097 dpurdie 144
}
5048 dpurdie 145
 
5097 dpurdie 146
 
5048 dpurdie 147
//# sourceURL=sdk_names_new.asp
148
</script>
149
<form title="Add New SDK Family" id=f1 action="sdk_opr_json.asp" class=td>
150
    <div id="info"></div>
151
	<DIV id='progressBar' style='visibility:hidden;'>
152
        <img src='icons/i_processing.gif' width='79' height='14'>
153
    </DIV>
154
 
155
    <p><label for="sdkName">SDK Name:</label>
5053 dpurdie 156
    <br><input id=sdk_name type="text" name="sdkName" maxlength=50 size=40 data-validation="length,alphanumeric" data-validation-length="min4" data-validation-allowing="_. -">
5048 dpurdie 157
 
158
    <p>Comment:
159
    <br><textarea id=sdk_comment name="sdkComment" cols=40  data-validation="length" data-validation-length="5-4000"></textarea>                                              
5097 dpurdie 160
 
5102 dpurdie 161
    <p>Project:
162
    <br><select id=sdk_projects name="sdkProject" data-validation="required"></select>                                              
163
 
5097 dpurdie 164
    <input type="hidden" name="action" value="addSdkName">
5048 dpurdie 165
</form>
166