mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-25 00:26:44 +00:00
9619727f3c
eslint-config-wikimedia 0.5.0 → 0.8.1 grunt-eslint 20.1.0 → 21.0.0 grunt-stylelint 0.9.0 → 0.10.1 stylelint 8.2.0 → 9.2.0 stylelint-config-wikimedia 0.4.2 → 0.4.3 Change-Id: I4c39a42f84303ee0d5d66032bf4cacd9e90821e9
42 lines
1 KiB
JavaScript
42 lines
1 KiB
JavaScript
( function () {
|
|
|
|
mw.hook( 'wikipage.content' ).add( function () {
|
|
var errors = mw.config.get( 'ScribuntoErrors' ),
|
|
regex = /^mw-scribunto-error-(\d+)/,
|
|
$dialog = $( '<div>' );
|
|
|
|
if ( !errors ) {
|
|
mw.log( 'mw.scribunto.errors: ScribuntoErrors does not exist in mw.config' );
|
|
errors = [];
|
|
}
|
|
|
|
$dialog.dialog( {
|
|
title: mw.msg( 'scribunto-parser-dialog-title' ),
|
|
autoOpen: false
|
|
} );
|
|
|
|
$( '.scribunto-error' ).each( function ( index, span ) {
|
|
var errorId,
|
|
matches = regex.exec( span.id );
|
|
if ( matches === null ) {
|
|
mw.log( 'mw.scribunto.errors: regex mismatch!' );
|
|
return;
|
|
}
|
|
errorId = parseInt( matches[ 1 ], 10 );
|
|
$( span ).on( 'click', function ( e ) {
|
|
var error = errors[ errorId ];
|
|
if ( typeof error !== 'string' ) {
|
|
mw.log( 'mw.scribunto.errors: error ' + matches[ 1 ] + ' not found.' );
|
|
return;
|
|
}
|
|
$dialog
|
|
.dialog( 'close' )
|
|
.html( error )
|
|
.dialog( 'option', 'position', [ e.clientX + 5, e.clientY + 5 ] )
|
|
.dialog( 'open' );
|
|
} );
|
|
} );
|
|
} );
|
|
|
|
}() );
|