| 1 |
'use strict'; |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
const CITE_BASELINE_LOGGING_SCHEMA = 'ext.cite.baseline'; |
| 16 |
|
| 17 |
|
| 18 |
const REFERENCE_PREVIEWS_LOGGING_SCHEMA = 'event.ReferencePreviewsPopups'; |
| 19 |
|
| 20 |
|
| 21 |
mw.loader.using( 'ext.eventLogging' ).then( () => { |
| 22 |
$( () => { |
| 23 |
if ( !navigator.sendBeacon || |
| 24 |
!mw.config.get( 'wgIsArticle' ) |
| 25 |
) { |
| 26 |
return; |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
mw.trackSubscribe( REFERENCE_PREVIEWS_LOGGING_SCHEMA, ( type, data ) => { |
| 31 |
if ( data.action.indexOf( 'anonymous' ) !== -1 ) { |
| 32 |
mw.config.set( 'wgCiteReferencePreviewsVisible', data.action === 'anonymousEnabled' ); |
| 33 |
} |
| 34 |
} ); |
| 35 |
|
| 36 |
|
| 37 |
$( '#mw-content-text' ).on( |
| 38 |
'click', |
| 39 |
|
| 40 |
'.reference a[ href*="#" ], .mw-reference-text a, .reference-text a', |
| 41 |
function () { |
| 42 |
const isInReferenceBlock = $( this ).parents( '.references' ).length > 0; |
| 43 |
mw.eventLog.dispatch( CITE_BASELINE_LOGGING_SCHEMA, { |
| 44 |
action: ( isInReferenceBlock ? |
| 45 |
'clickedReferenceContentLink' : |
| 46 |
'clickedFootnote' ), |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
with_ref_previews: mw.config.get( 'wgCiteReferencePreviewsVisible' ) |
| 51 |
} ); |
| 52 |
} |
| 53 |
); |
| 54 |
} ); |
| 55 |
} ); |