Debian Codegraph @

extensions/Scribunto/modules/ext.scribunto.errors.js

raw symbols SCIP
1 ( () => {
2
3 mw.hook( 'wikipage.content' ).add( () => {
4 const regex = /\bmw-scribunto-error-(\w+)\b/;
5 let popup;
6
7 $( '.scribunto-error' ).each( ( index, span ) => {
8 let matches = regex.exec( span.className );
9 if ( matches === null ) {
10 // T375539: backward-compatibility with old cached HTML
11 matches = regex.exec( span.id );
12 }
13 if ( matches === null ) {
14 mw.log( 'mw.scribunto.errors: regex mismatch!' );
15 return;
16 }
17 const $span = $( span );
18 $span.on( 'click', () => {
19 const error = mw.config.get( 'ScribuntoErrors-' + matches[ 1 ] );
20 if ( typeof error !== 'string' ) {
21 mw.log( 'mw.scribunto.errors: error ' + matches[ 1 ] + ' not found.' );
22 return;
23 }
24
25 if ( !popup ) {
26 popup = new OO.ui.PopupWidget( {
27 padded: true,
28 head: true,
29 label: $( '<div>' )
30 .text( mw.msg( 'scribunto-parser-dialog-title' ) )
31 .addClass( 'scribunto-error-label' )
32 } );
33 OO.ui.getDefaultOverlay().append( popup.$element );
34 }
35 popup.$body.html( error );
36 popup.setFloatableContainer( $span );
37 popup.toggle( true );
38 } );
39 } );
40 } );
41
42 } )();