mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-11-28 00:01:10 +00:00
63c5943a9f
The 'hll' CSS only targets the .linenos selector, but it doesn't hurt to avoid unnecessary DOM changes. Change-Id: Ic7134619606c6e4abc2480ddc9650d0352fc33da
31 lines
571 B
JavaScript
31 lines
571 B
JavaScript
$( function () {
|
|
|
|
var $lastLine;
|
|
|
|
function onHashChange() {
|
|
// Don't assume location.hash will be parseable as an ID (T271572)
|
|
var $line = $( document.getElementById( location.hash.slice( 1 ) ) || [] );
|
|
|
|
if ( !$line.closest( '.mw-highlight' ).length ) {
|
|
// Matched ID wasn't in a highlight block
|
|
$line = $( [] );
|
|
}
|
|
|
|
if ( $lastLine ) {
|
|
$lastLine.removeClass( 'hll' );
|
|
}
|
|
|
|
if ( $line.length ) {
|
|
$line.addClass( 'hll' );
|
|
}
|
|
|
|
$lastLine = $line;
|
|
}
|
|
|
|
$( window ).on( 'hashchange', onHashChange );
|
|
|
|
// Check hash on load
|
|
onHashChange();
|
|
|
|
}() );
|