text-generation-webui/js/switch_tabs.js

41 lines
1,022 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
}
2026-03-30 17:44:19 -07:00
function findButtonsByText(buttonText, container = document) {
return Array.from(container.getElementsByTagName("button"))
.filter(btn => btn.textContent.trim() === buttonText);
2023-08-29 13:22:15 -07:00
}
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();
}
function switch_to_image_ai_generate() {
const container = document.querySelector("#image-ai-tab");
2026-03-30 17:44:19 -07:00
const generateBtn = findButtonsByText("Generate", container)[0];
if (generateBtn) {
generateBtn.click();
}
scrollToTop();
}