MediaWiki:Common.js: Difference between revisions
Footer: more prominent 18+ notice |
Footer: add editorial standards, editing policy, join the team, FAQ, terms |
||
| (5 intermediate revisions by the same user not shown) | |||
| 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' ], [ ' | 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' ], [ 'Editorial standards', 'CasinoLeaks:Editorial_standards' ], [ 'Independence', 'CasinoLeaks:Funding_and_independence' ], [ 'Editing policy', 'CasinoLeaks:Editing_policy' ], [ 'Team and experts', 'CasinoLeaks:Team_and_experts' ], [ 'Join the team', 'CasinoLeaks:Join_the_team' ] ] ], | |||
[ 'Help', [ [ 'FAQ', 'CasinoLeaks:FAQ' ], [ 'Corrections', 'CasinoLeaks:Corrections_policy' ], [ 'Report an error', 'CasinoLeaks:Report_an_error' ], [ 'Contact', 'CasinoLeaks:Contact' ], [ 'Privacy', 'CasinoLeaks:Privacy_policy' ], [ 'Terms of use', 'CasinoLeaks:Terms_of_use' ], [ '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). | ||
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 | var bar = document.querySelector( '.last-modified-bar' ); | ||
if ( ! | if ( !bar || bar.getAttribute( 'data-clf' ) ) { | ||
return; | return; | ||
} | } | ||
bar.setAttribute( 'data-clf', '1' ); | |||
function tidy() { | |||
var t = bar.querySelector( '.last-modified-bar__text' ); | |||
var m = t && t.textContent.replace( /\s+/g, ' ' ).trim().match( /^(.*?) by .+$/ ); | |||
if ( m ) { | |||
t.textContent = m[ 1 ]; | |||
} | |||
} | |||
tidy(); | |||
new MutationObserver( tidy ).observe( bar, { childList: true, subtree: true, characterData: true } ); | |||
} | |||
} ); | } ); | ||