text-generation-webui/js/switch_tabs.js

60 lines
1.5 KiB
JavaScript
Raw Normal View History

2023-10-08 04:07:57 +02:00
let chat_tab = document.getElementById("chat-tab");
let main_parent = chat_tab.parentNode;
2023-08-14 03:48:15 +02:00
function scrollToTop() {
2023-10-08 04:07:57 +02:00
window.scrollTo({
top: 0,
// behavior: 'smooth'
});
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 = [];
buttonText = buttonText.trim();
for (let i = 0; i < buttons.length; i++) {
const button = buttons[i];
const buttonInnerText = button.textContent.trim();
if (buttonInnerText === buttonText) {
matchingButtons.push(button);
}
}
return matchingButtons;
}
function switch_to_chat() {
2023-10-08 04:07:57 +02:00
let chat_tab_button = main_parent.childNodes[0].childNodes[1];
chat_tab_button.click();
scrollToTop();
}
function switch_to_default() {
2024-03-26 20:32:20 +01:00
let default_tab_button = main_parent.childNodes[0].childNodes[5];
2023-10-08 04:07:57 +02:00
default_tab_button.click();
scrollToTop();
}
function switch_to_notebook() {
2024-03-26 20:32:20 +01:00
let notebook_tab_button = main_parent.childNodes[0].childNodes[9];
2023-10-08 04:07:57 +02:00
notebook_tab_button.click();
findButtonsByText("Raw")[1].click();
scrollToTop();
}
function switch_to_generation_parameters() {
2024-03-26 20:32:20 +01:00
let parameters_tab_button = main_parent.childNodes[0].childNodes[13];
2023-10-08 04:07:57 +02:00
parameters_tab_button.click();
findButtonsByText("Generation")[0].click();
scrollToTop();
}
function switch_to_character() {
2024-03-26 20:32:20 +01:00
let parameters_tab_button = main_parent.childNodes[0].childNodes[13];
2023-10-08 04:07:57 +02:00
parameters_tab_button.click();
findButtonsByText("Character")[0].click();
scrollToTop();
}