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), turnfill each Module:ReportedTable row's
action cells — .rt-confirm control/ into.rt-reject Confirm/ (toggle).rt-override + Reject/Correctwith (enterone abutton number),each
(Confirm toggle · Reject · Correct→enter a number), and mirror the verdict in the
writing.rt-status badge. Writes the verdict straight into the underlying Data:<...>.json page under the
REVIEWER'S OWN session (no bot creds). DOM order of .rt-confirm == records[]
orderpage under (the moduleREVIEWER'S emitsOWN exactlysession one(no perbot recordcreds);. theDOM exactorder Datawithin titleeach comesclass
== records[] order (one per record); the exact Data title comes from the hidden
from the hidden .rt-data-title marker. Verdicts survive a re-publish via wiki_extract.merge_verdicts
wiki_extract.merge_verdicts (value-gated). Anonymous users see read-the Status badge only marks(no buttons). */
$(function () {
if (!(window.mw && mw.config) || mw.config.get('wgNamespaceNumber') !== 3006) { return; }
var spansconfirmCells = document.querySelectorAll('.rt-confirm');
var rejectCells = document.querySelectorAll('.rt-reject');
if (!spans.length) { return; }
var overrideCells = document.querySelectorAll('.rt-override');
var statusCells = document.querySelectorAll('.rt-status');
if (!spansconfirmCells.length) { return; }
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) {
var okb = document.createElement('abutton');
b.type = 'button'; b.textContent = glyph; b.title = title;
b.className = 'rt-btn rt-btn--' + variant + (active ? ' is-active' : '');
fixb.onclick = function (e) { e.preventDefault(); correctRowhandler(rec); };
return b;
}
function fill(cell, node) { cell.innerHTML = ''; cell.appendChild(node); }
 
function render() {
if (!data || !data.records) { return; }
ifvar (spans.lengthn !== data.records.length) {;
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(spansconfirmCells, function (spancCell, i) {
var rec = data.records[i], status = rec.human_status || 'unreviewed';
fill(cCell, btn('✓', status === 'confirmed' ? 'Confirmed — click to un-confirm' : 'Confirm',
span.innerHTML = '';
status === 'confirmed', 'confirm', function () { toggleConfirm(rec); }));
var ok = document.createElement('a');
fill(rejectCells[i], btn('✗',
ok.href = '#'; ok.textContent = (status === 'confirmed') ? '✓' : '○';
ok.title = (status === 'confirmedrejected') ? 'ConfirmedRejected — click to un-confirmclear' : 'ClickReject to(wrong, confirmno value yet)';,
no.onclick status === 'rejected', 'reject', function (e) { e.preventDefault(); toggleReject(rec); }));
ok.style.cssText = 'text-decoration:none;font-weight:bold;margin-right:6px;color:' +
fix.titlefill(overrideCells[i], =btn('✎', 'RejectCorrect + enter the correctright number (override)';,
(status === 'confirmed' ? '#137333' : '#999');
ok.onclick status === 'overridden', 'override', function (e) { e.preventDefault(); toggleConfirmcorrectRow(rec); }));
span.appendChild(ok)var s = statusCells[i];
s.className = 'rt-status rt-status-' + status;
var no = document.createElement('a');
nos.hreftextContent = (status === '#confirmed';) no.textContent =? '✓ confirmed';
no.title = : (status === 'rejected') ? 'Rejected — click to clear' : 'Reject (wrong, no value yet)rejected';
fix.href = '#'; fix.textContent =: (status === 'overridden') ? ('✎ overridden → ' + rec.value) : '✎';
no.style.cssText = 'text-decoration:none;font-weight:bold;margin-right:6px;color:' +
: 'unreviewed';
(status === 'rejected' ? '#b00020' : '#999');
no.onclick = function (e) { e.preventDefault(); toggleReject(rec); };
span.appendChild(no);
var fix = document.createElement('a');
fix.href = '#'; fix.textContent = (status === 'overridden') ? ('✎ ' + rec.value) : '✎';
fix.title = 'Reject + enter the correct number (override)';
fix.style.cssText = 'text-decoration:none;color:' + (status === 'overridden' ? '#b06000' : '#999');
fix.onclick = function (e) { e.preventDefault(); correctRow(rec); };
span.appendChild(fix);
});
}