centerServer.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. centerServer_parameter = {};
  2. function centerServer_get() {
  3. $('#content').html('');
  4. $('#result').html('');
  5. var str = '<table border="1" width="100%">';
  6. str += '<tr><td colspan="2"><a href="#" id="put">put</a></td></tr>';
  7. str += '<tr><td>host:</td><td><input type="text" style="width:95%" id="host"/></td></tr>';
  8. str += '<tr><td>port:</td><td><input type="text" style="width:95%" id="port"/></td></tr>';
  9. str += '<tr><td>cipher:</td><td><input type="text" style="width:95%" id="cipher"/></td></tr>';
  10. str += '<tr><td>proxyHost:</td><td><input type="text" style="width:95%" id="proxyHost"/></td></tr>';
  11. str += '<tr><td>proxyPort:</td><td><input type="text" style="width:95%" id="proxyPort"/></td></tr>';
  12. str += '</table>';
  13. $('#content').html(str);
  14. $.ajax({
  15. type : 'get',
  16. dataType : 'json',
  17. contentType : 'application/json; charset=utf-8',
  18. url : '../jaxrs/centerserver',
  19. xhrFields : {
  20. 'withCredentials' : true
  21. },
  22. crossDomain : true
  23. }).done(function(json) {
  24. $('#result').html(JSON.stringify(json, null, 4));
  25. if (json.type == 'success') {
  26. if (json.data) {
  27. $('#host').val(json.data.host);
  28. $('#port').val(json.data.port);
  29. $('#cipher').val(json.data.cipher);
  30. $('#proxyHost').val(json.data.proxyHost);
  31. $('#proxyPort').val(json.data.proxyPort);
  32. }
  33. } else {
  34. failure(json);
  35. }
  36. });
  37. $('#put').click(function() {
  38. centerServer_put();
  39. });
  40. }
  41. function centerServer_put() {
  42. $('#result').html('');
  43. $.ajax({
  44. type : 'put',
  45. dataType : 'json',
  46. url : '../jaxrs/centerserver',
  47. contentType : 'application/json; charset=utf-8',
  48. data : JSON.stringify({
  49. host : $('#host').val(),
  50. port : $('#port').val(),
  51. cipher : $('#cipher').val(),
  52. proxyHost : $('#proxyHost').val(),
  53. proxyPort : $('#proxyPort').val()
  54. }),
  55. xhrFields : {
  56. 'withCredentials' : true
  57. },
  58. crossDomain : true
  59. }).done(function(json) {
  60. $('#result').html(JSON.stringify(json, null, 4));
  61. });
  62. }