login.template 773 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. $('form#login').submit(function(){
  16. var data = $(this).serializeObject(),
  17. State = History.getState();
  18. for(var i in State.data){
  19. data[i] = State.data;
  20. }
  21. data.type = 'action';
  22. data.id = 'login';
  23. apiCall(data,function(d){
  24. if(!d.error){
  25. setKey(d.key);
  26. History.go(-1);
  27. }else{
  28. setKey(null);
  29. apiState('page-login');
  30. }
  31. return false;
  32. });
  33. return false;
  34. }).children('.cancel').click(function(){
  35. loadState('page-index');
  36. return false;
  37. });
  38. </script>