Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Get the modal
  2. var modal = document.getElementById('myModal');
  3.  
  4. // Get the button that opens the modal
  5. //var btn = document.getElementById("myBtn");
  6.  
  7. // Get the <span> element that closes the modal
  8. var span = document.getElementsByClassName("close")[0];
  9.  
  10. // When the user clicks the button, open the modal
  11. function showModal() {
  12.     modal.style.display = "block";
  13. }
  14.  
  15. // When the user clicks on <span> (x), close the modal
  16. span.onclick = function() {
  17.     modal.style.display = "none";
  18. }
  19.  
  20. // When the user clicks anywhere outside of the modal, close it
  21. window.onclick = function(event) {
  22.     if (event.target == modal) {
  23.         modal.style.display = "none";
  24.     }
  25. }
  26.  
  27. function getUsername() {
  28.     var username = document.getElementById("getUsername").value;
  29.     console.log(username);
  30.     localStorage.setItem(username, username + " ||| " + score);
  31.     var x = localStorage.getItem(username);
  32.     document.getElementById("nowPlaying").innerHTML = x ;
  33.     modal.style.display = "none";
  34. }
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. // CSSSSSSSSSSSSSSSSSSSS
  48. .modal {
  49.     display: none; /* Hidden by default */
  50.     position: fixed; /* Stay in place */
  51.     z-index: 1; /* Sit on top */
  52.     padding-top: 100px; /* Location of the box */
  53.     left: 0;
  54.     top: 0;
  55.     width: 100%; /* Full width */
  56.     height: 100%; /* Full height */
  57.     overflow: auto; /* Enable scroll if needed */
  58.     background-color: rgb(0,0,0); /* Fallback color */
  59.     background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
  60. }
  61.  
  62. /* Modal Content */
  63. .modal-content {
  64.     background-color: #fefefe;
  65.     margin: auto;
  66.     padding: 20px;
  67.     border: 1px solid #888;
  68.     width: 80%;
  69. }
  70.  
  71. /* The Close Button */
  72. .close {
  73.     color: #aaaaaa;
  74.     float: right;
  75.     font-size: 28px;
  76.     font-weight: bold;
  77. }
  78.  
  79. .close:hover,
  80. .close:focus {
  81.     color: #000;
  82.     text-decoration: none;
  83.     cursor: pointer;
  84. }
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96. <!-- Modal content -->
  97.     <div class="modal-content">
  98.         <span class="close">&times;</span>
  99.         <h1>Welcome to The bricks</h1>
  100.         <p>Would you please enter your username: </p>
  101.         <input type="text" name="username" id="getUsername"><br>
  102.         <button onclick="getUsername()">Enter</button>
  103.     </div>
  104.  
  105. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement