login.template 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <script>
  2. {{#if key}}
  3. back();
  4. {{/if}}
  5. </script>
  6. <form id="form" style="display:none;">
  7. <div>
  8. <input name="username" class="fill-width" placeholder="Username" id="login-username" type="text"/>
  9. </div>
  10. <div >
  11. <input id="login-password" class="fill-width" placeholder="Password" name="password" type="password"/>
  12. </div>
  13. <div>
  14. <input type="button" value="cancel" class="cancel"/>
  15. <input type="submit" value="login"/>
  16. </div>
  17. </form>
  18. <script>
  19. {{#unless key}}
  20. $(document).ready(function(){
  21. $('form#form').show().submit(function(){
  22. var data = $(this).serializeObject(),
  23. State = History.getState();
  24. for(var i in State.data){
  25. data[i] = State.data;
  26. }
  27. data.type = 'action';
  28. data.id = 'login';
  29. apiCall(data,function(d){
  30. if(!d.error){
  31. setKey(d.key);
  32. notify('login','You have logged in successfully');
  33. back(true);
  34. }else{
  35. setKey(null);
  36. $('#loading').hide();
  37. }
  38. return false;
  39. });
  40. return false;
  41. }).find('.cancel').click(function(){
  42. back(true);
  43. return false;
  44. });
  45. });
  46. {{/unless}}
  47. </script>