MediaWiki:Common.js: Difference between revisions
Appearance
Footer: Funding and independence |
Footer redesign: two link columns, calmer 18+ notice, quiet last-edited bar (CURACAOFIL-6) |
||
| Line 1: | Line 1: | ||
/* | /* 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 | var footer = document.querySelector( 'footer.mw-footer' ) || document.getElementById( 'footer' ); | ||
if ( ! | if ( !footer || footer.querySelector( '.clf' ) ) { | ||
return; | return; | ||
} | } | ||
[ [ 'Methodology', 'CasinoLeaks:Methodology' ], [ 'Sources and coverage', 'CasinoLeaks:Sources_and_coverage' ], [ 'Corrections | function el( tag, cls, text ) { | ||
var | var n = document.createElement( tag ); | ||
if ( cls ) { n.className = cls; } | |||
if ( text ) { n.textContent = text; } | |||
return n; | |||
} | |||
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' ); | |||
} ); | } ); | ||
/* | /* Last-edited bar on phones: show when, not which account (CURACAOFIL-6). */ | ||
mw.hook( 'wikipage.content' ).add( function () { | mw.hook( 'wikipage.content' ).add( function () { | ||
var | var t = document.querySelector( '.last-modified-bar__text' ); | ||
if ( ! | if ( !t || t.getAttribute( 'data-clf' ) ) { | ||
return; | return; | ||
} | } | ||
t.setAttribute( 'data-clf', '1' ); | |||
function tidy() { | |||
var m = t.textContent.replace( /\s+/g, ' ' ).trim().match( /^(.*?) by .+$/ ); | |||
if ( m ) { | |||
t.textContent = m[ 1 ]; | |||
} | |||
} | |||
tidy(); | |||
new MutationObserver( tidy ).observe( t, { childList: true, subtree: true, characterData: true } ); | |||
} | |||
} ); | } ); | ||
Revision as of 23:15, 5 November 2026
/* 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 () {
var footer = document.querySelector( 'footer.mw-footer' ) || document.getElementById( 'footer' );
if ( !footer || footer.querySelector( '.clf' ) ) {
return;
}
function el( tag, cls, text ) {
var n = document.createElement( tag );
if ( cls ) { n.className = cls; }
if ( text ) { n.textContent = text; }
return n;
}
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' );
} );
/* Last-edited bar on phones: show when, not which account (CURACAOFIL-6). */
mw.hook( 'wikipage.content' ).add( function () {
var t = document.querySelector( '.last-modified-bar__text' );
if ( !t || t.getAttribute( 'data-clf' ) ) {
return;
}
t.setAttribute( 'data-clf', '1' );
function tidy() {
var m = t.textContent.replace( /\s+/g, ' ' ).trim().match( /^(.*?) by .+$/ );
if ( m ) {
t.textContent = m[ 1 ];
}
}
tidy();
new MutationObserver( tidy ).observe( t, { childList: true, subtree: true, characterData: true } );
} );