MediaWiki:Vector.js: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(40 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* All JavaScript here will be loaded for users of the Vector skin */
/* All JavaScript here will be loaded for users of the Vector skin */
if (document.readyState === 'complete') {
bg3wikiVectorJsMain();
} else {
window.addEventListener('load', bg3wikiVectorJsMain);
}
function bg3wikiVectorJsMain() {
var reportAdsLink = document.querySelector('#n-Please-report-bad-ads a');
if (reportAdsLink) {
reportAdsLink.setAttribute("target", "_blank");
}
}


/*
/*
* Note that some of the CSS added when enabling ads is already applied via
function bg3wikiCheckAdBlock() {
* MW:Vector.css, but it's undone in MW:Group-user.css for logged-in users.
var adsEnabled = document.body.classList.contains("mw-ads-enabled");
*
if (adsEnabled && !window.fusetag && !window.ramp) {
* So do it again when ads are enabled explicitly, e.g. for testing.
bg3wikiAdBlockProbable();
*/
}
 
if (mw.config.values.wgUserId == null || mw.config.values.wgUserId == 1) {
bg3wikiEnableAds();
}
}


function bg3wikiEnableAds () {
function bg3wikiAdBlockProbable() {
bg3wikiEnableSiteNoticeAd();
bg3wikiCleanupHeaderAd();
bg3wikiEnableSidebarAd();
bg3wikiCleanupSidebarAd();
}
}


function bg3wikiEnableSiteNoticeAd() {
function bg3wikiCleanupHeaderAd() {
var siteNotice = document.getElementById("siteNotice");
var headerAd = document.getElementById("bg3wiki-header-ad");
if (siteNotice == null) {
if (!headerAd) {
return;
return;
}
}
var p = headerAd.querySelector("p");
var h1 = document.getElementById("firstHeading");
p.style.fontSize = '1em';
h1.style.maxWidth = "calc(100% - 468px - 16px)";
p.innerText = "Ad block user? No problem.\n" +
"You can log in to clean up the UI of placeholders like this.";
var indicators = document.getElementsByClassName("mw-indicators")[0];
indicators.style.marginRight = "16px";
var ad = document.createElement("div");
ad.id = "bg3wiki-sitenotice-ad";
ad.classList.add("bg3wiki-ad");
ad.style.width = "468px";
ad.style.height = "60px";
ad.style.float = "right";
ad.style.marginTop = "-17px";
ad.style.border = "2px dotted var(--bdr-color)";
ad.style.boxSizing = "border-box";
ad.style.alignContent = "center";
siteNotice.appendChild(ad);
var p = document.createElement("p");
p.style.textAlign = "center";
p.style.lineHeight = "1.5em";
p.style.fontSize = "1.1em";
p.style.fontStyle = "italic";
p.style.color = "var(--fg-dark)";
if (mw.config.values.wgUserId == 1) {
p.innerText = "Ad block user? No problem. If you want, you can\n" +
"log in to hide this ad placeholder.";
}
ad.appendChild(p);
}
}


function bg3wikiEnableSidebarAd() {
function bg3wikiCleanupSidebarAd() {
var ad = document.querySelector("#p-Advertisement > div");
var headerAd = document.getElementById("bg3wiki-sidebar-ad");
if (ad == null) {
if (!headerAd) {
return;
return;
}
}
var p = headerAd.querySelector("p");
ad.style.width = "160px";
p.style.fontSize = '0.7em';
ad.style.height = "600px";
p.innerText = "Ad block user? No problem.\n" +
ad.style.marginTop = "5px";
"You can log in to clean up the UI of placeholders like this.";
ad.style.border = "2px dotted var(--bdr-color)";
ad.style.boxSizing = "border-box";
ad.style.paddingLeft = "10px";
ad.style.paddingRight = "10px";
ad.style.alignContent = "center";
var sidebarSpecial = document.getElementById("p-Special");
sidebarSpecial.style.display = "none";
var sidebarToolbox = document.getElementById("p-tb");
sidebarToolbox.style.display = "none";
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)";
if (mw.config.values.wgUserId == 1) {
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);
}
}
}
*/

Latest revision as of 20:27, 18 September 2024

/* All JavaScript here will be loaded for users of the Vector skin */

if (document.readyState === 'complete') {
	bg3wikiVectorJsMain();
} else {
	window.addEventListener('load', bg3wikiVectorJsMain);
}

function bg3wikiVectorJsMain() {
	var reportAdsLink = document.querySelector('#n-Please-report-bad-ads a');
	if (reportAdsLink) {
		reportAdsLink.setAttribute("target", "_blank");
	}
}

/*
function bg3wikiCheckAdBlock() {
	var adsEnabled = document.body.classList.contains("mw-ads-enabled");
	if (adsEnabled && !window.fusetag && !window.ramp) {
		bg3wikiAdBlockProbable();
	}
}

function bg3wikiAdBlockProbable() {
	bg3wikiCleanupHeaderAd();
	bg3wikiCleanupSidebarAd();
}

function bg3wikiCleanupHeaderAd() {
	var headerAd = document.getElementById("bg3wiki-header-ad");
	if (!headerAd) {
		return;
	}
	var p = headerAd.querySelector("p");
	p.style.fontSize = '1em';
	p.innerText = "Ad block user? No problem.\n" +
		"You can log in to clean up the UI of placeholders like this.";
}

function bg3wikiCleanupSidebarAd() {
	var headerAd = document.getElementById("bg3wiki-sidebar-ad");
	if (!headerAd) {
		return;
	}
	var p = headerAd.querySelector("p");
	p.style.fontSize = '0.7em';
	p.innerText = "Ad block user? No problem.\n" +
		"You can log in to clean up the UI of placeholders like this.";
}
*/