Content deleted Content added
Polygnotus (talk | contribs) No edit summary |
Polygnotus (talk | contribs) No edit summary |
||
Line 50:
aplimit: 50,
format: 'json'
}).
var exactMatches = data.query.allpages || [];
Line 61:
srlimit: 50,
format: 'json'
}).
var searchMatches = searchData.query.search || [];
Line 90:
displayAfDResults(allMatches, articleTitle);
}
}).
// If search fails, just show exact matches
displayAfDResults(exactMatches, articleTitle);
});
}).
$('#afd-search-btn').text('Search AfD').css('color', '#0645ad');
mw.notify('Error searching for AfD discussions', { type: 'error' });
Line 103:
var api = new mw.Api();
var pageTitles = pages.map(function(page) { return page.title; });
console.log('Fetching dates for:', pageTitles); // Debug log
// Get creation dates for all pages
Line 113 ⟶ 115:
rvprop: 'timestamp',
format: 'json'
}).
console.log('API response:', data); // Debug log
var pagesWithDates = [];
var mostRecentDate = null;
Line 119 ⟶ 123:
// Process each page and add creation date
var timestamp = pageData.revisions[0].timestamp;▼
var date = new Date(timestamp);▼
var timestampMs = date.getTime();▼
if (pageData && !pageData.missing
console.log('Page:', pageData.title, 'Date:', date.toDateString()); // Debug log
// Track most recent▼
date: date,
timestamp: timestampMs
});
▲ // Track most recent
if (timestampMs > mostRecentTimestamp) {
mostRecentTimestamp = timestampMs;
mostRecentDate = date;
}
} else {
console.log('No revisions found for:', pageData ? pageData.title : 'unknown page');
// Still add the page without date
pagesWithDates.push({
title: pageData ? pageData.title : 'Unknown page',
});
}
});
}
//
if (pagesWithDates.
pagesWithDates = pages;
}
// Sort by date (most recent first, pages without dates last)
pagesWithDates.sort(function(a, b) {
if (!a.timestamp && !b.timestamp) return 0;
if (!a.timestamp) return 1;
if (!b.timestamp) return -1;
});
// Check if most recent is within 3 months
Line 147 ⟶ 175:
threeMonthsAgo.setMonth(threeMonthsAgo.getMonth() - 3);
var isRecent = mostRecentDate && mostRecentDate > threeMonthsAgo;
console.log('Most recent date:', mostRecentDate ? mostRecentDate.toDateString() : 'none', 'Is recent:', isRecent); // Debug log
displayAfDResults(pagesWithDates, articleTitle, mostRecentDate, isRecent);
}).
console.log('API error:', error); // Debug log
// If date fetching fails, display without dates
displayAfDResults(pages, articleTitle);
|