Content deleted Content added
DreamRimmer (talk | contribs) Rfc (DR) |
DreamRimmer (talk | contribs) fixes |
||
Line 7:
*/
$(document).ready(function() {
var apiCache = {};
var CACHE_DURATION = 10 * 60 * 1000; // 10 minutes
Line 816 ⟶ 815:
return promise.then(results => {
return fetchPageBatch(batch).then(batchResults => {
if (index < batches.length - 1) {
return new Promise(resolve => {
Line 837 ⟶ 835:
function parseRfCs(wikitext, topicName) {
const rfcs = [];
const rfcEntryPattern = /'''\[\[([^\]|]+)(?:\|([^\]]+))?\]\]'''[\s\S]*?\{\{rfcquote\|text=([\s\S]*?)\}\}
const now = new Date();
const currentUtcYear = now.getUTCFullYear();
Line 851 ⟶ 850:
const link = match[1];
displayTitle = match[2] || link;
if (link.includes('#')) {
[pageName, anchor] = link.split('#');
Line 858:
}
const
let timestampStr = null;
let daysDiff = null;
const timestampMatch = rfcText.match(/(\d{2}:\d{2}, \d{1,2} \w+ \d{4} \(UTC\))\s*$/);
if (timestampMatch) {
timestampStr = timestampMatch[1];
const tsMatch = timestampStr.match(/(\d{2}):(\d{2}), (\d{1,2}) (\w+) (\d{4}) \(UTC\)/);
if (tsMatch) {
const [_, hour, minute, day, monthText, year] = tsMatch;
const months = [
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December" ];
const monthNum = months.indexOf(monthText);
if (monthNum !== -1) {
const tsDate = new Date(Date.UTC(
parseInt(year, 10),
monthNum,
parseInt(day, 10),
parseInt(hour, 10),
parseInt(minute, 10),
0, 0
));
const timeDiff = currentUtc.getTime() - tsDate.getTime();
daysDiff = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
if (daysDiff < 0) daysDiff = 0;
}
}
Line 891 ⟶ 902:
url: url,
daysOld: daysDiff,
timestamp: timestampStr || "unavailable"
});
}
return rfcs;
}
|