Content deleted Content added
lint |
fixes |
||
(One intermediate revision by the same user not shown) | |||
Line 136:
const utcOffset =
utcValue >= 0 ? `+${utcValue}` : `−${Math.abs(utcValue.toFixed(1))}`;
const utcPart = `(UTC${utcOffset})`;
const returnDate = this.LocalComments.timeFirst
? `${finalTime}, ${date}
: `${date}, ${finalTime}
return
}
Line 202 ⟶ 204:
}
▲ formattedDayOfTheWeek = `, ${last}${dayOfTheWeek}`;
}▼
▲ return formattedDate + formattedDayOfTheWeek + descriptiveDifference;
}
Line 413:
// Check if this is a text node.
if (node.nodeType === 3) {
// Don't continue if this text node's parent tag is one of these.
▲ if (['CODE', 'PRE'].includes(parentNodeName)) {
return;
}
Line 424 ⟶ 421:
const matches = value.match(search);
if (matches) {
// Only act on the first timestamp we found in this node. This is for
//
//
const [match] = matches;
const position = value.search(search);
const stringLength = match.toString().length;
const beforeMatch = value.slice(0, Math.max(0, position));▼
const afterMatch = value.slice(Math.max(0, position + stringLength));▼
const { returnDate, time } = this.adjustTime(▼
match.toString(),▼
search▼
▲ );
//
// which we'll then wrap in their own SPAN nodes.
// Create the code to display the new local comments content.
const $span
`<span class="localcomments" style="font-size: 95%;" title="${match}">${returnDate}</span>`
span.title = match;▼
parent = node.parentNode;▼
node.replaceWith(span);▼
// Replace the existing text node in the page with our new local
▲ $(node).replaceWith($span);
// Replace the text content that appears before the timestamp.
if (beforeMatch) {
`<span class="before-localcomments">${beforeMatch}</span>`
▲ }
// Replace the text content that appears after the timestamp.
`<span class="after-localcomments">${afterMatch}</span>`
);
}
}
} else {
Line 504 ⟶ 495:
this.replaceText(
document.querySelector('.mw-body-content .mw-parser-output'),
/(\d{1,2}):(\d{2}), (\d{1,2}) ([A-Z][a-z]+) (\d{4}) \(UTC\)/
);
|