MediaWiki:Common.js: Difference between revisions
Content deleted Content added
No edit summary |
No edit summary |
||
Line 441:
/* ── Datacheck confirm/correct gadget ───────────────────────────────────────
On a Datacheck: page (namespace 3006),
action cells — .rt-confirm
(Confirm toggle · Reject · Correct→enter a number), and mirror the verdict in the
== records[] order (one per record); the exact Data title comes from the hidden
$(function () {
if (!(window.mw && mw.config) || mw.config.get('wgNamespaceNumber') !== 3006) { return; }
var
var rejectCells = document.querySelectorAll('.rt-reject');
if (!spans.length) { return; }▼
var overrideCells = document.querySelectorAll('.rt-override');
var statusCells = document.querySelectorAll('.rt-status');
if (!mw.config.get('wgUserName')) { mw.log('Datacheck: log in to enable confirm controls.'); return; }
Line 530 ⟶ 534:
save('Datacheck: override saved (' + num + ').');
}
// One <button> per action cell (styled as .rt-btn in Common.css); the active verdict's button is filled.
function btn(glyph, title, active, variant, handler) {
b.type = 'button'; b.textContent = glyph; b.title = title;
b.className = 'rt-btn rt-btn--' + variant + (active ? ' is-active' : '');
return b;
}
function fill(cell, node) { cell.innerHTML = ''; cell.appendChild(node); }
function render() {
if (!data || !data.records) { return; }
if (confirmCells.length !== n || rejectCells.length !== n ||
overrideCells.length !== n || statusCells.length !== n) {
notify('Datacheck: table out of sync with the data page — reload the page.'); return;
}
Array.prototype.forEach.call(
var rec = data.records[i], status = rec.human_status || 'unreviewed';
fill(cCell, btn('✓', status === 'confirmed' ? 'Confirmed — click to un-confirm' : 'Confirm',
status === 'confirmed', 'confirm', function () { toggleConfirm(rec); }));
▲ var ok = document.createElement('a');
fill(rejectCells[i], btn('✗',
s.className = 'rt-status rt-status-' + status;
: 'unreviewed';
▲ no.onclick = function (e) { e.preventDefault(); toggleReject(rec); };
▲ fix.href = '#'; fix.textContent = (status === 'overridden') ? ('✎ ' + rec.value) : '✎';
▲ fix.title = 'Reject + enter the correct number (override)';
▲ fix.onclick = function (e) { e.preventDefault(); correctRow(rec); };
});
}
| |||