MediaWiki:Common.js: Difference between revisions

From AlphaX Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
(function () {
(function () {


    const AGE_KEY = "ageVerifiedTime";
const KEY = "alphax_age_terms";
    const CONSENT_KEY = "analyticsConsent";
const MAX_AGE = 30 * 24 * 60 * 60 * 1000;
    const MAX_AGE = 30 * 24 * 60 * 60 * 1000;


    const savedAge = localStorage.getItem(AGE_KEY);
const saved = localStorage.getItem(KEY);


    if (savedAge && (Date.now() - Number(savedAge) < MAX_AGE)) {
if (saved && (Date.now() - saved < MAX_AGE)) {
        const consent = localStorage.getItem(CONSENT_KEY);
    return;
        if (consent === "granted") {
}
            loadGoogleAnalytics();
        }
        return;
    }


    const style = document.createElement("style");
const style = document.createElement("style");
    style.innerHTML = `
        #age-overlay{
            position:fixed;
            top:0;
            left:0;
            width:100%;
            height:100%;
            backdrop-filter:blur(8px);
            background:rgba(0,0,0,0.85);
            display:flex;
            align-items:center;
            justify-content:center;
            z-index:999999;
            font-family:Arial,sans-serif;
        }


        #age-box{
style.innerHTML = `
            background:#111;
#age-overlay{
            color:white;
position:fixed;
            padding:40px;
inset:0;
            border-radius:12px;
background:rgba(0,0,0,0.85);
            max-width:460px;
backdrop-filter:blur(8px);
            text-align:center;
display:flex;
            box-shadow:0 0 40px rgba(0,0,0,0.7);
align-items:center;
        }
justify-content:center;
z-index:999999;
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial;
}


        #age-box h2{
#age-box{
            margin-top:0;
background:#0f0f12;
        }
border:1px solid rgba(255,255,255,0.08);
border-radius:20px;
padding:40px 34px;
max-width:520px;
width:90%;
color:white;
box-shadow:0 25px 80px rgba(0,0,0,0.6);
text-align:center;
}


        #age-buttons{
#age-box h2{
            margin-top:20px;
margin-top:0;
        }
font-size:32px;
margin-bottom:18px;
}


        #age-buttons button{
#age-text{
            padding:12px 22px;
color:#cfcfd6;
            margin:8px;
line-height:1.6;
            font-size:15px;
margin-bottom:28px;
            border:none;
}
            border-radius:6px;
            cursor:pointer;
        }


        #age-enter-analytics{
#checks{
            background:#2ecc71;
text-align:left;
            color:white;
margin-bottom:28px;
        }
}


        #age-enter-essential{
#checks label{
            background:#3498db;
display:block;
            color:white;
margin:12px 0;
        }
font-size:15px;
color:#e4e4ea;
cursor:pointer;
}


        #age-no{
#checks input{
            background:#e74c3c;
margin-right:10px;
            color:white;
}
        }


        #age-links{
#buttons{
            margin-top:18px;
display:flex;
            font-size:12px;
gap:14px;
            opacity:0.85;
justify-content:center;
            line-height:1.5;
margin-top:10px;
        }
}


        #age-links a{
#enter{
            color:#aaa;
background:#34d27a;
            margin:0 8px;
color:#05110b;
        }
border:none;
padding:14px 26px;
border-radius:10px;
font-size:16px;
font-weight:700;
cursor:pointer;
opacity:0.4;
}


        #cookie-note{
#enter.active{
            margin-top:14px;
opacity:1;
            font-size:12px;
}
            color:#ccc;
        }
    `;


    document.head.appendChild(style);
#exit{
background:#e74c3c;
border:none;
color:white;
padding:14px 22px;
border-radius:10px;
font-size:16px;
cursor:pointer;
}


    const overlay = document.createElement("div");
#links{
    overlay.id = "age-overlay";
margin-top:22px;
font-size:13px;
opacity:0.8;
}


    overlay.innerHTML = `
#links a{
        <div id="age-box">
color:#bbb;
margin:0 10px;
text-decoration:none;
}


            <h2>18+ Age Verification</h2>
#links a:hover{
color:white;
}
`;


            <p>This website contains adult educational content.</p>
document.head.appendChild(style);
            <p>You must be at least <b>18 years old</b> to enter.</p>


            <div id="cookie-note">
const overlay = document.createElement("div");
                We use essential storage for site functionality. You may optionally allow analytics.
overlay.id = "age-overlay";
            </div>


            <div id="age-buttons">
overlay.innerHTML = `
                <button id="age-enter-analytics">Enter with Analytics</button>
<div id="age-box">
                <button id="age-enter-essential">Enter Essential Only</button>
                <button id="age-no">Leave</button>
            </div>


            <div id="age-links">
<h2>18+ Access</h2>
                <a href="/index.php?title=Impressum">Impressum</a>
                <a href="/index.php?title=Datenschutz">Privacy</a>
            </div>


        </div>
<div id="age-text">
    `;
This website contains adult educational content.<br>
You must confirm the following to enter.
</div>


    document.body.appendChild(overlay);
<div id="checks">


    function saveAgeVerification() {
<label>
        localStorage.setItem(AGE_KEY, String(Date.now()));
<input type="checkbox" id="c1">
    }
I confirm that I am at least 18 years old
</label>


    function saveAnalyticsConsent(value) {
<label>
        localStorage.setItem(CONSENT_KEY, value);
<input type="checkbox" id="c2">
    }
I agree to the Terms & Conditions
</label>


    function loadGoogleAnalytics() {
<label>
<input type="checkbox" id="c3">
I agree to the Privacy Policy
</label>


        if (window.__gaLoaded) return;
</div>
        window.__gaLoaded = true;


        window.dataLayer = window.dataLayer || [];
<div id="buttons">


        function gtag(){
<button id="enter">Enter</button>
            dataLayer.push(arguments);
<button id="exit">Exit</button>
        }


        window.gtag = gtag;
</div>


        gtag('consent', 'default', {
<div id="links">
            analytics_storage: 'granted'
<a href="/index.php?title=Terms_and_Conditions">T&C</a>
        });
<a href="/index.php?title=Datenschutz">Privacy Policy</a>
</div>


        const script = document.createElement('script');
</div>
        script.async = true;
`;
        script.src = 'https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX';


        document.head.appendChild(script);
document.body.appendChild(overlay);


        gtag('js', new Date());
const c1 = document.getElementById("c1");
const c2 = document.getElementById("c2");
const c3 = document.getElementById("c3");
const enter = document.getElementById("enter");


        gtag('config', 'G-XXXXXXXXXX', {
function checkAll(){
            anonymize_ip: true
if(c1.checked && c2.checked && c3.checked){
        });
enter.classList.add("active");
    }
enter.disabled=false;
}else{
enter.classList.remove("active");
enter.disabled=true;
}
}


    document.getElementById("age-enter-analytics").onclick = function(){
c1.onchange=checkAll;
        saveAgeVerification();
c2.onchange=checkAll;
        saveAnalyticsConsent("granted");
c3.onchange=checkAll;
        overlay.remove();
        loadGoogleAnalytics();
    };


    document.getElementById("age-enter-essential").onclick = function(){
enter.disabled=true;
        saveAgeVerification();
        saveAnalyticsConsent("denied");
        overlay.remove();
    };


    document.getElementById("age-no").onclick = function(){
enter.onclick=function(){
        window.location.href="https://google.com";
localStorage.setItem(KEY, Date.now());
    };
overlay.remove();
};
 
document.getElementById("exit").onclick=function(){
window.location.href="https://google.com";
};


})();
})();

Revision as of 21:40, 15 March 2026

(function () {

const KEY = "alphax_age_terms";
const MAX_AGE = 30 * 24 * 60 * 60 * 1000;

const saved = localStorage.getItem(KEY);

if (saved && (Date.now() - saved < MAX_AGE)) {
    return;
}

const style = document.createElement("style");

style.innerHTML = `
#age-overlay{
position:fixed;
inset:0;
background:rgba(0,0,0,0.85);
backdrop-filter:blur(8px);
display:flex;
align-items:center;
justify-content:center;
z-index:999999;
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial;
}

#age-box{
background:#0f0f12;
border:1px solid rgba(255,255,255,0.08);
border-radius:20px;
padding:40px 34px;
max-width:520px;
width:90%;
color:white;
box-shadow:0 25px 80px rgba(0,0,0,0.6);
text-align:center;
}

#age-box h2{
margin-top:0;
font-size:32px;
margin-bottom:18px;
}

#age-text{
color:#cfcfd6;
line-height:1.6;
margin-bottom:28px;
}

#checks{
text-align:left;
margin-bottom:28px;
}

#checks label{
display:block;
margin:12px 0;
font-size:15px;
color:#e4e4ea;
cursor:pointer;
}

#checks input{
margin-right:10px;
}

#buttons{
display:flex;
gap:14px;
justify-content:center;
margin-top:10px;
}

#enter{
background:#34d27a;
color:#05110b;
border:none;
padding:14px 26px;
border-radius:10px;
font-size:16px;
font-weight:700;
cursor:pointer;
opacity:0.4;
}

#enter.active{
opacity:1;
}

#exit{
background:#e74c3c;
border:none;
color:white;
padding:14px 22px;
border-radius:10px;
font-size:16px;
cursor:pointer;
}

#links{
margin-top:22px;
font-size:13px;
opacity:0.8;
}

#links a{
color:#bbb;
margin:0 10px;
text-decoration:none;
}

#links a:hover{
color:white;
}
`;

document.head.appendChild(style);

const overlay = document.createElement("div");
overlay.id = "age-overlay";

overlay.innerHTML = `
<div id="age-box">

<h2>18+ Access</h2>

<div id="age-text">
This website contains adult educational content.<br>
You must confirm the following to enter.
</div>

<div id="checks">

<label>
<input type="checkbox" id="c1">
I confirm that I am at least 18 years old
</label>

<label>
<input type="checkbox" id="c2">
I agree to the Terms & Conditions
</label>

<label>
<input type="checkbox" id="c3">
I agree to the Privacy Policy
</label>

</div>

<div id="buttons">

<button id="enter">Enter</button>
<button id="exit">Exit</button>

</div>

<div id="links">
<a href="/index.php?title=Terms_and_Conditions">T&C</a>
<a href="/index.php?title=Datenschutz">Privacy Policy</a>
</div>

</div>
`;

document.body.appendChild(overlay);

const c1 = document.getElementById("c1");
const c2 = document.getElementById("c2");
const c3 = document.getElementById("c3");
const enter = document.getElementById("enter");

function checkAll(){
if(c1.checked && c2.checked && c3.checked){
enter.classList.add("active");
enter.disabled=false;
}else{
enter.classList.remove("active");
enter.disabled=true;
}
}

c1.onchange=checkAll;
c2.onchange=checkAll;
c3.onchange=checkAll;

enter.disabled=true;

enter.onclick=function(){
localStorage.setItem(KEY, Date.now());
overlay.remove();
};

document.getElementById("exit").onclick=function(){
window.location.href="https://google.com";
};

})();