templateForm.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. templateForm_parameter = {};
  2. function templateForm_list_category() {
  3. $('#result').html('');
  4. $('#content').html('');
  5. $.ajax({
  6. type : 'get',
  7. dataType : 'json',
  8. url : '../jaxrs/templateform/list/category',
  9. xhrFields : {
  10. 'withCredentials' : true
  11. },
  12. crossDomain : true
  13. }).always(function(json) {
  14. $('#result').html(JSON.stringify(json, null, 4));
  15. });
  16. }
  17. function templateForm_list() {
  18. $('#result').html('');
  19. $('#content').html('');
  20. $.ajax({
  21. type : 'get',
  22. dataType : 'json',
  23. url : '../jaxrs/templateform/list',
  24. xhrFields : {
  25. 'withCredentials' : true
  26. },
  27. crossDomain : true
  28. }).always(function(json) {
  29. $('#result').html(JSON.stringify(json, null, 4));
  30. });
  31. }
  32. function templateForm_init() {
  33. $('#result').html('');
  34. $('#content').html('');
  35. var str = '<table border="1" width="100%">';
  36. str += '<tr><td colspan="2"><a href="#" id="listWithCategory">listWithCategory</a>&nbsp;<a href="#" id="get">get</a>&nbsp;<a href="#" id="concreteFromForm">concreteFromForm</a>&nbsp;<a href="#" id="delete">delete</a></td></tr>';
  37. str += '<tr><td>id:</td><td><input type="text" id="id" style="width:95%"/></td></tr>';
  38. str += '<tr><td>formId:</td><td><input type="text" id="formId" style="width:95%"/></td></tr>';
  39. str += '<tr><td>category:</td><td><input type="text" id="category" style="width:95%"/></td></tr>';
  40. str += '<tr><td>name:</td><td><input type="text" id="name" style="width:95%"/></td></tr>';
  41. str += '</table>';
  42. $('#content').html(str);
  43. $('#listWithCategory').click(function() {
  44. templateForm_listWithCategory($('#category').val());
  45. });
  46. $('#get').click(function() {
  47. templateForm_get($('#id').val());
  48. });
  49. $('#concreteFromForm').click(function() {
  50. templateForm_concrete($('#formId').val(), $('#category').val(), $('#name').val());
  51. });
  52. $('#delete').click(function() {
  53. templateForm_delete($('#id').val());
  54. });
  55. }
  56. function templateForm_listWithCategory(category) {
  57. $('#result').html('');
  58. $.ajax({
  59. type : 'put',
  60. dataType : 'json',
  61. url : '../jaxrs/templateform/list/category',
  62. contentType : 'application/json; charset=utf-8',
  63. xhrFields : {
  64. 'withCredentials' : true
  65. },
  66. data : JSON.stringify({
  67. category : category
  68. }),
  69. crossDomain : true
  70. }).always(function(json) {
  71. $('#result').html(JSON.stringify(json, null, 4));
  72. });
  73. }
  74. function templateForm_get(id) {
  75. $('#result').html('');
  76. $.ajax({
  77. type : 'get',
  78. dataType : 'json',
  79. url : '../jaxrs/templateform/' + id,
  80. contentType : 'application/json; charset=utf-8',
  81. xhrFields : {
  82. 'withCredentials' : true
  83. },
  84. crossDomain : true
  85. }).always(function(json) {
  86. $('#result').html(JSON.stringify(json, null, 4));
  87. });
  88. }
  89. function templateForm_create_init() {
  90. str = '<table border="1" width="100%">';
  91. str += '<tr><td colspan="2"><a href="#" id="post">post</a></td></tr>';
  92. str += '<tr><td>name:</td><td><input type="text" id="name" style="width:95%"/></td></tr>';
  93. str += '<tr><td>category:</td><td><input type="text" id="category" style="width:95%"/></td></tr>';
  94. str += '<tr><td>alias:</td><td><input type="text" id="alias" style="width:95%"/></td></tr>';
  95. str += '<tr><td>description:</td><td><textarea id="description" style="width:95%"/></td></tr>';
  96. str += '<tr><td>icon:</td><td><textarea id="icon" style="width:95%"/></td></tr>';
  97. str += '<tr><td colspan="2">data:</td></tr>';
  98. str += '<tr><td colspan="2"><textarea id="data" style="width:95%;height:500px"/></td></tr>';
  99. str += '<tr><td colspan="2">mobileData:</td></tr>';
  100. str += '<tr><td colspan="2"><textarea id="mobileData" style="width:95%;height:500px"/></td></tr>';
  101. str += '</table>';
  102. $('#content').html(str);
  103. $('#post').click(function() {
  104. templateForm_post();
  105. });
  106. }
  107. function templateForm_post() {
  108. $.ajax({
  109. type : 'post',
  110. dataType : 'json',
  111. contentType : 'application/json; charset=utf-8',
  112. url : '../jaxrs/templateform',
  113. data : JSON.stringify({
  114. name : $('#name').val(),
  115. category : $('#category').val(),
  116. alias : $('#alias').val(),
  117. description : $('#description').val(),
  118. icon : $('#icon').val(),
  119. data : $('#data').val(),
  120. mobileData : $('#mobileData').val()
  121. }),
  122. xhrFields : {
  123. 'withCredentials' : true
  124. },
  125. crossDomain : true
  126. }).always(function(json) {
  127. $('#result').html(JSON.stringify(json, null, 4));
  128. });
  129. }
  130. function templateForm_delete(id) {
  131. $('#result').html('');
  132. $.ajax({
  133. type : 'delete',
  134. dataType : 'json',
  135. url : '../jaxrs/templateform/' + id,
  136. contentType : 'application/json; charset=utf-8',
  137. xhrFields : {
  138. 'withCredentials' : true
  139. },
  140. crossDomain : true
  141. }).always(function(json) {
  142. $('#result').html(JSON.stringify(json, null, 4));
  143. });
  144. }