EntropyStarRover

Locked profile

Jan 26th, 2021
765
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function lockedProfile() {
  2.  
  3.  
  4.     let btns = Array.from(document.getElementsByTagName("button"));
  5.  
  6.     btns.forEach(b => {
  7.         b.addEventListener("click", showMore);
  8.     })
  9.  
  10.     function showMore(e) {
  11.         let parent = e.target.parentNode;
  12.         let radios = Array.from(parent.querySelectorAll('input[type="radio"]'));
  13.         let isLocked = radios[0].checked;
  14.         console.log(isLocked);
  15.  
  16.         let isUnlocked = radios[1].checked;
  17.         console.log(isUnlocked);
  18.  
  19.         if (isUnlocked) {
  20.             let hiddenDiv = parent.querySelector('div');
  21.  
  22.             if (e.target.textContent == "Show more") {
  23.  
  24.                 hiddenDiv.style.display = "block";
  25.                 e.target.textContent = "Hide it";
  26.             } else {
  27.                 hiddenDiv.style.display = "none";
  28.                 e.target.textContent = "Show more";
  29.             }
  30.         }
  31.  
  32.     }
  33. }
RAW Paste Data