User:DreamRimmer/adminnewslettertools.js: Difference between revisions

Content deleted Content added
-
add convenient-discussions tag (DR)
 
(3 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 849:
let pageName, anchor, displayTitle;
const link = match[1];
displayTitle = match[2] || pageName(anchor ? `${link}#${anchor}` : link);
if (link.includes('#')) {
[pageName, anchor] = link.split('#');
Line 915 ⟶ 914:
const ageOptions = [3, 7, 10, 15, 20, 25, 30];
const rfcsGroupedrfcMap = {}new Map();
const rfcsGrouped = {};
rfcs.forEach(rfc => {
const keyuniqueKey = `${rfc.titleurl}|${rfc.urltitle}`;
if (!rfcsGrouped[key]rfcMap.has(uniqueKey)) {
rfcsGrouped[key]const existing = {rfcMap.get(uniqueKey);
if title: (!existing.topics.includes(rfc.title,topic)) {
url: existing.topics.push(rfc.url,topic);
daysOld: rfc.daysOld,}
} else timestamp: rfc.timestamp,{
rfcMap.set(uniqueKey, topics: []{
}; ...rfc,
rfcsGrouped topics: [key].topics.push(rfc.topic);]
});
}
rfcsGrouped[key].topics.push(rfc.topic);
});
const deduplicatedRfcs = ObjectArray.from(rfcMap.values(rfcsGrouped));
let html = `<p><small>Current date: ${currentDate}</small></p>`;
Line 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) => {
constlet topicDisplay;
= if (rfc.topics.length === 1) {
?topicDisplay = rfc.topics[0];
} else {
: `${rfc.topics} <span class="topic-toggle" onclick="toggleTopics(${index})" style="cursor:pointer;color:#0645ad;text-decoration:underline;font-size:0.9em;">(+${rfc.topics.length - 1} 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>`;
topicsDiv.style.display const mainTopic = 'block'rfc.topics[0];
toggleSpan.innerHTML = '(+' + (const additionalCount = rfc.topics.length - 1) + ' more)';
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)
toggleSpan.innerHTML = '(see less)'; </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>${topicDisplay}</td><td><a href="${rfc.url}" target="_blank">${rfc.title}</a></td><td>${rfc.daysOld}</td><td>${rfc.timestamp}</td></tr>`;
Line 964 ⟶ 981:
window._ageOptions = ${JSON.stringify(ageOptions)};
function toggleTopics(indexelementId) {
var topicsDivelement = document.getElementById('topics-' + indexelementId);
varif toggleSpan(element.style.display === topicsDiv.previousElementSibling;'none') {
if (topicsDiv element.style.display === 'noneblock') {;
topicsDiv.style.display = 'block';
toggleSpan.innerHTML = '(see less)';
} else {
topicsDivelement.style.display = 'none';
var rfc = window._rfcs.filter(function(r) { return !isNaN(r.daysOld) && r.daysOld <= parseInt(document.getElementById('rfc-age-filter').value, 10); }).sort(function(a, b) { return a.daysOld - b.daysOld; })[index];
toggleSpan.innerHTML = '(+' + (rfc.topics.length - 1) + ' more)';
}
}
Line 985 ⟶ 998:
document.getElementById('rfc-list-table').innerHTML = (${renderRfCTable.toString()})(filteredRfcs);
}
document.getElementById('rfc-age-filter').addEventListener('change', updateRfCTable);
updateRfCTable();
</script>`;
 
return html;
}