text-generation-webui/js/switch_tabs.js

53 lines
1.2 KiB
JavaScript
Raw Normal View History

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