MediaWiki:Vector.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 17: | Line 17: | ||
document.body.classList.add("mw-ads-enabled"); | document.body.classList.add("mw-ads-enabled"); | ||
bg3wikiEnableHeaderAd(); | |||
bg3wikiEnableSidebarAd(); | bg3wikiEnableSidebarAd(); | ||
} | } | ||
function | function bg3wikiEnableHeaderAd() { | ||
var ad = document.getElementById("bg3wiki- | var ad = document.getElementById("bg3wiki-header-ad"); | ||
if (ad == null) { | if (ad == null) { | ||
return; | return; |
Revision as of 21:28, 7 August 2024
/* All JavaScript here will be loaded for users of the Vector skin */
/*
* Note that some of the style changes that are applied when enabling ads are
* already applied via MW:Vector.css, but only for anonymous visitors, so apply
* them again in case ads are enabled explicitly, e.g. for testing.
*/
if (mw.config.get("wgUserId") == null) {
bg3wikiEnableAds();
}
function bg3wikiEnableAds () {
// This class is normally added through a hook in LocalSettings.php, when
// the visitor is not a logged-in user. The class is added here as well,
// since this function could be called for testing purposes.
document.body.classList.add("mw-ads-enabled");
bg3wikiEnableHeaderAd();
bg3wikiEnableSidebarAd();
}
function bg3wikiEnableHeaderAd() {
var ad = document.getElementById("bg3wiki-header-ad");
if (ad == null) {
return;
}
// TODO
}
function bg3wikiEnableSidebarAd() {
var ad = document.querySelector("#p-Advertisement > div");
if (ad == null) {
return;
}
// TODO
if (false) {
var p = document.createElement("p");
p.style.textAlign = "center";
p.style.lineHeight = "1.5em";
p.style.fontSize = "0.9em";
p.style.fontStyle = "italic";
p.style.color = "var(--fg-dark)";
p.innerText = "Ad block user?\nNo problem.\n\n" +
"If you want, you can log in to hide this ad placeholder.";
ad.innerHTML = "";
ad.appendChild(p);
}
}