login.template 835 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <h1>
  2. {{title}}
  3. </h1>
  4. <form id="login">
  5. <div>
  6. Username: <input name="username" type="text"/>
  7. </div>
  8. <div>
  9. Password: <input name="password" type="password"/>
  10. </div>
  11. <input type="submit" value="login"/>
  12. <input type="button" value="cancel" class="cancel"/>
  13. </form>
  14. <script>
  15. {{#if key}}
  16. History.back();
  17. {{else}}
  18. $('form#login').submit(function(){
  19. var data = $(this).serializeObject(),
  20. State = History.getState();
  21. for(var i in State.data){
  22. data[i] = State.data;
  23. }
  24. data.type = 'action';
  25. data.id = 'login';
  26. apiCall(data,function(d){
  27. if(!d.error){
  28. setKey(d.key);
  29. History.go(-1);
  30. }else{
  31. setKey(null);
  32. $('#loading').hide();
  33. }
  34. return false;
  35. });
  36. return false;
  37. }).children('.cancel').click(function(){
  38. History.back();
  39. return false;
  40. });
  41. {{/if}}
  42. </script>