Fix debug mode after language variant changes

Follow-up to 329df8c953.

Change-Id: I49f7d580a7e7c5dde7c234ca8905157e6a0f4f5d
This commit is contained in:
Bartosz Dziewoński 2020-09-24 19:32:13 +02:00
parent 2a03b6e420
commit ca41a405ec
2 changed files with 9 additions and 6 deletions

View file

@ -4,7 +4,7 @@ var
parser = new Parser( document.getElementById( 'mw-content-text' ) ),
comments = parser.getCommentItems(),
threads = parser.getThreads(),
timestampRegex = parser.getLocalTimestampRegexp();
timestampRegexps = parser.getLocalTimestampRegexps();
highlighter.markThreads( threads );
@ -13,7 +13,10 @@ comments.forEach( function ( comment ) {
var signature, emptySignature, node, match;
node = comment.range.endContainer;
match = parser.findTimestamp( node, timestampRegex );
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

View file

@ -4,18 +4,18 @@ var initialOffset, indentWidth;
function markTimestamp( parser, node, match ) {
var
dfParser = parser.getLocalTimestampParser(),
dfParsers = parser.getLocalTimestampParsers(),
newNode, wrapper, date;
newNode = node.splitText( match.index );
newNode.splitText( match[ 0 ].length );
newNode = node.splitText( match.matchData.index );
newNode.splitText( match.matchData[ 0 ].length );
wrapper = document.createElement( 'span' );
wrapper.className = 'detected-timestamp';
// We might need to actually port all the date formatting code from MediaWiki's PHP code
// if we want to support displaying dates in all the formats available in user preferences
// (which include formats in several non-Gregorian calendars).
date = dfParser( match );
date = dfParsers[ match.parserIndex ]( match.matchData );
wrapper.title = date.format() + ' / ' + date.fromNow();
wrapper.appendChild( newNode );
node.parentNode.insertBefore( wrapper, node.nextSibling );