Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5048 dpurdie 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'   sdk_names_edit.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  : 'Save',
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
        populateSdkForm(this);
33
        },
34
close : function(event, ui ){
35
        // Need to remove DOM elements on close so that
36
        // When it is opened again - the binds occur correctly
37
        $(this).dialog('destroy').remove();
38
        },
39
});
40
 
41
function setInfo(txt) {
42
    $("#info").text( txt).addClass("error");
43
}
44
 
45
function clearInfo(txt) {
46
    $("#info").text("").removeClass("error");
47
}
48
 
49
$.validate({
50
    form: '#f1',
51
    validateOnBlur : false,
52
    onSuccess : function(f) {
53
        processSdkForm(f);
54
    },
55
 
56
});
57
 
58
// Severe Error processing
59
//  Disable all the inputs on a form
60
//  Hide dialog buttons marked to be hidden
61
//  All the user can do is read the erro message and close the form
62
function disableForm()
63
{   
64
    var form = $("#f1");
65
    form.dialog( "widget" ).find(".hideOnError").hide();
66
    form.find(":input").prop("disabled",true);
67
}
68
 
69
function populateSdkForm(f)
70
{
71
    clearInfo();
72
    $("#progressBar").css('visibility', 'visible');
73
    var postData = { action : "getData", sdkId : <%=Request("sdkId")%> };
74
    var formURL = "sdk_opr_json.asp";
75
    $.ajax(
76
    {
77
        url : formURL,
78
        type: "POST",
79
        data : postData,
80
        dataType : "json",
81
        cache: false,
82
        success:function(data, textStatus, jqXHR)
83
        {
84
            //data: return data from server
85
            clearInfo();
86
            console.log ("PopulateData", data);
87
            if (data.result != 0)
88
            {
89
                setInfo("Error:" + ((data.error != 0) ? data.emsgSummary : "Reason not given"));
90
                if (data.error >= 0) disableForm();
91
                return;
92
            }
93
            $("#sdk_id").val(data.aaData.SDK_ID);
94
            $("#sdk_name").val(data.aaData.SDK_NAME);
95
            $("#sdk_comment").val(data.aaData.SDK_COMMENT);
96
        },
97
        error: function(jqXHR, textStatus, errorThrown)
98
        {
99
            setInfo("Error:" + errorThrown);
100
            disableForm();
101
            //if fails
102
        },
103
        complete : function()
104
        {
105
            $("#progressBar").css('visibility', 'hidden');
106
        }
107
    });
108
}
109
 
110
function processSdkForm(f)
111
{
112
    clearInfo();
113
    $("#progressBar").css('visibility', 'visible');
114
    var postData = f.serializeArray();
115
    var formURL = f.attr("action");
116
    $.ajax(
117
    {
118
        url : formURL,
119
        type: "POST",
120
        data : postData,
121
        dataType : "json",
122
        cache: false,
123
        success:function(data, textStatus, jqXHR)
124
        {
125
            //data: return data from server
126
            //console.log ("UpdateData", data);
127
            if (data.result != 0)
128
            {
129
                setInfo("Error:" + ((data.error != 0) ? data.emsgSummary : "Reason not given"));
130
                if (data.error >= 0) disableForm();
131
                return;
132
            }
5051 dpurdie 133
            $("#sdk_version").trigger('sdkNameEdited');
5048 dpurdie 134
            f.dialog( "close" );
135
        },
136
        error: function(jqXHR, textStatus, errorThrown)
137
        {
138
            setInfo("Error:" + errorThrown);
139
            disableForm();
140
            //if fails
141
        },
142
        complete : function()
143
        {
144
            $("#progressBar").css('visibility', 'hidden');
145
        }
146
    });
147
};
148
 
149
$( "#f1" ).submit(function(e) {
150
        e.preventDefault(); //STOP default action
151
        return false;
152
        });
153
//# sourceURL=sdk_names_edit.js
154
</script>
155
<form title="Edit Entry" id=f1 action="sdk_opr_json.asp" class=td>
156
    <div id="info"></div>
157
	<DIV id='progressBar' style='visibility:hidden;'>
158
        <img src='icons/i_processing.gif' width='79' height='14'>
159
    </DIV>
160
 
161
    <p><label for="sdkName">SDK Name:</label>
5053 dpurdie 162
    <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 163
 
164
    <p>Comment:
165
    <br><textarea id=sdk_comment name="sdkComment" cols=40  data-validation="length" data-validation-length="5-4000"></textarea>                                              
166
 
167
    <input type="hidden" name="action" value="updateEntry">
168
    <input id=sdk_id type="hidden" name="sdkid" value="">
169
</form>