diff options
| author | Hizbu Azka <hanifan.azka@gmail.com> | 2026-10-18 17:48:21 +0700 |
|---|---|---|
| committer | Hizbu Azka <hanifan.azka@gmail.com> | 2026-10-18 17:48:21 +0700 |
| commit | d6db8204d42f678e2a32151e25ee61c4b0bfa705 (patch) | |
| tree | 7807162e7447944b39a2a419e1cb4dfe9776fa46 /_posts | |
| parent | a6f3a92412891ab9353f6b3d4b8c687e92c56d84 (diff) | |
simplify fullscreen logic
Diffstat (limited to '_posts')
| -rw-r--r-- | _posts/2026-10-17-regex.html | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/_posts/2026-10-17-regex.html b/_posts/2026-10-17-regex.html index addb3de..b7e3855 100644 --- a/_posts/2026-10-17-regex.html +++ b/_posts/2026-10-17-regex.html @@ -10,34 +10,15 @@ layout: post <script> const body = document.body; const checkbox = document.getElementById("fullscreen"); - const properties = ["margin", "max-width", "padding"]; - - // Save each property's original inline value and priority. - const originalStyles = Object.fromEntries( - properties.map(property => [ - property, - { - value: body.style.getPropertyValue(property), - priority: body.style.getPropertyPriority(property) - } - ]) - ); - checkbox.addEventListener("change", () => { if (checkbox.checked) { body.style.setProperty("margin", "0"); body.style.setProperty("max-width", "none"); body.style.setProperty("padding", "0"); } else { - for (const property of properties) { - const { value, priority } = originalStyles[property]; - - if (value) { - body.style.setProperty(property, value, priority); - } else { - body.style.removeProperty(property); - } - } + body.style.removeProperty("margin"); + body.style.removeProperty("max-width"); + body.style.removeProperty("padding"); } }); </script> |