User:Thparkth/CommentsInLocalTime.js: Difference between revisions

Content deleted Content added
debug
Tag: Reverted
Restored revision 1122653465 by Thparkth (talk): Reset debugging
Line 151:
* 08:51, 23 November 2015 (UTC)
*/
parseRegExp: /\d\d:\d\d,(?: \s[1-9]d\s|\s0[1-9]\s|\s1[0-9]\s|\s2[0-9]\s|\s3[0-1]\s)d? (?: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 185 ⟶ 184:
var isInProse = proseTags.indexOf(node.parentElement.nodeName) !== -1
|| !$(node).parents(codeTags).length;
console.log("isInProse? " + isInProse);
var isDateNode = isInProse && LocalComments.parseRegExp.test(node.data);
console.log("isDateNode? " + isDateNode);
return isDateNode ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
},
Line 197 ⟶ 194:
function wrapTimestamps() {
var prefixNode;
var sanityEscapeCounter = 0;
while ((prefixNode = iter.nextNode())) {
console.log("iter.nextNode()");
if (sanityEscapeCounter++ > 1000) break;
var result = LocalComments.parseRegExp.exec(prefixNode.data);
if (!result) continue;
console.log("iter.nextNode() CONTINUE " + result[0]);
// Split out the timestamp into a separate text node.
var dateNode = prefixNode.splitText(result.index);
Line 216 ⟶ 210:
}
if (!then.isValid()) continue;
console.log("iter.nextNode() CONTINUE 2");
then.utcOffset(-LocalComments.utcOffset);
Line 314 ⟶ 307:
mw.loader.using("moment", function () {
console.log("moment 1");
wrapTimestamps();
console.log("moment 2");
formatTimestamps();
console.log("moment 3");
});
});