User:DreamRimmer/adminnewslettertools.js: Difference between revisions

Content deleted Content added
m fix (DR)
return deduplicated data
Line 849:
let pageName, anchor, displayTitle;
const link = match[1];
displayTitle = match[21] || link;
if (link.includes('#')) {
Line 915:
const ageOptions = [3, 7, 10, 15, 20, 25, 30];
const topicNames = [
const rfcsGrouped = {};
'Biographies', 'Economy, trade, and companies', 'History and geography',
rfcs.forEach(rfc => {
'Language and linguistics', 'Maths, science, and technology',
'Art,const architecture,key literature,= and media', 'Politics, government, and law',`${rfc.title}|${rfc.url}`;
if (!rfcsGrouped[key]) {
'Religion and philosophy', 'Society, sports, and culture',
'Wikipedia style and naming', 'WikipediarfcsGrouped[key] policies= and guidelines',{
'WikiProjects and collaborations', 'Wikipedia technical issues and templates' title: rfc.title,
'Wikipedia proposals', 'Unsorted', 'User names' url: rfc.url,
]; daysOld: rfc.daysOld,
timestamp: rfc.timestamp,
 
topics: []
};
}
rfcsGrouped[key].topics.push(rfc.topic);
});
const deduplicatedRfcs = Object.values(rfcsGrouped);
let html = `<p><small>Current date: ${currentDate}</small></p>`;
html += `<p>Age filter: <select id="rfc-age-filter">`;
Line 935 ⟶ 943:
function renderRfCTable(filteredRfcs) {
if (filteredRfcs.length > 0) {
let table = '<h4>Current RfCs</h4><table class="wikitable sortable"><thead><tr><th>Topic(s)</th><th>RfC</th><th>Days Old</th><th>Started</th></tr></thead><tbody>';
filteredRfcs.sort((a, b) => a.daysOld - b.daysOld).forEach((rfc, index) => {
const topicDisplay = rfc.topics.length === 1
table += `<tr><td>${rfc.topic}</td><td><a href="${rfc.url}" target="_blank">${rfc.title}</a></td><td>${rfc.daysOld}</td><td>${rfc.timestamp}</td></tr>`;
? rfc.topics[0]
: `${rfc.topics} <span class="topic-toggle" onclick="toggleTopics(${index})" style="cursor:pointer;color:#0645ad;text-decoration:underline;font-size:0.9em;">(see more)</span><div id="topics-${index}" style="display:none;margin-top:5px;font-size:0.9em;line-height:1.3;">${rfc.topics.slice(1).map(t => `• ${t}`).join('<br>')}</div>`;
table += `<tr><td>${rfc.topictopicDisplay}</td><td><a href="${rfc.url}" target="_blank">${rfc.title}</a></td><td>${rfc.daysOld}</td><td>${rfc.timestamp}</td></tr>`;
});
table += '</tbody></table>';
Line 949 ⟶ 961:
html += '<p><a href="https://en.wikipedia.org/wiki/Wikipedia:Requests_for_comment/All" target="_blank">All open RfCs</a></p>';
html += `<script>
window._rfcs = ${JSON.stringify(rfcsdeduplicatedRfcs)};
window._ageOptions = ${JSON.stringify(ageOptions)};
function toggleTopics(index) {
var topicsDiv = document.getElementById('topics-' + index);
var toggleSpan = topicsDiv.previousElementSibling;
if (topicsDiv.style.display === 'none') {
topicsDiv.style.display = 'block';
toggleSpan.textContent = '(see less)';
} else {
topicsDiv.style.display = 'none';
toggleSpan.textContent = '(see more)';
}
}
function updateRfCTable() {
var rfcs = window._rfcs;