跳转到内容

MediaWiki:Common.js:修订间差异

来自洽隐山房
无编辑摘要
无编辑摘要
第50行: 第50行:
         });
         });
     });
     });
     document.addEventListener("DOMContentLoaded", function(e){
      
        inject_parallax(document);
    inject_parallax(document);
        loadScript(
    loadScript(
            "https://cdnjs.cloudflare.com/ajax/libs/parallax/3.1.0/parallax.min.js"
        "https://cdnjs.cloudflare.com/ajax/libs/parallax/3.1.0/parallax.min.js"
        ).then(function () {
    ).then(function () {
            new Parallax(scene);
        new Parallax(scene);
        });
     });
     });


   
     loadScript(
     loadScript(
         "https://cdn.jsdelivr.net/npm/@hotwired/turbo@latest/dist/turbo.es2017-esm.min.js",
         "https://cdn.jsdelivr.net/npm/@hotwired/turbo@latest/dist/turbo.es2017-esm.min.js",

2026年8月21日 (五) 04:04的版本

(function () {
    if (!window.SLOADED) {
        window.SLOADED = {};
        window.RELOAD = true;
    } else {
        window.RELOAD = false;
    }

    let scene;
    function inject_parallax(document) {
        scene = document.createElement("div");
        document.body.appendChild(scene);
        scene.id = "scene";
        scene.dataset.turboPermanent = "true";
        scene.style.zIndex = -100;
        scene.style.position = "fixed";
        scene.id = "parallax-bg";
        scene.style.inset = "-300px";
        var img = document.createElement("img");
        scene.appendChild(img);
        img.src = "/_nuxt/bg-1.DbZGBWF5.jpg";
        img.dataset.depth = 0.5;
    }
    
    function loadScript(url, options = {}, dataset = {}) {
        return new Promise((resolve, reject) => {
            if (window.SLOADED[url]) resolve();
            const script = document.createElement("script");
            script.src = url;
            script.async = "async";
            Object.assign(script, options);
            Object.assign(script.dataset, dataset);
            script.onload = () => {
                window.SLOADED[url] = true;
                resolve();
            };
            script.onerror = (e) => reject(e);
            document.head.appendChild(script);
        });
    }
    document.body.querySelectorAll('script').forEach((script)=>{
        window.SLOADED[script.src] = true;
    })
    document.addEventListener("turbo:before-render", (event) => {
        const newBody = event.detail.newBody;
        const loadPhpScripts = newBody.querySelectorAll('script');
        loadPhpScripts.forEach((script) => {
            if(window.SLOADED[script.src])
                script.remove();
        });
    });
    
    inject_parallax(document);
    loadScript(
        "https://cdnjs.cloudflare.com/ajax/libs/parallax/3.1.0/parallax.min.js"
    ).then(function () {
        new Parallax(scene);
    });

    loadScript(
        "https://cdn.jsdelivr.net/npm/@hotwired/turbo@latest/dist/turbo.es2017-esm.min.js",
        { type: "module" }
    );
})();