MediaWiki:Common.js: Difference between revisions

Footer: Terms of use, FAQ
Footer redesign: two link columns, calmer 18+ notice, quiet last-edited bar (CURACAOFIL-6)
Line 1: Line 1:
/* Footer links to the trust pages (CURACAOFIL-6). Owner-authorised 2026-11-05. */
/* CasinoLeaks footer (CURACAOFIL-6). One block: 18+ notice, two link columns, small bottom line.
  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 places = document.getElementById( 'footer-places' );
var footer = document.querySelector( 'footer.mw-footer' ) || document.getElementById( 'footer' );
if ( !places || places.querySelector( '[data-trust-links]' ) ) {
if ( !footer || footer.querySelector( '.clf' ) ) {
return;
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 ) {
function el( tag, cls, text ) {
var li = document.createElement( 'li' ), a = document.createElement( 'a' );
var n = document.createElement( tag );
li.setAttribute( 'data-trust-links', '1' );
if ( cls ) { n.className = cls; }
a.href = mw.util.getUrl( item[ 1 ] );
if ( text ) { n.textContent = text; }
a.textContent = item[ 0 ];
return n;
li.appendChild( a );
}
places.appendChild( li );
function link( label, target, external ) {
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' );
} );
} );


/* 18+ notice and independent help resources in the footer (CURACAOFIL-6) */
/* Last-edited bar on phones: show when, not which account (CURACAOFIL-6).
  Minerva replaces the text node after load, so watch the whole bar and re-query each time. */
mw.hook( 'wikipage.content' ).add( function () {
mw.hook( 'wikipage.content' ).add( function () {
var footer = document.querySelector( 'footer' ) || document.getElementById( 'footer' );
var bar = document.querySelector( '.last-modified-bar' );
if ( !footer || footer.querySelector( '.cl-rg' ) ) {
if ( !bar || bar.getAttribute( 'data-clf' ) ) {
return;
return;
}
}
var box = document.createElement( 'div' );
bar.setAttribute( 'data-clf', '1' );
box.className = 'cl-rg';
function tidy() {
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 t = bar.querySelector( '.last-modified-bar__text' );
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 m = t && t.textContent.replace( /\s+/g, ' ' ).trim().match( /^(.*?) by .+$/ );
var b = document.createElement( 'span' );
if ( m ) {
b.textContent = '18+';
t.textContent = m[ 1 ];
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' );
tidy();
var lead = document.createElement( 'strong' );
new MutationObserver( tidy ).observe( bar, { childList: true, subtree: true, characterData: true } );
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 );
} );
} );