2018-11-03 13:14:53 +00:00
|
|
|
( function () {
|
2015-01-23 21:36:55 +00:00
|
|
|
|
|
|
|
mw.hook( 'wikipage.content' ).add( function () {
|
2023-08-07 22:11:46 +00:00
|
|
|
var regex = /^mw-scribunto-error-(\w+)/,
|
2022-10-05 00:19:08 +00:00
|
|
|
popup;
|
2015-01-23 21:36:55 +00:00
|
|
|
|
|
|
|
$( '.scribunto-error' ).each( function ( index, span ) {
|
2023-08-07 22:11:46 +00:00
|
|
|
var matches = regex.exec( span.id );
|
2015-01-23 21:36:55 +00:00
|
|
|
if ( matches === null ) {
|
|
|
|
mw.log( 'mw.scribunto.errors: regex mismatch!' );
|
|
|
|
return;
|
|
|
|
}
|
2022-10-05 00:19:08 +00:00
|
|
|
var $span = $( span );
|
|
|
|
$span.on( 'click', function () {
|
2023-08-07 22:11:46 +00:00
|
|
|
var error = mw.config.get( 'ScribuntoErrors-' + matches[ 1 ] );
|
2015-01-23 21:36:55 +00:00
|
|
|
if ( typeof error !== 'string' ) {
|
2015-09-12 15:21:20 +00:00
|
|
|
mw.log( 'mw.scribunto.errors: error ' + matches[ 1 ] + ' not found.' );
|
2015-01-23 21:36:55 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-10-05 00:19:08 +00:00
|
|
|
|
|
|
|
if ( !popup ) {
|
|
|
|
popup = new OO.ui.PopupWidget( {
|
|
|
|
padded: true,
|
|
|
|
head: true,
|
|
|
|
label: $( '<div>' )
|
|
|
|
.text( mw.msg( 'scribunto-parser-dialog-title' ) )
|
|
|
|
.addClass( 'scribunto-error-label' )
|
|
|
|
} );
|
|
|
|
OO.ui.getDefaultOverlay().append( popup.$element );
|
|
|
|
}
|
|
|
|
popup.$body.html( error );
|
|
|
|
popup.setFloatableContainer( $span );
|
|
|
|
popup.toggle( true );
|
2015-01-23 21:36:55 +00:00
|
|
|
} );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
2018-11-03 13:14:53 +00:00
|
|
|
}() );
|