-
Notifications
You must be signed in to change notification settings - Fork 0
Add page number input to chat log pagination #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
66abc4a
9f8f7db
5ee3861
35c7282
b0bff7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -169,10 +169,89 @@ | |||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| function addPageJump() { | ||||||||||||
| try { | ||||||||||||
| const paginateDiv = document.querySelector('#dataTable_paginate'); | ||||||||||||
| if (!paginateDiv) { | ||||||||||||
| console.warn('[ChatLog] addPageJump: paginate div not found'); | ||||||||||||
| return; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Don't add if already exists | ||||||||||||
| if (document.getElementById('pageJumpContainer')) { | ||||||||||||
| return; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| const pageInfo = table.page.info(); | ||||||||||||
| const totalPages = pageInfo.pages; | ||||||||||||
|
|
||||||||||||
| // Create the page jump container | ||||||||||||
| const jumpContainer = document.createElement('div'); | ||||||||||||
| jumpContainer.id = 'pageJumpContainer'; | ||||||||||||
| jumpContainer.className = 'datatable-page-jump'; | ||||||||||||
| jumpContainer.innerHTML = ` | ||||||||||||
| <span class="page-jump-label">Go to page:</span> | ||||||||||||
| <input type="number" id="pageJumpInput" class="page-jump-input" min="1" max="${totalPages}" value="${pageInfo.page + 1}" /> | ||||||||||||
| <span class="page-jump-total">of ${totalPages}</span> | ||||||||||||
| `; | ||||||||||||
|
Comment on lines
+192
to
+196
Check warningCode scanning / ESLint Assignments to [innerHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML)/[outerHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/outerHTML) properties or calls to [insertAdjacentHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML) method manipulate DOM directly without any sanitization and should be avoided. Use document.createElement() or similar methods instead. Warning
Do not write to DOM directly using innerHTML/outerHTML property
|
||||||||||||
|
|
||||||||||||
| // Insert before the pagination controls | ||||||||||||
| paginateDiv.parentNode.insertBefore(jumpContainer, paginateDiv); | ||||||||||||
|
|
||||||||||||
| // Helper function for page navigation | ||||||||||||
| function navigateToPage(inputElement) { | ||||||||||||
| const pageInfo = table.page.info(); | ||||||||||||
| const pageNum = parseInt(inputElement.value, 10); | ||||||||||||
|
|
||||||||||||
| // Check for valid number and range | ||||||||||||
| if (!isNaN(pageNum) && pageNum >= 1 && pageNum <= pageInfo.pages) { | ||||||||||||
| table.page(pageNum - 1).draw(false); | ||||||||||||
| } else { | ||||||||||||
| // Reset to current page if invalid or out of range | ||||||||||||
| inputElement.value = pageInfo.page + 1; | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Add event handler for the input | ||||||||||||
| const pageInput = document.getElementById('pageJumpInput'); | ||||||||||||
| if (pageInput) { | ||||||||||||
| pageInput.addEventListener('keypress', function(e) { | ||||||||||||
| if (e.key === 'Enter') { | ||||||||||||
|
Comment on lines
+218
to
+219
|
||||||||||||
| pageInput.addEventListener('keypress', function(e) { | |
| if (e.key === 'Enter') { | |
| pageInput.addEventListener('keydown', function(e) { | |
| if (e.key === 'Enter') { | |
| e.preventDefault(); |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the draw.dt handler, document.querySelector('.page-jump-total') searches the whole document. It would be more robust to scope this lookup to the page-jump container (or otherwise keep a reference) to avoid accidentally updating the wrong element if another .page-jump-total exists on the page.
| const totalSpan = document.querySelector('.page-jump-total'); | |
| const totalSpan = jumpContainer.querySelector('.page-jump-total'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The page-jump input doesn’t have an associated label (a isn’t announced as a label by many screen readers). Consider using a … or adding an aria-label/aria-labelledby/aria-describedby so the control is accessible.