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() {
|
2021-01-25 22:30:48 +00:00
|
|
|
var id = location.hash.slice( 1 ),
|
2021-02-18 05:48:45 +00:00
|
|
|
// Don't assume location.hash will be parseable as a selector (T271572)
|
2021-01-25 22:30:48 +00:00
|
|
|
// and avoid warning when id is empty (T272844)
|
2021-02-18 05:48:45 +00:00
|
|
|
line = id ? document.getElementById( id ) : null;
|
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();
|
|
|
|
|
|
|
|
}() );
|