read.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. read_parameter = {
  2. first : '(0)',
  3. last : '(0)',
  4. count : 20
  5. };
  6. function read_list_init() {
  7. var str = '<table border="1" width="100%">';
  8. str += '<thead><tr><td colspan="6"><a href="#" id="prev">prev</a>&nbsp;<a href="#" id="next">next</a>&nbsp;<span id="total">0</span></td></tr>';
  9. str += '<tr><th>rank</th><th>id</th><th>title</th><th>processName</th></tr></thead>';
  10. str += '<tbody id="grid"></tbody>'
  11. str += '</table>';
  12. $('#content').html(str);
  13. $('#next').click(function() {
  14. read_list_next();
  15. });
  16. $('#prev').click(function() {
  17. read_list_prev();
  18. });
  19. read_parameter.first = '(0)';
  20. read_parameter.last = '(0)';
  21. read_list_next();
  22. }
  23. function read_list_next(id) {
  24. var id = (id ? id : read_parameter.last);
  25. $.ajax({
  26. type : 'get',
  27. dataType : 'json',
  28. url : '../jaxrs/read/list/' + id + '/next/' + read_parameter.count,
  29. xhrFields : {
  30. 'withCredentials' : true
  31. },
  32. crossDomain : true
  33. }).done(function(json) {
  34. if (json.type == 'success') {
  35. if (json.data.length > 0) {
  36. read_parameter.first = json.data[0].id;
  37. read_parameter.last = json.data[json.data.length - 1].id;
  38. } else {
  39. read_parameter.first = '(0)';
  40. }
  41. read_list_grid(json);
  42. }
  43. }).always(function(json) {
  44. $('#result').html(JSON.stringify(json, null, 4));
  45. });
  46. }
  47. function read_list_prev(id) {
  48. var id = (id ? id : read_parameter.first);
  49. $.ajax({
  50. type : 'get',
  51. dataType : 'json',
  52. url : '../jaxrs/read/list/' + id + '/prev/' + read_parameter.count,
  53. xhrFields : {
  54. 'withCredentials' : true
  55. },
  56. crossDomain : true
  57. }).done(function(json) {
  58. if (json.type == 'success') {
  59. if (json.data.length > 0) {
  60. read_parameter.first = json.data[0].id;
  61. read_parameter.last = json.data[json.data.length - 1].id;
  62. } else {
  63. read_parameter.last = '(0)';
  64. }
  65. read_list_grid(json);
  66. }
  67. }).always(function(json) {
  68. $('#result').html(JSON.stringify(json, null, 4));
  69. });
  70. }
  71. function read_listWithApplication_init() {
  72. var str = '<table border="1" width="100%">';
  73. str += '<thead><tr><td colspan="4"><a href="#" id="prev">prev</a>&nbsp;<a href="#" id="next">next</a>&nbsp;<span id="total">0</span></td></tr>';
  74. str += '<tr><th>applicationFlag</th><th colspan="3"><input type="text" id="applicationFlag" style="width:95%"/></th></tr>';
  75. str += '<tr><th>rank</th><th>id</th><th>title</th><th>processName</th></tr></thead>';
  76. str += '<tbody id="grid"></tbody>'
  77. str += '</table>';
  78. $('#content').html(str);
  79. $('#next').click(function() {
  80. read_listWithApplication_next();
  81. });
  82. $('#prev').click(function() {
  83. read_listWithApplication_prev();
  84. });
  85. read_parameter.first = '(0)';
  86. read_parameter.last = '(0)';
  87. }
  88. function read_listWithApplication_next(id) {
  89. var id = (id ? id : read_parameter.last);
  90. $.ajax({
  91. type : 'get',
  92. dataType : 'json',
  93. url : '../jaxrs/read/list/' + read_parameter.last + '/next/' + read_parameter.count + '/application/' + $('#applicationFlag').val(),
  94. xhrFields : {
  95. 'withCredentials' : true
  96. },
  97. crossDomain : true
  98. }).done(function(json) {
  99. if (json.type == 'success') {
  100. if (json.data.length > 0) {
  101. read_parameter.first = json.data[0].id;
  102. read_parameter.last = json.data[json.data.length - 1].id;
  103. } else {
  104. read_parameter.first = '(0)';
  105. }
  106. read_list_grid(json);
  107. }
  108. }).always(function(json) {
  109. $('#result').html(JSON.stringify(json, null, 4));
  110. });
  111. }
  112. function read_listWithApplication_prev(id) {
  113. var id = (id ? id : read_parameter.first);
  114. $.ajax({
  115. type : 'get',
  116. dataType : 'json',
  117. url : '../jaxrs/read/list/' + id + '/prev/' + read_parameter.count + '/application/' + $('#applicationFlag').val(),
  118. xhrFields : {
  119. 'withCredentials' : true
  120. },
  121. crossDomain : true
  122. }).done(function(json) {
  123. if (json.type == 'success') {
  124. if (json.data.length > 0) {
  125. read_parameter.first = json.data[0].id;
  126. read_parameter.last = json.data[json.data.length - 1].id;
  127. } else {
  128. read_parameter.last = '(0)';
  129. }
  130. read_list_grid(json);
  131. }
  132. }).always(function(json) {
  133. $('#result').html(JSON.stringify(json, null, 4));
  134. });
  135. }
  136. function read_listWithProcess_init() {
  137. var str = '<table border="1" width="100%">';
  138. str += '<thead><tr><td colspan="4"><a href="#" id="prev">prev</a>&nbsp;<a href="#" id="next">next</a>&nbsp;<span id="total">0</span></td></tr>';
  139. str += '<tr><th>processFlag</th><th colspan="3"><input type="text" id="processFlag" style="width:95%"/></th></tr>';
  140. str += '<tr><th>rank</th><th>id</th><th>title</th><th>processName</th></tr></thead>';
  141. str += '<tbody id="grid"></tbody>'
  142. str += '</table>';
  143. $('#content').html(str);
  144. $('#next').click(function() {
  145. read_listWithProcess_next();
  146. });
  147. $('#prev').click(function() {
  148. read_listWithProcess_prev();
  149. });
  150. read_parameter.first = '(0)';
  151. read_parameter.last = '(0)';
  152. }
  153. function read_listWithProcess_next(id) {
  154. var id = (id ? id : read_parameter.last);
  155. $.ajax({
  156. type : 'get',
  157. dataType : 'json',
  158. url : '../jaxrs/read/list/' + id + '/next/' + read_parameter.count + '/process/' + $('#processFlag').val(),
  159. xhrFields : {
  160. 'withCredentials' : true
  161. },
  162. crossDomain : true
  163. }).done(function(json) {
  164. if (json.type == 'success') {
  165. if (json.data.length > 0) {
  166. read_parameter.first = json.data[0].id;
  167. read_parameter.last = json.data[json.data.length - 1].id;
  168. } else {
  169. read_parameter.first = '(0)';
  170. }
  171. read_list_grid(json);
  172. }
  173. }).always(function(json) {
  174. $('#result').html(JSON.stringify(json, null, 4));
  175. });
  176. }
  177. function read_listWithProcess_prev(id) {
  178. var id = (id ? id : read_parameter.first);
  179. $.ajax({
  180. type : 'get',
  181. dataType : 'json',
  182. url : '../jaxrs/read/list/' + id + '/prev/' + read_parameter.count + '/process/' + $('#processFlag').val(),
  183. xhrFields : {
  184. 'withCredentials' : true
  185. },
  186. crossDomain : true
  187. }).done(function(json) {
  188. if (json.type == 'success') {
  189. if (json.data.length > 0) {
  190. read_parameter.first = json.data[0].id;
  191. read_parameter.last = json.data[json.data.length - 1].id;
  192. } else {
  193. read_parameter.last = '(0)';
  194. }
  195. read_list_grid(json);
  196. }
  197. }).always(function(json) {
  198. $('#result').html(JSON.stringify(json, null, 4));
  199. });
  200. }
  201. function read_list_grid(json) {
  202. if (json.data && json.data.length > 0) {
  203. str = '';
  204. $.each(json.data, function(index, item) {
  205. str += '<tr>';
  206. str += '<td>' + item.rank + '</td>';
  207. str += '<td>' + item.id + '</td>';
  208. str += '<td>' + item.title + '</td>';
  209. str += '<td>' + item.processName + '</td>';
  210. str += '</tr>';
  211. });
  212. $('#total').html(json.count);
  213. $('#grid').html(str);
  214. } else {
  215. $('#total').html('0');
  216. $('#grid').html('');
  217. }
  218. }
  219. function read_listCountWithApplication() {
  220. $('#result').html('');
  221. $('#content').html('');
  222. $.ajax({
  223. type : 'get',
  224. dataType : 'json',
  225. url : '../jaxrs/read/list/count/application',
  226. xhrFields : {
  227. 'withCredentials' : true
  228. },
  229. crossDomain : true
  230. }).always(function(json) {
  231. $('#result').html(JSON.stringify(json, null, 4));
  232. });
  233. }
  234. function read_listCountWithProcess_init() {
  235. $('#result').html('');
  236. str = '<table border="1" width="100%">';
  237. str += '<tr><td colspan="2"><a href="#" id="get">get</a></td></tr>';
  238. str += '<tr><td>applicationFlag:</td><td><input type="text" id="applicationFlag" style="width:95%"/></td></tr>';
  239. str += '</table>';
  240. $('#content').html(str);
  241. $('#get').click(function() {
  242. read_listCountWithProcess();
  243. });
  244. }
  245. function read_listCountWithProcess() {
  246. $('#result').html('');
  247. $('#content').html('');
  248. $.ajax({
  249. type : 'get',
  250. dataType : 'json',
  251. url : '../jaxrs/read/list/count/application/' + $('#applicationFlag').val() + '/process',
  252. xhrFields : {
  253. 'withCredentials' : true
  254. },
  255. crossDomain : true
  256. }).always(function(json) {
  257. $('#result').html(JSON.stringify(json, null, 4));
  258. });
  259. }
  260. function read_countWithPerson_init() {
  261. $('#result').html('');
  262. str = '<table border="1" width="100%">';
  263. str += '<tr><td colspan="2"><a href="#" id="get">get</a></td></tr>';
  264. str += '<tr><td>person:</td><td><input type="text" id="person" style="width:95%"/></td></tr>';
  265. str += '</table>';
  266. $('#content').html(str);
  267. $('#get').click(function() {
  268. read_countWithPerson();
  269. });
  270. }
  271. function read_countWithPerson() {
  272. $('#result').html('');
  273. $('#content').html('');
  274. $.ajax({
  275. type : 'get',
  276. dataType : 'json',
  277. url : '../jaxrs/read/count/' + $('#person').val(),
  278. xhrFields : {
  279. 'withCredentials' : true
  280. },
  281. crossDomain : true
  282. }).always(function(json) {
  283. $('#result').html(JSON.stringify(json, null, 4));
  284. });
  285. }
  286. function read_get_init() {
  287. $('#result').html('');
  288. str = '<table border="1" width="100%">';
  289. str += '<tr><td colspan="2"><a href="#" id="get">get</a>&nbsp;<a href="#" id="reference">reference</a>&nbsp;<a href="#" id="process">process</a>&nbsp;<a href="#" id="update">update</a></td></tr>';
  290. str += '<tr><td>flag:</td><td><input type="text" id="flag" style="width:95%"/></td></tr>';
  291. str += '</table>';
  292. $('#content').html(str);
  293. $('#get').click(function() {
  294. read_get();
  295. });
  296. $('#reference').click(function() {
  297. read_reference();
  298. });
  299. $('#process').click(function() {
  300. read_process();
  301. });
  302. $('#update').click(function() {
  303. read_update();
  304. });
  305. }
  306. function read_get() {
  307. }
  308. function read_update() {
  309. }
  310. function read_reference() {
  311. }
  312. function read_process() {
  313. }
  314. function read_filter_init() {
  315. }