MediaWiki:Common.js:修订间差异
外观
无编辑摘要 |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | /* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | ||
(function(){ | (function () { | ||
if(!window.SLOADED){ | if (!window.SLOADED) { | ||
window.SLOADED = {} | |||
window.RELOAD = true; | |||
}else{ | } else { | ||
window.RELOAD = false; | |||
} | } | ||
let scene; | let scene; | ||
function inject_parallax(document){ | 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 hack_mw(mw){ | function hack_mw(mw) { | ||
mw.loader.registerOne = function (module, version, dependencies, group, source, skip) { | |||
registry[module] = { | |||
// Exposed to execute() for mw.loader.impl() closures. | |||
// Import happens via require(). | |||
module: { | |||
exports: {} | |||
}, | |||
// module.export objects for each package file inside this module | |||
packageExports: {}, | |||
version: version || '', | |||
dependencies: dependencies || [], | |||
group: typeof group === 'undefined' ? null : group, | |||
source: typeof source === 'string' ? source : 'local', | |||
state: 'registered', | |||
skip: typeof skip === 'string' ? skip : null | |||
}; | |||
}; | }; | ||
mw.loader.impl = function (declarator) { | |||
var data = declarator(), | var data = declarator(), | ||
module = data[ 0 ], | module = data[0], | ||
script = data[ 1 ] || null, | script = data[1] || null, | ||
style = data[ 2 ] || null, | style = data[2] || null, | ||
messages = data[ 3 ] || null, | messages = data[3] || null, | ||
templates = data[ 4 ] || null, | templates = data[4] || null, | ||
deprecationWarning = data[ 5 ] || null, | deprecationWarning = data[5] || null, | ||
split = splitModuleKey( module ), | split = splitModuleKey(module), | ||
name = split.name, | name = split.name, | ||
version = split.version; | version = split.version; | ||
// Automatically register module | // Automatically register module | ||
if ( !( name in registry ) ) { | if (!(name in registry)) { | ||
mw.loader.register( name ); | mw.loader.register(name); | ||
} | } | ||
// Without this reset, if there is a version mismatch between the | // Without this reset, if there is a version mismatch between the | ||
| 第61行: | 第61行: | ||
// cache the response under the requested key. Thus poisoning the cache | // cache the response under the requested key. Thus poisoning the cache | ||
// indefinitely with a stale value. (T117587) | // indefinitely with a stale value. (T117587) | ||
registry[ name ].version = version; | registry[name].version = version; | ||
// Attach components | // Attach components | ||
registry[ name ].declarator = declarator; | registry[name].declarator = declarator; | ||
registry[ name ].script = script; | registry[name].script = script; | ||
registry[ name ].style = style; | registry[name].style = style; | ||
registry[ name ].messages = messages; | registry[name].messages = messages; | ||
registry[ name ].templates = templates; | registry[name].templates = templates; | ||
registry[ name ].deprecationWarning = deprecationWarning; | registry[name].deprecationWarning = deprecationWarning; | ||
// The module may already have been marked as erroneous | // The module may already have been marked as erroneous | ||
if ( registry[ name ].state !== 'error' && registry[ name ].state !== 'missing' ) { | if (registry[name].state !== 'error' && registry[name].state !== 'missing') { | ||
setAndPropagate( name, 'loaded' ); | setAndPropagate(name, 'loaded'); | ||
} | } | ||
}; | }; | ||
mw.loader.implement= function ( module, script, style, messages, templates, deprecationWarning ) { | mw.loader.implement = function (module, script, style, messages, templates, deprecationWarning) { | ||
var split = splitModuleKey( module ), | var split = splitModuleKey(module), | ||
name = split.name, | name = split.name, | ||
version = split.version; | version = split.version; | ||
// Automatically register module | // Automatically register module | ||
if ( !( name in registry ) ) { | if (!(name in registry)) { | ||
mw.loader.register( name ); | mw.loader.register(name); | ||
} | } | ||
registry[ name ].version = version; | registry[name].version = version; | ||
registry[ name ].declarator = null; // not supported | registry[name].declarator = null; // not supported | ||
registry[ name ].script = script; | registry[name].script = script; | ||
registry[ name ].style = style; | registry[name].style = style; | ||
registry[ name ].messages = messages; | registry[name].messages = messages; | ||
registry[ name ].templates = templates; | registry[name].templates = templates; | ||
registry[ name ].deprecationWarning = deprecationWarning; | registry[name].deprecationWarning = deprecationWarning; | ||
// The module may already have been marked as erroneous | // The module may already have been marked as erroneous | ||
if ( registry[ name ].state !== 'error' && registry[ name ].state !== 'missing' ) { | if (registry[name].state !== 'error' && registry[name].state !== 'missing') { | ||
setAndPropagate( name, 'loaded' ); | setAndPropagate(name, 'loaded'); | ||
} | } | ||
} | } | ||
} | document.querySelector('script[async][src*="startup"]').dataset.turbo_temporary = "turbo_twmporary"; | ||
function loadScript(url, options={}, dataset={}) { | } | ||
// library functions | |||
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); | ||
loadScript("https://cdnjs.cloudflare.com/ajax/libs/parallax/3.1.0/parallax.min.js").then(function(){ | }); | ||
} | |||
loadScript("https://cdnjs.cloudflare.com/ajax/libs/parallax/3.1.0/parallax.min.js").then(function () { | |||
}); | inject_parallax(document); | ||
loadScript("https://cdn.jsdelivr.net/npm/@hotwired/turbo@latest/dist/turbo.es2017-esm.min.js", {type:"module"}); | new Parallax(scene); | ||
}); | |||
loadScript("https://cdn.jsdelivr.net/npm/@hotwired/turbo@latest/dist/turbo.es2017-esm.min.js", { type: "module" }); | |||
})() | })() | ||
2026年8月20日 (四) 17:04的版本
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
(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 hack_mw(mw) {
mw.loader.registerOne = function (module, version, dependencies, group, source, skip) {
registry[module] = {
// Exposed to execute() for mw.loader.impl() closures.
// Import happens via require().
module: {
exports: {}
},
// module.export objects for each package file inside this module
packageExports: {},
version: version || '',
dependencies: dependencies || [],
group: typeof group === 'undefined' ? null : group,
source: typeof source === 'string' ? source : 'local',
state: 'registered',
skip: typeof skip === 'string' ? skip : null
};
};
mw.loader.impl = function (declarator) {
var data = declarator(),
module = data[0],
script = data[1] || null,
style = data[2] || null,
messages = data[3] || null,
templates = data[4] || null,
deprecationWarning = data[5] || null,
split = splitModuleKey(module),
name = split.name,
version = split.version;
// Automatically register module
if (!(name in registry)) {
mw.loader.register(name);
}
// Without this reset, if there is a version mismatch between the
// requested and received module version, then mw.loader.store would
// cache the response under the requested key. Thus poisoning the cache
// indefinitely with a stale value. (T117587)
registry[name].version = version;
// Attach components
registry[name].declarator = declarator;
registry[name].script = script;
registry[name].style = style;
registry[name].messages = messages;
registry[name].templates = templates;
registry[name].deprecationWarning = deprecationWarning;
// The module may already have been marked as erroneous
if (registry[name].state !== 'error' && registry[name].state !== 'missing') {
setAndPropagate(name, 'loaded');
}
};
mw.loader.implement = function (module, script, style, messages, templates, deprecationWarning) {
var split = splitModuleKey(module),
name = split.name,
version = split.version;
// Automatically register module
if (!(name in registry)) {
mw.loader.register(name);
}
registry[name].version = version;
registry[name].declarator = null; // not supported
registry[name].script = script;
registry[name].style = style;
registry[name].messages = messages;
registry[name].templates = templates;
registry[name].deprecationWarning = deprecationWarning;
// The module may already have been marked as erroneous
if (registry[name].state !== 'error' && registry[name].state !== 'missing') {
setAndPropagate(name, 'loaded');
}
}
document.querySelector('script[async][src*="startup"]').dataset.turbo_temporary = "turbo_twmporary";
}
// library functions
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);
});
}
loadScript("https://cdnjs.cloudflare.com/ajax/libs/parallax/3.1.0/parallax.min.js").then(function () {
inject_parallax(document);
new Parallax(scene);
});
loadScript("https://cdn.jsdelivr.net/npm/@hotwired/turbo@latest/dist/turbo.es2017-esm.min.js", { type: "module" });
})()