Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. /**************************************************
  2. * Javascript - Ficha 11
  3. * ************************************************/
  4. var username = "Admin";
  5. var password = "savetrees";
  6.  
  7. var user = document.querySelector('#input_username');
  8. var pass = document.querySelector('#input_password');
  9.  
  10. var login_attemps = 0;
  11.  
  12.  
  13. init();
  14. function init() {
  15. document.querySelector('#btn-donate').style.visibility = 'hidden';
  16. alert("1");
  17. document.querySelector('#btn-logout').style.visibility = 'hidden';
  18. alert("2");
  19. login_attemps = 0;
  20. }
  21.  
  22. /*
  23. . class
  24. # id
  25. */
  26.  
  27.  
  28.  
  29.  
  30.  
  31. document.querySelector('#btn-login').addEventListener('click', function()
  32. {
  33. /*
  34. if(login_attemps => 5)
  35. {
  36. alert("Não tem mais tentativas.");
  37. return false;
  38. }
  39. */
  40.  
  41. if(user.value == "" || pass.value == "")
  42. {
  43. alert("Preencha ambos os campos para poder efetuar o Login. Tem " + (5 - login_attemps) + "tentativas restantes.");
  44. login_attemps += 1;
  45. }
  46.  
  47.  
  48. if(user.value == username && pass.value == password)
  49. {
  50.  
  51. document.querySelector('#btn-donate').style.visibility = 'visible';
  52. document.querySelector('#btn-logout').style.visibility = 'visible';
  53.  
  54.  
  55. document.querySelector('#input_username').style.visibility = 'hidden';
  56. document.querySelector('#input_password').style.visibility = 'hidden';
  57. document.querySelector('#btn-login').style.visibility = 'hidden';
  58.  
  59.  
  60. document.querySelector('#post_login_box').innerHTML = "<p>Logged in as:</p><h4>" + username +"</h4>";
  61.  
  62.  
  63. // .visible
  64. // donate button visible
  65. }
  66. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement