register.template 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <script>
  2. {{#if key}}
  3. back();
  4. {{/if}}
  5. </script>
  6. <form id="form" style="display:none;">
  7. <div>
  8. <input name="email" class="fill-width" placeholder="Email" type="text"/>
  9. </div>
  10. <div>
  11. <input name="username" class="fill-width" placeholder="Username" type="text"/>
  12. </div>
  13. <div>
  14. <input name="password" class="fill-width" placeholder="Password" type="password"/>
  15. </div>
  16. <div>
  17. <input name="password1" class="fill-width" placeholder="Verify Password" type="password"/>
  18. </div>
  19. <div class="fill-width" style="height:20px;background-repeat:no-repeat;background-position:center;background-size:165px 20px;" id="captcha"></div>
  20. <div>
  21. <input name="captcha" class="fill-width" placeholder="Captcha" type="text"/>
  22. </div>
  23. <div>
  24. <input type="button" value="cancel" class="cancel left"/>
  25. <input type="submit" value="register" class="right"/>
  26. </div>
  27. </form>
  28. <script>
  29. {{#unless key}}
  30. $(document).ready(function(){
  31. var reloadCaptcha = function(){
  32. $('#captcha').css('background-image','url(index.php?get=captcha&timestamp='+(+new Date)+')');
  33. $('input[name=captcha]').val('');
  34. };
  35. reloadCaptcha();
  36. $('form#form').show().submit(function(){
  37. var data = $(this).serializeObject(),
  38. State = History.getState();
  39. for(var i in State.data){
  40. data[i] = State.data;
  41. }
  42. data.type = 'action';
  43. data.id = 'register';
  44. apiCall(data,function(d){
  45. if(!d.error){
  46. setKey(d.key);
  47. notify('register','You have successfully registered');
  48. loadState('page-index');
  49. }else{
  50. setKey(null);
  51. reloadCaptcha();
  52. $('#loading').hide();
  53. }
  54. });
  55. return false;
  56. }).find('.cancel').click(function(){
  57. back();
  58. return false;
  59. });
  60. });
  61. {{/unless}}
  62. </script>