2019-10-24 14:38:31 +00:00
|
|
|
var
|
2020-07-20 21:15:03 +00:00
|
|
|
Parser = require( 'ext.discussionTools.init' ).Parser,
|
2019-10-24 14:38:31 +00:00
|
|
|
highlighter = require( './highlighter.js' ),
|
2020-07-20 21:15:03 +00:00
|
|
|
parser = new Parser( document.getElementById( 'mw-content-text' ) ),
|
|
|
|
comments = parser.getCommentItems(),
|
|
|
|
threads = parser.getThreads(),
|
2020-09-24 17:32:13 +00:00
|
|
|
timestampRegexps = parser.getLocalTimestampRegexps();
|
2019-10-24 14:38:31 +00:00
|
|
|
|
|
|
|
highlighter.markThreads( threads );
|
|
|
|
|
2020-07-10 14:16:49 +00:00
|
|
|
comments.forEach( function ( comment ) {
|
2020-12-12 12:50:14 +00:00
|
|
|
comment.signatureRanges.forEach( function ( signatureRange ) {
|
|
|
|
var signature, emptySignature, node, match;
|
2020-07-10 14:16:49 +00:00
|
|
|
|
2020-12-12 12:50:14 +00:00
|
|
|
node = signatureRange.endContainer;
|
|
|
|
match = parser.findTimestamp( node, timestampRegexps );
|
|
|
|
if ( !match ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
signature = parser.findSignature( node )[ 0 ];
|
|
|
|
emptySignature = signature.length === 1 && signature[ 0 ] === node;
|
|
|
|
// Note that additional content may follow the timestamp (e.g. in some voting formats), but we
|
|
|
|
// don't care about it. The code below doesn't mark that due to now the text nodes are sliced,
|
|
|
|
// but we might need to take care to use the matched range of node in other cases.
|
|
|
|
highlighter.markTimestamp( parser, node, match );
|
|
|
|
if ( !emptySignature ) {
|
|
|
|
highlighter.markSignature( signature );
|
|
|
|
}
|
|
|
|
} );
|
2020-07-10 14:16:49 +00:00
|
|
|
} );
|