reset.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. function reset_init() {
  2. $('#content').html('');
  3. $('#result').html('');
  4. var str = '<table border="1" width="100%">';
  5. str += '<tr><td colspan="2"><a href="#" id="checkCredential">checkCredential</a>&nbsp;<a href="#" id="checkPassword">checkPassword</a>&nbsp;<a href="#" id="createCode">createCode</a>&nbsp;<a href="#" id="update">update</a></td></tr>';
  6. str += '<tr><td>credential:</td><td><input type="text" style="width:95%" id= "credential"/></td></tr>';
  7. str += '<tr><td>password:</td><td><input type="password" style="width:95%" id= "password"/></td></tr>';
  8. str += '<tr><td>codeAnswer:</td><td><input type="text" style="width:95%" id= "codeAnswer"/></td></tr>';
  9. str += '</table>';
  10. $('#content').html(str);
  11. $('#checkCredential').click(function() {
  12. reset_check_credential($('#credential').val());
  13. });
  14. $('#checkPassword').click(function() {
  15. reset_check_password($('#password').val());
  16. });
  17. $('#createCode').click(function() {
  18. reset_create_code($('#credential').val());
  19. });
  20. $('#update').click(function() {
  21. reset_update($('#credential').val(), $('#password').val(), $('#codeAnswer').val());
  22. });
  23. }
  24. function reset_check_credential(credential) {
  25. $('#result').html('');
  26. $.ajax({
  27. type : 'get',
  28. dataType : 'json',
  29. url : '../jaxrs/reset/check/credential/' + credential,
  30. xhrFields : {
  31. 'withCredentials' : true
  32. },
  33. crossDomain : true
  34. }).always(function(json) {
  35. $('#result').html(JSON.stringify(json, null, 4));
  36. });
  37. }
  38. function reset_check_password(password) {
  39. $('#result').html('');
  40. $.ajax({
  41. type : 'get',
  42. dataType : 'json',
  43. url : '../jaxrs/reset/check/password/' + password,
  44. xhrFields : {
  45. 'withCredentials' : true
  46. },
  47. crossDomain : true
  48. }).always(function(json) {
  49. $('#result').html(JSON.stringify(json, null, 4));
  50. });
  51. }
  52. function reset_create_code(credential) {
  53. $('#result').html('');
  54. $.ajax({
  55. type : 'get',
  56. dataType : 'json',
  57. url : '../jaxrs/reset/code/credential/' + credential,
  58. xhrFields : {
  59. 'withCredentials' : true
  60. },
  61. crossDomain : true
  62. }).always(function(json) {
  63. $('#result').html(JSON.stringify(json, null, 4));
  64. });
  65. }
  66. function reset_update(credential, password, codeAnswer) {
  67. $.ajax({
  68. type : 'put',
  69. dataType : 'json',
  70. url : '../jaxrs/reset',
  71. contentType : 'application/json; charset=utf-8',
  72. data : JSON.stringify({
  73. credential : credential,
  74. password : password,
  75. codeAnswer : codeAnswer
  76. }),
  77. xhrFields : {
  78. 'withCredentials' : true
  79. },
  80. crossDomain : true
  81. }).always(function(json) {
  82. $('#result').html(JSON.stringify(json, null, 4));
  83. });
  84. }