User:Thparkth/CommentsInLocalTime.js: Difference between revisions

Content deleted Content added
debug
Tag: Reverted
put the regexp fix back in
 
(12 intermediate revisions by the same user not shown)
Line 151:
* 08:51, 23 November 2015 (UTC)
*/
parseRegExp: /\d\d:\d\d, (?:\ds[1-9]\d? s|\s0[1-9]\s|\s1[0-9]\s|\s2[0-9]\s|\s3[0-1]\s)(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\w* \d{4} \(UTC\)/,
/**
Line 179:
var iter = document.createNodeIterator(root, NodeFilter.SHOW_TEXT, {
acceptNode: function (node) {
console.log("acceptNode: " + node.wholeText);
// We can’t just check the node’s direct parent, because templates
// like [[Template:Talkback]] and [[Template:Resolved]] may place a
Line 195 ⟶ 194:
function wrapTimestamps() {
var prefixNode;
var loopEscapeCounter = 0; // we'll break out if the while loop runs more than 5,000 times to avoid a browser hang
while ((prefixNode = iter.nextNode())) {
if (loopEscapeCounter++ > 5000) { // escape infinite loop
console.log("iter.nextNode()");
console.log("ERROR: CommentsInLocalTime.js loop breakout in wrapTimestamps()");
break;
}
 
var result = LocalComments.parseRegExp.exec(prefixNode.data);
if (!result) continue;
console.log("iter.nextNode() CONTINUE");
// Split out the timestamp into a separate text node.
var dateNode = prefixNode.splitText(result.index);
Line 212 ⟶ 216:
}
if (!then.isValid()) continue;
console.log("iter.nextNode() CONTINUE 2");
then.utcOffset(-LocalComments.utcOffset);
Line 310 ⟶ 313:
mw.loader.using("moment", function () {
console.log("moment 1");
wrapTimestamps();
console.log("moment 2");
formatTimestamps();
console.log("moment 3");
});
});