function connection_list_init() {
$('#result').html('');
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/connection/list/connectiontype',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(data) {
if (data.type == 'success') {
var str = '
';
str += '| type | list |
| |
';
$('#content').html(str);
$('#list', '#content').click(function() {
connection_list($('#type', '#content').val());
});
$('#result').html(JSON.stringify(data.data, null, 4));
} else {
failure(data);
}
});
}
function connection_list(connectionType) {
$('#grid').html('');
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/connection/list/connectiontype/' + connectionType,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(data) {
if (data.type == 'success') {
var str = '';
str += '| url | username | operate |
';
if (data.data) {
$.each(data.data, function(typeIndex, item) {
str += '';
str += '| ' + item.url + ' | ';
str += '' + item.username + ' | ';
str += '';
str += 'edit ';
str += 'delete ';
str += ' | ';
str += '
';
});
}
str += '
';
$('#grid').html(str);
$('#result').html(JSON.stringify(data.data, null, 4));
} else {
failure(data);
}
});
}
function connection_edit(connectionType, order) {
$('#result').html('');
$('#content').html('');
var str = '';
$('#content').html(str);
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/connection/connectiontype/' + connectionType + '/order/' + order,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(data) {
if (data.type == 'success') {
$('#url', '#content').val(data.data.url);
$('#username', '#content').val(data.data.username);
$('#password', '#content').val(data.data.password);
$('#enable', '#content').val(data.data.enable + '');
$('#order', '#content').val(data.data.order);
} else {
failure(data);
}
$('#result').html(JSON.stringify(data.data, null, 4));
});
$('#put', '#content').click(function() {
connection_put(connectionType, order);
});
}
function connection_put(connectionType, order) {
$('#result').html('');
$.ajax({
type : 'put',
dataType : 'json',
url : '../jaxrs/connection/connectiontype/' + connectionType + '/order/' + order,
contentType : 'application/json; charset=utf-8',
data : JSON.stringify({
url : $('#url', '#content').val(),
username : $('#username', '#content').val(),
password : $('#password', '#content').val(),
order : $('#order', '#content').val(),
enable : $('#enable', '#content').val(),
}),
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(data) {
if (data.type == 'success') {
} else {
failure(data);
}
$('#result').html(JSON.stringify(data.data, null, 4));
});
}
function connection_create_init() {
$('#result').html('');
var str = '';
$('#content').html(str);
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/connection/list/connectiontype',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(data) {
if (data.type == 'success') {
if (data.data) {
var str = '';
$.each(data.data, function(typeIndex, type) {
str += '';
});
}
$('#type').html(str);
$('#result').html(JSON.stringify(data.data, null, 4));
} else {
failure(data);
}
});
$('#post', '#content').click(function() {
connection_post($('#type', '#content').val());
});
}
function connection_post(connectionType) {
$.ajax({
type : 'post',
dataType : 'json',
url : '../jaxrs/connection/connectiontype/' + connectionType,
contentType : 'application/json; charset=utf-8',
data : JSON.stringify({
url : $('#url', '#content').val(),
username : $('#username', '#content').val(),
password : $('#password', '#content').val(),
enable : $('#enable', '#content').val()
}),
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(data) {
if (data.type == 'success') {
} else {
failure(data);
}
$('#result').html(JSON.stringify(data.data, null, 4));
});
}
function connection_update() {
var str = '';
$('#content').html(str);
$('#put', '#content').click(function() {
connection_put();
});
}
function connection_delete(connectionType, order) {
$.ajax({
type : 'delete',
dataType : 'json',
url : '../jaxrs/connection/connectiontype/' + connectionType + '/order/' + order,
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(data) {
if (data.type == 'success') {
} else {
failure(data);
}
$('#result').html(JSON.stringify(data.data, null, 4));
});
}
function connection_createForEach_init() {
$('#result').html('');
var str = '';
$('#content').html(str);
$('#post', '#content').click(function() {
connection_postForEach();
});
}
function connection_postForEach() {
$.ajax({
type : 'post',
dataType : 'json',
url : '../jaxrs/connection/connectiontype/all/type',
contentType : 'application/json; charset=utf-8',
data : JSON.stringify({
url : $('#url', '#content').val(),
username : $('#username', '#content').val(),
password : $('#password', '#content').val(),
enable : $('#enable', '#content').val()
}),
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(data) {
if (data.type == 'success') {
} else {
failure(data);
}
$('#result').html(JSON.stringify(data.data, null, 4));
});
}