| @@ -16,8 +16,9 @@ | ||
| 16 | 16 | var L = window.mxchatKbReimport; |
| 17 | 17 | var find = function (selector) { return card.querySelector(selector); }; |
| 18 | 18 | |
| 19 | 19 | var before = find('#mxchat-kb-reimport-before'); |
| 20 | + var edited = find('#mxchat-kb-reimport-edited'); | |
| 20 | 21 | var checkBtn = find('#mxchat-kb-reimport-check'); |
| 21 | 22 | var applyBtn = find('#mxchat-kb-reimport-apply'); |
| 22 | 23 | var clearBtn = find('#mxchat-kb-reimport-clear'); |
| 23 | 24 | var progress = find('.mxch-kb-reimport-progress'); |
| @@ -107,8 +108,11 @@ | ||
| 107 | 108 | checkBtn.disabled = state; |
| 108 | 109 | applyBtn.disabled = state; |
| 109 | 110 | clearBtn.disabled = state; |
| 110 | 111 | before.disabled = state; |
| 112 | + if (edited) { | |
| 113 | + edited.disabled = state; | |
| 114 | + } | |
| 111 | 115 | } |
| 112 | 116 | |
| 113 | 117 | function render(state) { |
| 114 | 118 | var phase = state.phase || 'idle'; |
| @@ -124,8 +128,11 @@ | ||
| 124 | 128 | } |
| 125 | 129 | if (state.before && !busy) { |
| 126 | 130 | before.value = state.before; |
| 127 | 131 | } |
| 132 | + if (edited && !busy && typeof state.with_edited !== 'undefined') { | |
| 133 | + edited.checked = !!state.with_edited; | |
| 134 | + } | |
| 128 | 135 | |
| 129 | 136 | // Progress: a check has no total to measure against, a rewrite has. |
| 130 | 137 | if (phase === 'scan') { |
| 131 | 138 | progress.hidden = false; |
| @@ -159,8 +166,11 @@ | ||
| 159 | 166 | counts.appendChild(badge(fmt(L.countCorrect, state.unchanged), phase === 'done' ? '' : 'success')); |
| 160 | 167 | if (state.changed > 0) { |
| 161 | 168 | counts.appendChild(badge(fmt(L.countChanged, state.changed))); |
| 162 | 169 | } |
| 170 | + if (state.edited > 0) { | |
| 171 | + counts.appendChild(badge(fmt(L.countEdited, state.edited), 'warning')); | |
| 172 | + } | |
| 163 | 173 | if (state.skipped > 0) { |
| 164 | 174 | counts.appendChild(badge(fmt(L.countSkipped, state.skipped))); |
| 165 | 175 | } |
| 166 | 176 | |
| @@ -184,12 +194,13 @@ | ||
| 184 | 194 | more.textContent = extra > 0 ? fmt(L.andMore, extra) : ''; |
| 185 | 195 | |
| 186 | 196 | othersList.textContent = ''; |
| 187 | 197 | (state.notes || []).forEach(function (note) { |
| 188 | - othersList.appendChild(row(note.label, note.note, [badge(note.kind === 'changed' ? L.leftAlone : L.skipped)])); | |
| 198 | + var kind = note.kind === 'changed' ? L.leftAlone : (note.kind === 'edited' ? L.editedNotRewritten : L.skipped); | |
| 199 | + othersList.appendChild(row(note.label, note.note, [badge(kind, note.kind === 'edited' ? 'warning' : '')])); | |
| 189 | 200 | }); |
| 190 | 201 | others.hidden = !(state.notes && state.notes.length); |
| 191 | - othersText.textContent = fmt(L.othersTitle, state.changed + state.skipped); | |
| 202 | + othersText.textContent = fmt(L.othersTitle, state.changed + state.skipped + (state.edited || 0)); | |
| 192 | 203 | |
| 193 | 204 | if (state.error) { |
| 194 | 205 | showError(fmt(L.scanStopped, state.error)); |
| 195 | 206 | } |
| @@ -241,9 +252,9 @@ | ||
| 241 | 252 | doneBox.hidden = true; |
| 242 | 253 | progress.hidden = false; |
| 243 | 254 | bar.hidden = true; |
| 244 | 255 | label.textContent = fmt(L.checking, 0); |
| 245 | - run({ op: 'scan', restart: '1', before: before.value }, 'scan'); | |
| 256 | + run({ op: 'scan', restart: '1', before: before.value, edited: (edited && edited.checked) ? '1' : '0' }, 'scan'); | |
| 246 | 257 | }); |
| 247 | 258 | |
| 248 | 259 | applyBtn.addEventListener('click', function () { |
| 249 | 260 | if (last && last.to_repair) { |