Subversion Repositories DevTools

Rev

Go to most recent revision | Details | 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,
11
    modal: true,
12
    draggable: true,
13
    resizable: true,
14
    dialogClass: "rounded_box",
15
        buttons: [
16
            {
17
            text  : 'Add',
18
            class : 'hideOnError',
19
            click : function(){
20
                        clearInfo();
21
                        $( "#f1" ).submit();
22
                        },
23
            },
24
            {
25
            text : 'Cancel',
26
            click : function(){ 
27
                        $( this ).dialog( "close" ); 
28
                        },
29
            },
30
        ],
31
    open: function( event, ui ) {
32
        },
33
    close : function(event, ui ){
34
        // Need to remove DOM elements on close so that
35
        // When it is opened again - the binds occur correctly
36
        $(this).dialog('destroy').remove();
37
        },
38
    });
39
 
40
function setInfo(txt) {
41
    $("#info").text( txt).addClass("error");
42
}
43
 
44
function clearInfo(txt) {
45
    $("#info").text("").removeClass("error");
46
}
47
 
48
$.validate({
49
    form: '#f1',
50
    validateOnBlur : false,
51
    onSuccess : function(f) {
52
        processSdkForm(f);
53
    },
54
});
55
 
56
// Severe Error processing
57
//  Disable all the inputs on a form
58
//  Hide dialog buttons marked to be hidden
59
//  All the user can do is read the erro message and close the form
60
function disableForm()
61
{   
62
    var form = $("#f1");
63
    form.dialog( "widget" ).find(".hideOnError").hide();
64
    form.find(":input").prop("disabled",true);
65
}
66
 
67
function processSdkForm(f)
68
{
5097 dpurdie 69
    getAjaxData (
70
        "sdk_opr_json.asp",
71
        f.serializeArray(),
72
        function(data){
73
            $("#sdk_version").trigger('sdkNameEdited');
74
            f.dialog( "close" );
75
        });    
76
}
77
 
78
$( "#f1" ).submit(function(e) {
79
        e.preventDefault(); //STOP default action
80
        return false;
81
        });
82
 
83
//  getAjaxData - with error processing
84
//      url - url to fetch
85
//      data    - additional data to pass to ajax request
86
//      success - function to call on success
87
function getAjaxData( url, data, success )
88
{
5048 dpurdie 89
    clearInfo();
90
    $("#progressBar").css('visibility', 'visible');
91
    $.ajax(
92
    {
5097 dpurdie 93
        url : url,
5048 dpurdie 94
        type: "POST",
5097 dpurdie 95
        data : data,
5048 dpurdie 96
        dataType : "json",
97
        cache: false,
98
        success:function(data, textStatus, jqXHR)
99
        {
100
            //data: return data from server
101
            //console.log ("UpdateData", data);
102
            if (data.result != 0)
103
            {
104
                setInfo("Error:" + ((data.error != 0) ? data.emsgSummary : "Reason not given"));
105
                if (data.error >= 0) disableForm();
106
                return;
107
            }
5097 dpurdie 108
            //  call user success function
109
            if (jQuery.isFunction(success))
110
            {
111
                success(data);
112
            }
5048 dpurdie 113
        },
114
        error: function(jqXHR, textStatus, errorThrown)
115
        {
116
            setInfo("Error:" + errorThrown);
117
            //if fails
118
        },
119
        complete : function()
120
        {
121
            $("#progressBar").css('visibility', 'hidden');
122
        }
123
    });
124
 
5097 dpurdie 125
}
5048 dpurdie 126
 
5097 dpurdie 127
 
5048 dpurdie 128
//# sourceURL=sdk_names_new.asp
129
</script>
130
<form title="Add New SDK Family" id=f1 action="sdk_opr_json.asp" class=td>
131
    <div id="info"></div>
132
	<DIV id='progressBar' style='visibility:hidden;'>
133
        <img src='icons/i_processing.gif' width='79' height='14'>
134
    </DIV>
135
 
136
    <p><label for="sdkName">SDK Name:</label>
5053 dpurdie 137
    <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 138
 
139
    <p>Comment:
140
    <br><textarea id=sdk_comment name="sdkComment" cols=40  data-validation="length" data-validation-length="5-4000"></textarea>                                              
5097 dpurdie 141
 
142
    <input type="hidden" name="action" value="addSdkName">
5048 dpurdie 143
</form>
144