text-generation-webui/js/switch_tabs.js

39 lines
907 B
JavaScript
Raw Normal View History

2023-08-13 18:48:15 -07:00
function scrollToTop() {
2025-06-18 10:22:36 -07:00
window.scrollTo({ top: 0 });
2023-08-13 18:48:15 -07:00
}
2023-08-29 13:22:15 -07:00
function findButtonsByText(buttonText) {
2023-10-07 19:07:57 -07:00
const buttons = document.getElementsByTagName("button");
2023-08-29 13:22:15 -07:00
const matchingButtons = [];
for (let i = 0; i < buttons.length; i++) {
2025-06-18 10:22:36 -07:00
if (buttons[i].textContent.trim() === buttonText) {
matchingButtons.push(buttons[i]);
2023-08-29 13:22:15 -07:00
}
}
return matchingButtons;
}
function switch_to_chat() {
2025-06-18 10:22:36 -07:00
document.getElementById("chat-tab-button").click();
2023-10-07 19:07:57 -07:00
scrollToTop();
}
function switch_to_notebook() {
2025-06-18 10:22:36 -07:00
document.getElementById("notebook-parent-tab-button").click();
2023-10-07 19:07:57 -07:00
findButtonsByText("Raw")[1].click();
scrollToTop();
}
function switch_to_generation_parameters() {
2025-06-18 10:22:36 -07:00
document.getElementById("parameters-button").click();
2023-10-07 19:07:57 -07:00
findButtonsByText("Generation")[0].click();
scrollToTop();
}
function switch_to_character() {
2025-06-18 10:22:36 -07:00
document.getElementById("character-tab-button").click();
2023-10-07 19:07:57 -07:00
scrollToTop();
}