Frontend created and rewritten a few times, with some backend fixes #1
| @@ -205,23 +205,21 @@ defineExpose({ | ||||
|       cursor.value = null | ||||
|       return | ||||
|     } | ||||
|     const N = documents.length | ||||
|     const mod = (a: number, b: number) => ((a % b) + b) % b | ||||
|     const index = cursor.value !== null ? documents.indexOf(cursor.value) : -1 | ||||
|     const moveto = mod(index + d, documents.length + 1) | ||||
|     const increment = (i: number, d: number) => mod(i + d, N + 1) | ||||
|     const index = cursor.value !== null ? documents.indexOf(cursor.value) : documents.length | ||||
|     const moveto = increment(index, d) | ||||
|     cursor.value = documents[moveto] ?? null | ||||
|     const tr = document.getElementById( | ||||
|       `file-${cursor.value.key}` | ||||
|     ) as HTMLTableRowElement | null | ||||
|     const tr = cursor.value ? document.getElementById(`file-${cursor.value.key}`) : null | ||||
|     if (select) { | ||||
|       // Go forwards, possibly wrapping over the end; the last entry is not toggled | ||||
|       let [begin, end] = d > 0 ? [index, moveto] : [moveto, index] | ||||
|       for (let p = begin; p !== end; p = mod(p + 1, documents.length)) { | ||||
|         const doc = documents[p] | ||||
|         if (documentStore.selected.has(doc.key)) { | ||||
|           documentStore.selected.delete(doc.key) | ||||
|         } else { | ||||
|           documentStore.selected.add(doc.key) | ||||
|         } | ||||
|       for (let p = begin; p !== end; p = increment(p, 1)) { | ||||
|         if (p === N) continue | ||||
|         const key = documents[p].key | ||||
|         if (documentStore.selected.has(key)) documentStore.selected.delete(key) | ||||
|         else documentStore.selected.add(key) | ||||
|       } | ||||
|     } | ||||
|     // @ts-ignore | ||||
|   | ||||
		Reference in New Issue
	
	Block a user