2021-01-01 19:48:57 +00:00
|
|
|
$( function () {
|
|
|
|
|
2021-02-18 05:48:45 +00:00
|
|
|
var lastLine;
|
2021-01-01 19:48:57 +00:00
|
|
|
|
|
|
|
function onHashChange() {
|
2022-08-22 15:29:22 +00:00
|
|
|
var line = mw.util.getTargetFromFragment();
|
2021-01-13 20:47:41 +00:00
|
|
|
|
2021-02-18 05:48:45 +00:00
|
|
|
if ( lastLine ) {
|
|
|
|
lastLine.classList.remove( 'hll' );
|
2021-01-01 19:48:57 +00:00
|
|
|
}
|
|
|
|
|
2021-02-18 05:48:45 +00:00
|
|
|
// Support IE 11, Edge 14, Safari 7: Can't use unprefixed Element.matches('… *') yet.
|
|
|
|
if ( !line || !$( line ).closest( '.mw-highlight' ).length ) {
|
|
|
|
// Matched ID wasn't in a highlight block
|
|
|
|
lastLine = null;
|
|
|
|
return;
|
2021-01-01 19:48:57 +00:00
|
|
|
}
|
|
|
|
|
2021-02-18 05:48:45 +00:00
|
|
|
line.classList.add( 'hll' );
|
|
|
|
lastLine = line;
|
2021-01-01 19:48:57 +00:00
|
|
|
}
|
|
|
|
|
2021-02-18 05:48:45 +00:00
|
|
|
window.addEventListener( 'hashchange', onHashChange );
|
2021-01-01 19:48:57 +00:00
|
|
|
|
|
|
|
// Check hash on load
|
|
|
|
onHashChange();
|
|
|
|
|
|
|
|
}() );
|