MediaWiki:Mobile.js: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 8: Line 8:


function bg3wikiEnableAds() {
function bg3wikiEnableAds() {
// The "header" is actually at the bottom.
var header = document.getElementsByClassName("citizen-header")[0];
header.style.bottom = "50px";
// Floating page actions thingy above the "header"
var actions = document.getElementsByClassName("page-actions")[0];
actions.style.bottom = "calc(50px + var(--header-size) + var(--space-xs))";
// Actual page contents
var content = document.getElementsByClassName("citizen-page-container")[0];
content.style.marginBottom = "50px";
var ad = document.createElement("div");
var ad = document.createElement("div");
ad.id = "bg3wiki-footer-ad";
ad.id = "bg3wiki-footer-ad";
Line 17: Line 29:
ad.style.zIndex = "999";
ad.style.zIndex = "999";
ad.style.background = "var(--color-surface-3)";
ad.style.background = "var(--color-surface-3)";
ad.style.alignContent = "center";
document.body.appendChild(ad);
document.body.appendChild(ad);
var header = document.getElementsByClassName("citizen-header")[0];
var p = document.createElement("p");
header.style.bottom = "50px";
p.style.textAlign = "center";
p.style.fontSize = "0.9em";
var content = document.getElementsByClassName("citizen-page-container")[0];
p.style.fontStyle = "italic";
content.style.marginBottom = "50px";
p.style.color = "var(--color-subtle)";
p.innerText = "Ad placeholder";
var actions = document.getElementsByClassName("page-actions")[0];
ad.appendChild(p);
actions.style.bottom = "calc(50px + var(--header-size) + var(--space-xs))";
}
}
/*
(function () {
var launchDayMaxPageId = 6545;
if (
mw.config.get("wgIsMainPage") ||
mw.config.get("wgNamespaceNumber") !== 0 ||
mw.config.get("wgArticleId") > launchDayMaxPageId ||
mw.config.get("wgAction") !== "view"
) {
return;
}
    if (
    document.getElementById("bg3wiki-uptodate-notice") ||
    document.getElementById("bg3wiki-legacy-content-notice")
    ) {
    return;
    }
var notice = document.getElementById("siteNotice");
notice.style.margin = "10px 10px 0";
notice.style.fontWeight = "bold";
notice.style.color = "yellow"
notice.innerHTML =
"This page was created during Early Access. " +
"It may not be up to date with the release version.";
})();
*/
/*
(function () {
var notice = document.getElementById("bg3wiki-downtime-notice");
if (notice && new Date().getMonth() + 1 == 9) {
notice.style.display = 'block';
}
})();
*/

Revision as of 16:12, 7 August 2024

/* All JavaScript here will be loaded for users of the mobile site */

var userId = mw.config.get("wgUserId");

if (userId == 1) {
	bg3wikiEnableAds();
}

function bg3wikiEnableAds() {
	// The "header" is actually at the bottom.
	var header = document.getElementsByClassName("citizen-header")[0];
	header.style.bottom = "50px";
	
	// Floating page actions thingy above the "header"
	var actions = document.getElementsByClassName("page-actions")[0];
	actions.style.bottom = "calc(50px + var(--header-size) + var(--space-xs))";
	
	// Actual page contents
	var content = document.getElementsByClassName("citizen-page-container")[0];
	content.style.marginBottom = "50px";
	
	var ad = document.createElement("div");
	ad.id = "bg3wiki-footer-ad";
	ad.classList.add("bg3wiki-ad");
	ad.style.height = "50px";
	ad.style.width = "100%";
	ad.style.position = "fixed";
	ad.style.bottom = "0";
	ad.style.zIndex = "999";
	ad.style.background = "var(--color-surface-3)";
	ad.style.alignContent = "center";
	document.body.appendChild(ad);
	
	var p = document.createElement("p");
	p.style.textAlign = "center";
	p.style.fontSize = "0.9em";
	p.style.fontStyle = "italic";
	p.style.color = "var(--color-subtle)";
	p.innerText = "Ad placeholder";
	ad.appendChild(p);
}