VladislavNechepaev

Untitled

Sep 23rd, 2021
618
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var mainWrapper = document.getElementsByClassName("main pull-left")
  2.       if (!mainWrapper.length) mainWrapper = document.getElementsByClassName("main")
  3.       const mainHeader = mainWrapper[0].getElementsByClassName("clearfix")[0]
  4.       const mainCustomFields = document.getElementsByClassName("custom-fields")[0]
  5.       const [covidWrapper1,covidDropdown1] = createCovidDropdown("covid_dropdown1", "Have you been abroad during the last 7 days?")
  6.       const [covidWrapper2,covidDropdown2] = createCovidDropdown("covid_dropdown2", "Have you contacted with any suspected/COVID-19 patients for the last 14 days?")
  7.       const [covidWrapper3,covidDropdown3] = createCovidDropdown("covid_dropdown3", "Do you have any symptoms of cold (high temperature, etc.)?")
  8.       const covidDropdownMessage = document.createElement("div")
  9.       covidDropdownMessage.innerHTML = "Sorry, you are not allowed to visit the office."
  10.       covidDropdownMessage.style.color = "red"
  11.       covidDropdownMessage.hidden = true
  12.       mainHeader.after(covidDropdownMessage)
  13.       mainHeader.after(covidWrapper1)
  14.       mainHeader.after(covidWrapper2)
  15.       mainHeader.after(covidWrapper3)
  16.       const covidDropdownList = [covidDropdown1,covidDropdown2,covidDropdown3]
  17.        
  18.       function createCovidDropdown(id, text){
  19.         const wrapper = document.createElement("div")
  20.         const covidDropdown = document.createElement("select")
  21.         covidDropdown.id = id
  22.         const optionNull = document.createElement("option")
  23.         optionNull.innerHTML = "..."
  24.         const optionYes = document.createElement("option")
  25.         optionYes.innerHTML = "Yes"
  26.         const optionNo = document.createElement("option")
  27.         optionNo.innerHTML = "No"
  28.         covidDropdown.appendChild(optionNull)
  29.         covidDropdown.appendChild(optionYes)
  30.         covidDropdown.appendChild(optionNo)
  31.         covidDropdown.onchange = function(){ renderController() }
  32.         const covidDropdownHeader = document.createElement("label")
  33.         covidDropdownHeader.htmlFor = id
  34.         covidDropdownHeader.innerHTML = text
  35.         covidDropdownHeader.style.marginTop = "10px"
  36.         covidDropdownHeader.style.marginRight = "50px"
  37.         wrapper.appendChild(covidDropdownHeader)
  38.         wrapper.appendChild(covidDropdown)
  39.         return [wrapper,covidDropdown]
  40.       }
  41.  
  42. // ============================
  43.  
  44. covidQuestions = true
  45.         covidAllSelected = true
  46.         covidDropdownList.forEach(covidDropdown => {
  47.           if (covidDropdown.value !== "No") covidQuestions = false
  48.           if (covidDropdown.value === "...") covidAllSelected = false
  49.         })
  50.         if (covidQuestions) {
  51.           mainCustomFields.hidden = false
  52.           documentCheckbox.checked = true
  53.         } else {
  54.           mainCustomFields.hidden = true
  55.           documentCheckbox.checked = false
  56.         }
  57.         covidDropdownMessage.hidden = !(!covidQuestions && covidAllSelected)
RAW Paste Data