collect.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. collect_parameter = {};
  2. function collect_init() {
  3. $('#content').html('');
  4. $('#result').html('');
  5. var str = '<table border="1" width="100%">';
  6. str += '<tr><td colspan="2"><a href="#" id="get">get</a>&nbsp;<a href="#" id="update">update</a>&nbsp;<a href="#" id="connect">connect</a>&nbsp;<a href="#" id="nameExist">nameExist</a>&nbsp;<a href="#" id="code">code</a>&nbsp;<a href="#" id="regist">regist</a>&nbsp;<a href="#" id="controllerMobile">controllerMobile</a>&nbsp;<a href="#" id="resetPassword">resetPassword</a></td></tr>';
  7. str += '<tr><td colspan="2"><a href="#" id="validate">validate</a>&nbsp;<a href="#" id="validateDirect">validateDirect</a>&nbsp;<a href="#" id="validateCodeAnswer">validateCodeAnswer</a>&nbsp;<a href="#" id="validatePassword">validatePassword</a></td></tr>';
  8. str += '<tr><td>enable:</td><td><select id="enable"><option value="true">true</option><option value="false">false</option></select></td></tr>';
  9. str += '<tr><td>name:</td><td><input id="name" style="width:95%"/></td></tr>';
  10. str += '<tr><td>password:</td><td><input id="password" type="password" style="width:95%"/></td></tr>';
  11. str += '<tr><td>mobile:</td><td><input id="mobile" style="width:95%"/></td></tr>';
  12. str += '<tr><td>codeAnswer:</td><td><input id="codeAnswer" style="width:95%"/></td></tr>';
  13. str += '</tbody>';
  14. str += '</table>';
  15. $('#content').html(str);
  16. $('#get').click(function() {
  17. collect_get();
  18. });
  19. $('#update').click(function() {
  20. collect_update();
  21. });
  22. $('#connect').click(function() {
  23. collect_connect();
  24. });
  25. $('#validate').click(function() {
  26. collect_validate();
  27. });
  28. $('#validateDirect').click(function() {
  29. collect_validateDirect();
  30. });
  31. $('#validateCodeAnswer').click(function() {
  32. collect_validateCodeAnswer();
  33. });
  34. $('#validatePassword').click(function() {
  35. collect_validatePassword();
  36. });
  37. $('#nameExist').click(function() {
  38. collect_name_exist($('#name').val());
  39. });
  40. $('#code').click(function() {
  41. collect_code($('#mobile').val());
  42. });
  43. $('#regist').click(function() {
  44. collect_regist();
  45. });
  46. $('#controllerMobile').click(function() {
  47. collect_controller_mobile($('#name').val(), $('#mobile').val());
  48. });
  49. $('#resetPassword').click(function() {
  50. collect_reset_password();
  51. });
  52. }
  53. function collect_get() {
  54. $.ajax({
  55. type : 'get',
  56. dataType : 'json',
  57. url : '../jaxrs/collect',
  58. contentType : 'application/json; charset=utf-8',
  59. xhrFields : {
  60. 'withCredentials' : true
  61. },
  62. crossDomain : true
  63. }).always(function(json) {
  64. $('#result').html(JSON.stringify(json, null, 4));
  65. }).done(function(json) {
  66. $('#enable').val(json.data.enable + '');
  67. $('#name').val(json.data.name);
  68. $('#password').val(json.data.password);
  69. });
  70. }
  71. function collect_update() {
  72. $.ajax({
  73. type : 'put',
  74. dataType : 'json',
  75. url : '../jaxrs/collect',
  76. contentType : 'application/json; charset=utf-8',
  77. xhrFields : {
  78. 'withCredentials' : true
  79. },
  80. data : JSON.stringify({
  81. enable : $('#enable').val(),
  82. name : $('#name').val(),
  83. password : $('#password').val()
  84. }),
  85. crossDomain : true
  86. }).always(function(json) {
  87. $('#result').html(JSON.stringify(json, null, 4));
  88. });
  89. }
  90. function collect_connect() {
  91. $.ajax({
  92. type : 'get',
  93. dataType : 'json',
  94. url : '../jaxrs/collect/connect',
  95. contentType : 'application/json; charset=utf-8',
  96. xhrFields : {
  97. 'withCredentials' : true
  98. },
  99. crossDomain : true
  100. }).always(function(json) {
  101. $('#result').html(JSON.stringify(json, null, 4));
  102. });
  103. }
  104. function collect_validate() {
  105. $.ajax({
  106. type : 'get',
  107. dataType : 'json',
  108. url : '../jaxrs/collect/validate',
  109. contentType : 'application/json; charset=utf-8',
  110. xhrFields : {
  111. 'withCredentials' : true
  112. },
  113. crossDomain : true
  114. }).always(function(json) {
  115. $('#result').html(JSON.stringify(json, null, 4));
  116. });
  117. }
  118. function collect_validateDirect() {
  119. $.ajax({
  120. type : 'put',
  121. dataType : 'json',
  122. url : '../jaxrs/collect/validate/direct',
  123. contentType : 'application/json; charset=utf-8',
  124. xhrFields : {
  125. 'withCredentials' : true
  126. },
  127. data : JSON.stringify({
  128. name : $('#name').val(),
  129. password : $('#password').val()
  130. }),
  131. crossDomain : true
  132. }).always(function(json) {
  133. $('#result').html(JSON.stringify(json, null, 4));
  134. });
  135. }
  136. function collect_validatePassword() {
  137. $.ajax({
  138. type : 'put',
  139. dataType : 'json',
  140. url : '../jaxrs/collect/validate/password',
  141. contentType : 'application/json; charset=utf-8',
  142. xhrFields : {
  143. 'withCredentials' : true
  144. },
  145. data : JSON.stringify({
  146. password : $('#password').val()
  147. }),
  148. crossDomain : true
  149. }).always(function(json) {
  150. $('#result').html(JSON.stringify(json, null, 4));
  151. });
  152. }
  153. function collect_validateCodeAnswer() {
  154. $.ajax({
  155. type : 'put',
  156. dataType : 'json',
  157. url : '../jaxrs/collect/validate/codeanswer',
  158. contentType : 'application/json; charset=utf-8',
  159. xhrFields : {
  160. 'withCredentials' : true
  161. },
  162. data : JSON.stringify({
  163. mobile : $('#mobile').val(),
  164. codeAnswer : $('#codeAnswer').val()
  165. }),
  166. crossDomain : true
  167. }).always(function(json) {
  168. $('#result').html(JSON.stringify(json, null, 4));
  169. });
  170. }
  171. function collect_code(mobile) {
  172. $.ajax({
  173. type : 'get',
  174. dataType : 'json',
  175. url : '../jaxrs/collect/code/mobile/' + mobile,
  176. contentType : 'application/json; charset=utf-8',
  177. xhrFields : {
  178. 'withCredentials' : true
  179. },
  180. crossDomain : true
  181. }).always(function(json) {
  182. $('#result').html(JSON.stringify(json, null, 4));
  183. });
  184. }
  185. function collect_name_exist(name) {
  186. $.ajax({
  187. type : 'get',
  188. dataType : 'json',
  189. url : '../jaxrs/collect/name/' + name + '/exist',
  190. contentType : 'application/json; charset=utf-8',
  191. xhrFields : {
  192. 'withCredentials' : true
  193. },
  194. crossDomain : true
  195. }).always(function(json) {
  196. $('#result').html(JSON.stringify(json, null, 4));
  197. });
  198. }
  199. function collect_regist() {
  200. $.ajax({
  201. type : 'post',
  202. dataType : 'json',
  203. url : '../jaxrs/collect',
  204. contentType : 'application/json; charset=utf-8',
  205. data : JSON.stringify({
  206. name : $('#name').val(),
  207. password : $('#password').val(),
  208. mobile : $('#mobile').val(),
  209. codeAnswer : $('#codeAnswer').val()
  210. }),
  211. xhrFields : {
  212. 'withCredentials' : true
  213. },
  214. crossDomain : true
  215. }).always(function(json) {
  216. $('#result').html(JSON.stringify(json, null, 4));
  217. });
  218. }
  219. function collect_reset_password() {
  220. $.ajax({
  221. type : 'put',
  222. dataType : 'json',
  223. url : '../jaxrs/collect/resetpassword',
  224. contentType : 'application/json; charset=utf-8',
  225. data : JSON.stringify({
  226. name : $('#name').val(),
  227. password : $('#password').val(),
  228. mobile : $('#mobile').val(),
  229. codeAnswer : $('#codeAnswer').val()
  230. }),
  231. xhrFields : {
  232. 'withCredentials' : true
  233. },
  234. crossDomain : true
  235. }).always(function(json) {
  236. $('#result').html(JSON.stringify(json, null, 4));
  237. });
  238. }
  239. function collect_controller_mobile(name, mobile) {
  240. $.ajax({
  241. type : 'get',
  242. dataType : 'json',
  243. url : '../jaxrs/collect/controllermobile/name/' + name + '/mobile/' + mobile,
  244. contentType : 'application/json; charset=utf-8',
  245. xhrFields : {
  246. 'withCredentials' : true
  247. },
  248. crossDomain : true
  249. }).always(function(json) {
  250. $('#result').html(JSON.stringify(json, null, 4));
  251. });
  252. }