Widget:Guides/PlatformSwitcher: Difference between revisions

No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 22: Line 22:


<script type="module" defer>
<script type="module" defer>
const containers = document.querySelectorAll('.platform-specific');
const containers = document.querySelectorAll('.platform');
switch_thing('windows');
 
const plat = navigator.platform;
const os = plat.includes("Mac") ? "macos"
  : plat.includes("Win") ? "windows"
  : plat.includes("Linux") ? "linux"
  : plat.includes("Haiku") ? "haiku"
  : "windows";
 
switch_thing(os);
const os_radio = document.querySelector(`[value=${os}]`);
os_radio.checked = true;


const fieldset = document.getElementById("platform-switcher");
const fieldset = document.getElementById("platform-switcher");
Line 35: Line 45:
     x.style.display = "none"
     x.style.display = "none"
   }
   }
   document.querySelector('.' + value).style.display = "block";
   const platform_elems = document.querySelectorAll('.' + value);
  platform_elems.forEach(x => x.style.display = "unset");
}
}
</script>
</script>