login.template 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <script>
  2. {{#if key}}
  3. back();
  4. {{/if}}
  5. </script>
  6. <form id="form" style="display:none;">
  7. <input name="username" class="fill-width" placeholder="Username" id="login-username" type="text"/>
  8. <input id="login-password" class="fill-width" placeholder="Password" name="password" type="password"/>
  9. <button value="Cancel" class="danger">Cancel</button>
  10. <button value="Login" onclick="$(this).parent().submit();">Login</button>
  11. </form>
  12. <script>
  13. {{#unless key}}
  14. $(document).ready(function(){
  15. $('form#form').show().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. notify('login','You have logged in successfully');
  27. back(true);
  28. }else{
  29. setKey(null);
  30. $('#loading').hide();
  31. }
  32. return false;
  33. });
  34. return false;
  35. }).find('.danger').click(function(){
  36. back(true);
  37. return false;
  38. });
  39. });
  40. {{/unless}}
  41. </script>