Update F95_BRATR_Management_Ratings_Helper.js

This commit is contained in:
Ryahn 2025-09-22 01:48:03 +00:00
parent 8821dad70d
commit bc4e35e28e

View File

@ -393,6 +393,8 @@
<label><input type="checkbox" class="bh-cliche-only"> Only reviews matching selected cliché</label> <label><input type="checkbox" class="bh-cliche-only"> Only reviews matching selected cliché</label>
<button class="bh-copy">Copy CSV</button> <button class="bh-copy">Copy CSV</button>
<button class="bh-reset">Reset</button> <button class="bh-reset">Reset</button>
<button class="bh-prev-page"> Prev</button>
<button class="bh-next-page">Next </button>
</div> </div>
<div class="bh-table"></div> <div class="bh-table"></div>
</div> </div>
@ -412,7 +414,9 @@
#bratr-helper .bh-controls{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:8px} #bratr-helper .bh-controls{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:8px}
#bratr-helper .bh-controls label{display:flex;gap:6px;align-items:center;background:#161616;border:1px solid #2a2a2a;border-radius:8px;padding:4px 8px} #bratr-helper .bh-controls label{display:flex;gap:6px;align-items:center;background:#161616;border:1px solid #2a2a2a;border-radius:8px;padding:4px 8px}
#bratr-helper input, #bratr-helper select{background:#0f0f0f;border:1px solid #333;color:#ddd;border-radius:6px;padding:3px 6px} #bratr-helper input, #bratr-helper select{background:#0f0f0f;border:1px solid #333;color:#ddd;border-radius:6px;padding:3px 6px}
#bratr-helper button.bh-copy,#bratr-helper button.bh-reset{background:#1e1e1e;border:1px solid #444;color:#ddd;border-radius:8px;padding:4px 10px;cursor:pointer} #bratr-helper button.bh-copy,#bratr-helper button.bh-reset,#bratr-helper button.bh-prev-page,#bratr-helper button.bh-next-page{background:#1e1e1e;border:1px solid #444;color:#ddd;border-radius:8px;padding:4px 10px;cursor:pointer}
#bratr-helper button.bh-prev-page,#bratr-helper button.bh-next-page{background:#2a4a2a;border-color:#4a6a4a;font-size:11px;padding:3px 8px}
#bratr-helper button.bh-prev-page:hover,#bratr-helper button.bh-next-page:hover{background:#3a5a3a}
#bratr-helper .bh-table{overflow:auto;max-height:48vh;border:1px solid #2a2a2a;border-radius:8px} #bratr-helper .bh-table{overflow:auto;max-height:48vh;border:1px solid #2a2a2a;border-radius:8px}
#bratr-helper table{width:100%;border-collapse:collapse} #bratr-helper table{width:100%;border-collapse:collapse}
#bratr-helper th,#bratr-helper td{padding:6px 8px;border-bottom:1px solid #232323;vertical-align:top} #bratr-helper th,#bratr-helper td{padding:6px 8px;border-bottom:1px solid #232323;vertical-align:top}
@ -494,6 +498,75 @@
} }
}); });
// Navigation helper function
function navigateToPage(pageNumber) {
try {
const currentUrl = window.location.href;
const urlMatch = currentUrl.match(/\/bratr-ratings\/(?:page-(\d+)\/)?management/);
if (urlMatch) {
let targetUrl;
if (pageNumber === 1) {
// For page 1, remove the page number from URL
targetUrl = currentUrl.replace(
/\/bratr-ratings\/page-\d+\/management/,
'/bratr-ratings/management'
);
} else {
// For other pages, add or update the page number
targetUrl = currentUrl.replace(
/\/bratr-ratings\/(?:page-\d+\/)?management/,
`/bratr-ratings/page-${pageNumber}/management`
);
}
console.log(`Navigating to page ${pageNumber}: ${targetUrl}`);
window.location.href = targetUrl;
} else {
console.warn('Could not determine current page number from URL:', currentUrl);
}
} catch (error) {
console.error('Error navigating to page:', error);
}
}
// Previous page handler
panel.querySelector('.bh-prev-page').addEventListener('click', () => {
try {
const currentUrl = window.location.href;
const urlMatch = currentUrl.match(/\/bratr-ratings\/(?:page-(\d+)\/)?management/);
if (urlMatch) {
const currentPage = urlMatch[1] ? parseInt(urlMatch[1], 10) : 1;
const prevPage = currentPage - 1;
if (prevPage >= 1) {
navigateToPage(prevPage);
} else {
console.log('Already on first page');
}
}
} catch (error) {
console.error('Error navigating to previous page:', error);
}
});
// Next page handler
panel.querySelector('.bh-next-page').addEventListener('click', () => {
try {
const currentUrl = window.location.href;
const urlMatch = currentUrl.match(/\/bratr-ratings\/(?:page-(\d+)\/)?management/);
if (urlMatch) {
const currentPage = urlMatch[1] ? parseInt(urlMatch[1], 10) : 1;
const nextPage = currentPage + 1;
navigateToPage(nextPage);
}
} catch (error) {
console.error('Error navigating to next page:', error);
}
});
// Optimized event delegation // Optimized event delegation
const controlElements = [ui.min, ui.maxlen, ui.user, ui.lowonly, ui.from, ui.to, ui.clicheSel, ui.clicheOnly]; const controlElements = [ui.min, ui.maxlen, ui.user, ui.lowonly, ui.from, ui.to, ui.clicheSel, ui.clicheOnly];
['input', 'change'].forEach(eventType => { ['input', 'change'].forEach(eventType => {