Jump to content

MediaWiki:Common.js: Difference between revisions

From CasinoLeaks
Footer redesign: two link columns, calmer 18+ notice, quiet last-edited bar (CURACAOFIL-6)
Footer: Terms of use, FAQ
Line 1: Line 1:
/* CasinoLeaks footer (CURACAOFIL-6). One block: 18+ notice, two link columns, small bottom line.
/* Footer links to the trust pages (CURACAOFIL-6). Owner-authorised 2026-11-05. */
  Replaces the default footer link row and the earlier trust-links and 18+ scripts. Owner-authorised 2026-11-05. */
mw.hook( 'wikipage.content' ).add( function () {
mw.hook( 'wikipage.content' ).add( function () {
var footer = document.querySelector( 'footer.mw-footer' ) || document.getElementById( 'footer' );
var places = document.getElementById( 'footer-places' );
if ( !footer || footer.querySelector( '.clf' ) ) {
if ( !places || places.querySelector( '[data-trust-links]' ) ) {
return;
return;
}
}
function el( tag, cls, text ) {
[ [ 'Methodology', 'CasinoLeaks:Methodology' ], [ 'Sources and coverage', 'CasinoLeaks:Sources_and_coverage' ], [ 'Corrections policy', 'CasinoLeaks:Corrections_policy' ], [ 'Editorial standards', 'CasinoLeaks:Editorial_standards' ], [ 'Funding and independence', 'CasinoLeaks:Funding_and_independence' ], [ 'Terms of use', 'CasinoLeaks:Terms_of_use' ], [ 'FAQ', 'CasinoLeaks:FAQ' ], [ 'Team and experts', 'CasinoLeaks:Team_and_experts' ], [ 'Contact', 'CasinoLeaks:Contact' ] ].forEach( function ( item ) {
var n = document.createElement( tag );
var li = document.createElement( 'li' ), a = document.createElement( 'a' );
if ( cls ) { n.className = cls; }
li.setAttribute( 'data-trust-links', '1' );
if ( text ) { n.textContent = text; }
a.href = mw.util.getUrl( item[ 1 ] );
return n;
a.textContent = item[ 0 ];
}
li.appendChild( a );
function link( label, target, external ) {
places.appendChild( li );
var a = el( 'a', null, label );
if ( external ) {
a.href = target; a.rel = 'noopener nofollow'; a.target = '_blank';
} else {
a.href = mw.util.getUrl( target );
}
return a;
}
var box = el( 'div', 'clf' );
 
var rg = el( 'div', 'clf-rg' );
rg.appendChild( el( 'span', 'clf-age', '18+' ) );
var p = el( 'p' );
p.appendChild( el( 'strong', null, 'Gambling can be addictive.' ) );
p.appendChild( document.createTextNode( ' This site is for information only and is not an invitation to gamble. Need help? ' ) );
p.appendChild( link( 'GambleAware', 'https://www.gambleaware.org', true ) );
p.appendChild( document.createTextNode( ', ' ) );
p.appendChild( link( 'Gambling Therapy', 'https://gamblingtherapy.org', true ) );
p.appendChild( document.createTextNode( ' or ' ) );
p.appendChild( link( 'more help', 'CasinoLeaks:Get_help' ) );
p.appendChild( document.createTextNode( '.' ) );
rg.appendChild( p );
box.appendChild( rg );
 
var nav = el( 'nav', 'clf-nav' );
nav.setAttribute( 'aria-label', 'About CasinoLeaks' );
[
[ 'About', [ [ 'About us', 'CasinoLeaks:About' ], [ 'Methodology', 'CasinoLeaks:Methodology' ], [ 'Sources and coverage', 'CasinoLeaks:Sources_and_coverage' ], [ 'Independence', 'CasinoLeaks:Funding_and_independence' ], [ 'Team and experts', 'CasinoLeaks:Team_and_experts' ] ] ],
[ 'Help', [ [ 'Corrections', 'CasinoLeaks:Corrections_policy' ], [ 'Report an error', 'CasinoLeaks:Report_an_error' ], [ 'Contact', 'CasinoLeaks:Contact' ], [ 'Privacy', 'CasinoLeaks:Privacy_policy' ], [ 'Disclaimer', 'CasinoLeaks:General_disclaimer' ] ] ]
].forEach( function ( group ) {
var col = el( 'div', 'clf-col' );
col.appendChild( el( 'div', 'clf-head', group[ 0 ] ) );
var ul = el( 'ul' );
group[ 1 ].forEach( function ( item ) {
var li = el( 'li' );
li.appendChild( link( item[ 0 ], item[ 1 ] ) );
ul.appendChild( li );
} );
col.appendChild( ul );
nav.appendChild( col );
} );
} );
box.appendChild( nav );
var bottom = el( 'div', 'clf-bottom' );
bottom.appendChild( el( 'span', null, '© ' + new Date().getFullYear() + ' CasinoLeaks · Sourced and dated facts about online gambling' ) );
var toggle = document.getElementById( 'mw-mf-display-toggle' ) || document.querySelector( '#footer-places-mobileview a' );
if ( toggle ) {
var t = link( toggle.textContent, '' );
t.href = toggle.href;
bottom.appendChild( t );
}
box.appendChild( bottom );
var anchor = footer.querySelector( '.footer-content' ) || footer;
anchor.insertBefore( box, anchor.firstChild );
document.documentElement.classList.add( 'clf-ready' );
} );
} );


/* Last-edited bar on phones: show when, not which account (CURACAOFIL-6). */
/* 18+ notice and independent help resources in the footer (CURACAOFIL-6) */
mw.hook( 'wikipage.content' ).add( function () {
mw.hook( 'wikipage.content' ).add( function () {
var t = document.querySelector( '.last-modified-bar__text' );
var footer = document.querySelector( 'footer' ) || document.getElementById( 'footer' );
if ( !t || t.getAttribute( 'data-clf' ) ) {
if ( !footer || footer.querySelector( '.cl-rg' ) ) {
return;
return;
}
}
t.setAttribute( 'data-clf', '1' );
var box = document.createElement( 'div' );
function tidy() {
box.className = 'cl-rg';
var m = t.textContent.replace( /\s+/g, ' ' ).trim().match( /^(.*?) by .+$/ );
box.style.cssText = 'display:flex;align-items:center;gap:1em;margin:0 0 1.2em;padding:1em 1.2em;border:1px solid #d33;border-left:6px solid #d33;border-radius:4px;background:#fff4f4;font-size:1em;line-height:1.55;color:#202122';
if ( m ) {
var links = [ [ 'GambleAware', 'https://www.gambleaware.org' ], [ 'GamCare', 'https://www.gamcare.org.uk' ], [ 'GAMSTOP', 'https://www.gamstop.co.uk' ], [ 'Gambling Therapy', 'https://gamblingtherapy.org' ], [ 'NCPG', 'https://www.ncpgambling.org' ] ];
t.textContent = m[ 1 ];
var b = document.createElement( 'span' );
}
b.textContent = '18+';
}
b.style.cssText = 'flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:3.2em;height:3.2em;border-radius:50%;background:#d33;color:#fff;font-weight:bold;font-size:1.1em';
tidy();
box.appendChild( b );
new MutationObserver( tidy ).observe( t, { childList: true, subtree: true, characterData: true } );
var txt = document.createElement( 'div' );
var lead = document.createElement( 'strong' );
lead.textContent = 'Gambling can be addictive. ';
txt.appendChild( lead );
txt.appendChild( document.createTextNode( 'This site is for information only and is not an invitation to gamble. You must be of legal age. Need help? ' ) );
box.appendChild( txt );
links.forEach( function ( l, i ) {
var a = document.createElement( 'a' );
a.href = l[ 1 ]; a.textContent = l[ 0 ]; a.rel = 'noopener nofollow'; a.target = '_blank';
txt.appendChild( a );
txt.appendChild( document.createTextNode( i < links.length - 1 ? ' · ' : ' · ' ) );
} );
var more = document.createElement( 'a' );
more.href = mw.util.getUrl( 'CasinoLeaks:Get_help' ); more.textContent = 'More help';
txt.appendChild( more );
footer.insertBefore( box, footer.firstChild );
} );
} );

Revision as of 23:16, 5 November 2026

/* Footer links to the trust pages (CURACAOFIL-6). Owner-authorised 2026-11-05. */
mw.hook( 'wikipage.content' ).add( function () {
	var places = document.getElementById( 'footer-places' );
	if ( !places || places.querySelector( '[data-trust-links]' ) ) {
		return;
	}
	[ [ 'Methodology', 'CasinoLeaks:Methodology' ], [ 'Sources and coverage', 'CasinoLeaks:Sources_and_coverage' ], [ 'Corrections policy', 'CasinoLeaks:Corrections_policy' ], [ 'Editorial standards', 'CasinoLeaks:Editorial_standards' ], [ 'Funding and independence', 'CasinoLeaks:Funding_and_independence' ], [ 'Terms of use', 'CasinoLeaks:Terms_of_use' ], [ 'FAQ', 'CasinoLeaks:FAQ' ], [ 'Team and experts', 'CasinoLeaks:Team_and_experts' ], [ 'Contact', 'CasinoLeaks:Contact' ] ].forEach( function ( item ) {
		var li = document.createElement( 'li' ), a = document.createElement( 'a' );
		li.setAttribute( 'data-trust-links', '1' );
		a.href = mw.util.getUrl( item[ 1 ] );
		a.textContent = item[ 0 ];
		li.appendChild( a );
		places.appendChild( li );
	} );
} );

/* 18+ notice and independent help resources in the footer (CURACAOFIL-6) */
mw.hook( 'wikipage.content' ).add( function () {
	var footer = document.querySelector( 'footer' ) || document.getElementById( 'footer' );
	if ( !footer || footer.querySelector( '.cl-rg' ) ) {
		return;
	}
	var box = document.createElement( 'div' );
	box.className = 'cl-rg';
	box.style.cssText = 'display:flex;align-items:center;gap:1em;margin:0 0 1.2em;padding:1em 1.2em;border:1px solid #d33;border-left:6px solid #d33;border-radius:4px;background:#fff4f4;font-size:1em;line-height:1.55;color:#202122';
	var links = [ [ 'GambleAware', 'https://www.gambleaware.org' ], [ 'GamCare', 'https://www.gamcare.org.uk' ], [ 'GAMSTOP', 'https://www.gamstop.co.uk' ], [ 'Gambling Therapy', 'https://gamblingtherapy.org' ], [ 'NCPG', 'https://www.ncpgambling.org' ] ];
	var b = document.createElement( 'span' );
	b.textContent = '18+';
	b.style.cssText = 'flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:3.2em;height:3.2em;border-radius:50%;background:#d33;color:#fff;font-weight:bold;font-size:1.1em';
	box.appendChild( b );
	var txt = document.createElement( 'div' );
	var lead = document.createElement( 'strong' );
	lead.textContent = 'Gambling can be addictive. ';
	txt.appendChild( lead );
	txt.appendChild( document.createTextNode( 'This site is for information only and is not an invitation to gamble. You must be of legal age. Need help? ' ) );
	box.appendChild( txt );
	links.forEach( function ( l, i ) {
		var a = document.createElement( 'a' );
		a.href = l[ 1 ]; a.textContent = l[ 0 ]; a.rel = 'noopener nofollow'; a.target = '_blank';
		txt.appendChild( a );
		txt.appendChild( document.createTextNode( i < links.length - 1 ? ' · ' : ' · ' ) );
	} );
	var more = document.createElement( 'a' );
	more.href = mw.util.getUrl( 'CasinoLeaks:Get_help' ); more.textContent = 'More help';
	txt.appendChild( more );
	footer.insertBefore( box, footer.firstChild );
} );