User:DreamRimmer/adminnewslettertools.js: Difference between revisions

Content deleted Content added
fixes
add convenient-discussions tag (DR)
 
(7 intermediate revisions by the same user not shown)
Line 614:
format: 'json'
}).then(revisions => {
const filtered = revisions.filter(rev => rev.tags && (rev.tags.includes('discussiontools-newtopic') || rev.tags.includes('convenient-discussions')));
return createEditTable('ArbCom topics', filtered, true);
});
Line 835:
function parseRfCs(wikitext, topicName) {
const rfcs = [];
const rfcEntryPattern = /'''\[\[([^\]|]+)(?:\|([^\]]+))?\]\]'''[\s\S]*?\{\{rfcquote\|text=((?:[^{}]|\s{[^{]|\S}[^}]*|\{\{(?:[^{}]|\{[^{]|\}[^}])*\}\})*)\}\}/gi;
const now = new Date();
Line 849:
let pageName, anchor, displayTitle;
const link = match[1];
displayTitle = match[2] || (anchor ? `${link}#${anchor}` : link);
if (link.includes('#')) {
[pageName, anchor] = link.split('#');
Line 862 ⟶ 861:
let daysDiff = null;
const timestampMatch = rfcText.match(/(\d{2}):(\d{2}), (\d{1,2}) (\w+) (\d{4}) \(UTC\))\s*$/);
if (timestampMatch) {
timestampStrconst [fullMatch, hour, minute, day, monthText, year] = timestampMatch[1];
timestampStr = ))fullMatch;
const tsMatchmonths = timestampStr.match(/(\d{2}):(\d{2}), (\d{1,2}) (\w+) (\d{4}) \(UTC\)/);[
if (tsMatch) { "January", "February", "March", "April", "May", "June",
const [_"July", hour"August", minute"September", day"October", monthText"November", year] = tsMatch;"December"
const months = [];
const monthNum = "January", "February", "March", "April", "May", "June",months.indexOf(monthText);
"July", "August", "September", "October", "November", "December"
if (monthNum !== -1) ];{
const monthNumtsDate = monthsnew Date(Date.indexOfUTC(monthText);
parseInt(dayyear, 10),
monthNum,
parseInt(hourday, 10),
parseInt(minutehour, 10),
parseInt(minute, 010), 0
0, 0
}));
ifconst (monthNumtimeDiff !== -1currentUtc.getTime() {- tsDate.getTime();
daysDiff = Math.floor(timeDiff / const(1000 tsDate* =60 new* Date(Date.UTC(60 * 24));
parseInt(year, 10),
if (daysDiff < 0) daysDiff = monthNum,0;
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 918 ⟶ 914:
const ageOptions = [3, 7, 10, 15, 20, 25, 30];
const topicNamesrfcMap = [new Map();
'Biographies', 'Economy, trade, and companies', 'History and geography',
rfcs.forEach(rfc => {
'Language and linguistics', 'Maths, science, and technology',
const uniqueKey = `${rfc.url}|${rfc.title}`;
'Art, architecture, literature, and media', 'Politics, government, and law',
if (rfcMap.has(uniqueKey)) {
'Religion and philosophy', 'Society, sports, and culture',
'Wikipedia style and naming', 'Wikipediaconst policiesexisting and= guidelines',rfcMap.get(uniqueKey);
if (!existing.topics.includes(rfc.topic)) {
'WikiProjects and collaborations', 'Wikipedia technical issues and templates',
'Wikipedia proposals', 'Unsorted', 'User names' existing.topics.push(rfc.topic);
]; }
} else {
 
rfcMap.set(uniqueKey, {
...rfc,
topics: [rfc.topic]
});
}
});
const deduplicatedRfcs = Array.from(rfcMap.values());
let html = `<p><small>Current date: ${currentDate}</small></p>`;
html += `<p>Age filter: <select id="rfc-age-filter">`;
Line 939 ⟶ 944:
if (filteredRfcs.length > 0) {
let table = '<h4>Current RfCs</h4><table class="wikitable sortable"><thead><tr><th>Topic</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) => {
let topicDisplay;
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>`;
if (rfc.topics.length === 1) {
topicDisplay = rfc.topics[0];
} else {
const timeDiffmainTopic = currentUtcrfc.getTime() - tsDate.getTime()topics[0];
const additionalCount = rfc.topics.length - 1;
const additionalTopics = rfc.topics.slice(1).join(', ');
topicDisplay = `
<span class="main-topic">${mainTopic}</span>
<span class="additional-topics" style="color: #0645ad; cursor: pointer; text-decoration: underline;"
onclick="toggleTopics('topics-${index}')"
title="${additionalTopics}">
(+${additionalCount} more)
if (daysDiff < 0) daysDiff = 0;</span>
<div id="topics-${index}" style="display: none; margin-top: 5px; font-size: 0.9em; color: #666;">
${rfc.topics.slice(1).map(topic => `<div>• ${topic}</div>`).join('')}
</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 952 ⟶ 978:
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(elementId) {
var element = document.getElementById(elementId);
if (element.style.display === 'none') {
element.style.display = 'block';
} else {
element.style.display = 'none';
}
}
function updateRfCTable() {
var rfcs = window._rfcs;
Line 962 ⟶ 998:
document.getElementById('rfc-list-table').innerHTML = (${renderRfCTable.toString()})(filteredRfcs);
}
document.getElementById('rfc-age-filter').addEventListener('change', updateRfCTable);
updateRfCTable();
</script>`;
 
return html;
}