Content deleted Content added
lint |
bug fixes |
||
Line 10:
*/
$(() => {
const nowrapStyle = `style="white-space: nowrap;"`;
/**
* Given a number, add a leading zero if necessary, so that the final number
Line 136 ⟶ 138:
const utcOffset =
utcValue >= 0 ? `+${utcValue}` : `−${Math.abs(utcValue.toFixed(1))}`;
const timePart = `<span class="localcomments-time" ${nowrapStyle}>${finalTime}</span>`;
const datePart = `<span class="localcomments-date">${date}</span>`;
const utcPart = `<span class="localcomments-utc" ${nowrapStyle}>(UTC${utcOffset})</span>`;
const returnDate = this.LocalComments.timeFirst
? `${
: `${
return { returnDate, time };
Line 202 ⟶ 208:
}
return `<span ${nowrapStyle}>${formattedDate}</span><span
▲ formattedDayOfTheWeek = `, ${last}${dayOfTheWeek}`;
▲ }
▲ return formattedDate + formattedDayOfTheWeek + descriptiveDifference;
}
Line 413 ⟶ 417:
// 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 ⟶ 425:
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));▼
// Grab the text content before and after the matching timestamp,
const afterMatch = value.slice(Math.max(0, position + stringLength));▼
// which we'll then wrap in their own SPAN nodes.
const { returnDate, time } = this.adjustTime(
match.toString(),
Line 442 ⟶ 444:
// Is the "timestamp" attribute used for microformats?
const $span =
`<span class="localcomments" style="font-size: 95%;" timestamp="${timestamp}" title="${match}">${returnDate}</span>`
);
`<span class="before-localcomments">${beforeMatch}</span>`
);
const
`<span class="after-localcomments">${afterMatch}</span>`
$span.before($before);
}
} else {
Line 504 ⟶ 498:
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\)/
);
|