|
|
| (8 intermediate revisions by the same user not shown) |
| Line 2: |
Line 2: |
|
| |
|
| {{#tag:html| | | {{#tag:html| |
| <div id="ageDisclaimerOverlay" class="age-overlay" style="display:none"> | | <script src="https://www.gamebrew.org/images/misc/assets/js/Disclaimer.js"></script> |
| <div class="age-blur"></div>
| | <script src="https://www.gamebrew.org/images/misc/assets/js/common.js"></script> |
| <div class="age-popup slide-down">
| |
| <h2>You must be 18+ to view this content</h2>
| |
| <p>This page may contain content intended for mature audiences only.<br>Please confirm that you are 18 years of age or older.</p>
| |
| <div class="btn-group">
| |
| <button id="acceptDisclaimer">I am 18 or older</button>
| |
| <button id="declineDisclaimer">Leave this page</button>
| |
| </div>
| |
| </div>
| |
| </div> | |
| | |
| <script> | |
| // Load the MediaWiki user module so we can tell if someone is logged in
| |
| mw.loader.using(['mediawiki.user', 'mediawiki.util']).then(function () {
| |
| const overlay = document.getElementById("ageDisclaimerOverlay");
| |
| const body = document.body;
| |
| const isLoggedIn = !mw.user.isAnon();
| |
| const cookieConfirmed = document.cookie
| |
| .split('; ')
| |
| .some(part => part.trim() === 'ageConfirmed=true');
| |
| | |
| function showOverlay() {
| |
| overlay.style.display = 'flex';
| |
| body.style.overflow = 'hidden';
| |
| requestAnimationFrame(()=>{
| |
| overlay.querySelector(".age-popup").classList.add("slide-active");
| |
| });
| |
| }
| |
| function hideOverlay() {
| |
| overlay.style.display = 'none';
| |
| body.style.overflow = '';
| |
| }
| |
| | |
| // Show to everyone on first visit (no cookie),
| |
| // and even if they have a cookie, force-show again for logged-in users
| |
| if (!cookieConfirmed || isLoggedIn) {
| |
| showOverlay();
| |
| }
| |
| | |
| document.getElementById("acceptDisclaimer").addEventListener("click", function () {
| |
| // set 30‑day cookie
| |
| document.cookie = "ageConfirmed=true;max-age=" + (30*24*60*60) + ";path=/";
| |
| hideOverlay();
| |
| });
| |
| | |
| document.getElementById("declineDisclaimer").addEventListener("click", function () {
| |
| // send them back to Main Page; you can change this target
| |
| window.location.href = mw.util.getUrl('Main_Page');
| |
| });
| |
| });
| |
| </script> | |
| }} | | }} |