Content deleted Content added
Try this fix for no leading zeros on the time |
Fixed so that it doesn't fail on unrecognized dates |
||
Line 5:
Link: [[User:Gary King/comments in local time.js]]
*/
$(commentsInLocalTime);▼
var language;
Line 130 ⟶ 122:
time.setUTCHours(oldHour);
time.setUTCMinutes(oldMinute);
// A string matching the date pattern was found, but it cannot be converted to a Date object. Return it with no changes made.
if (isNaN(time)) return [originalTimestamp, ''];
// determine the time offset
Line 275 ⟶ 270:
{
if (!node.length) return false;
// Check if this is a text node.
if (node[0].nodeType == 3)
{
var value = node[0].nodeValue;
var matches = value.match(search);
if (matches != null)
{
Line 292 ⟶ 289:
var timeArray = adjustTime(matches[match].toString(), search);
// Is the "timestamp" attribute used for microformats?
var span = $('<span class="localcomments" style="font-size: 95%; white-space: nowrap;" timestamp="' + (timeArray[1] ? timeArray[1].getTime() : '') + '" title="' + matches[match] + '">' + timeArray[0] + '</span>'); node.replaceWith(span);
Line 313 ⟶ 311:
}
for (var child = 0; child < children.length; child++) replaceText(children[child], search);
▲ {
}
}
▲$(commentsInLocalTime);
|