application_parameter = { applications : null }; function application_list() { $('#content').html(''); $.ajax({ type : 'get', dataType : 'json', contentType : 'application/json; charset=utf-8', url : '../jaxrs/applications', xhrFields : { 'withCredentials' : true }, crossDomain : true }).done(function(data) { if (data.type == 'success') { if (data.data && data.data.applicationTypes) { application_parameter.applications = data.data; var str = ''; str += ''; $.each(data.data.applicationTypes, function(index, item) { str += ''; $.each(item.applications, function(index, o) { str += ''; str += ''; str += ''; str += ''; str += ''; str += ''; str += ''; str += ''; }); }); str += '
hostportcontextPathavailableweightoperate
' + item.type + '
' + o.host + '' + o.port + '' + o.contextPath + '' + o.available + '' + o.weight + ''; str += 'edit '; str += '
'; $('#content').html(str); } } else { failure(data); } $('#result').html(JSON.stringify(data.data, null, 4)); }); } function application_edit(token) { $('#result').html(''); var str = ''; str += ''; str += ''; str += ''; str += ''; str += ''; str += ''; str += ''; str += ''; str += ''; str += '
put
token: 
available: 
reportDate: 
contextPath: 
enable:
host:
port:
weight:
'; $('#content').html(str); $('#put', '#content').click(function() { application_put(token); }); $.each(application_parameter.applications.applicationTypes, function(index, item) { $.each(item.applications, function(index, o) { if (o.token == token) { $('#token', '#content').html(o.token); $('#available', '#content').html(o.available + ''); $('#reportDate', '#content').html(o.reportDate); $('#contextPath', '#content').html(o.contextPath); $('#enable', '#content').val(o.enable + ''); $('#host', '#content').val(o.host); $('#port', '#content').val(o.port); $('#weight', '#content').val(o.weight); } }); }); } function application_put(token) { $('#result').html(''); $.ajax({ type : 'put', dataType : 'json', url : '../jaxrs/application/' + token, contentType : 'application/json; charset=utf-8', data : JSON.stringify({ enable : $('#enable', '#content').val(), host : $('#host', '#content').val(), port : $('#port', '#content').val(), weight : $('#weight', '#content').val() }), xhrFields : { 'withCredentials' : true }, crossDomain : true }).done(function(data) { if (data.type == 'success') { application_list(); } else { failure(data); } }); }