mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2025-12-06 07:12:10 +01:00
Code simplification
This commit is contained in:
parent
22cc9e0115
commit
8b7eb5c87c
|
|
@ -1,24 +1,14 @@
|
|||
let chat_tab = document.getElementById("chat-tab");
|
||||
let main_parent = chat_tab.parentNode;
|
||||
|
||||
function scrollToTop() {
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
// behavior: 'smooth'
|
||||
});
|
||||
window.scrollTo({ top: 0 });
|
||||
}
|
||||
|
||||
function findButtonsByText(buttonText) {
|
||||
const buttons = document.getElementsByTagName("button");
|
||||
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);
|
||||
if (buttons[i].textContent.trim() === buttonText) {
|
||||
matchingButtons.push(buttons[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -26,28 +16,23 @@ function findButtonsByText(buttonText) {
|
|||
}
|
||||
|
||||
function switch_to_chat() {
|
||||
let chat_tab_button = main_parent.childNodes[0].childNodes[1];
|
||||
chat_tab_button.click();
|
||||
document.getElementById("chat-tab-button").click();
|
||||
scrollToTop();
|
||||
}
|
||||
|
||||
function switch_to_notebook() {
|
||||
let notebook_tab_button = main_parent.childNodes[0].childNodes[9];
|
||||
notebook_tab_button.click();
|
||||
document.getElementById("notebook-parent-tab-button").click();
|
||||
findButtonsByText("Raw")[1].click();
|
||||
scrollToTop();
|
||||
}
|
||||
|
||||
function switch_to_generation_parameters() {
|
||||
let parameters_tab_button = main_parent.childNodes[0].childNodes[13];
|
||||
parameters_tab_button.click();
|
||||
document.getElementById("parameters-button").click();
|
||||
findButtonsByText("Generation")[0].click();
|
||||
scrollToTop();
|
||||
}
|
||||
|
||||
function switch_to_character() {
|
||||
let parameters_tab_button = main_parent.childNodes[0].childNodes[13];
|
||||
parameters_tab_button.click();
|
||||
findButtonsByText("Character")[0].click();
|
||||
document.getElementById("character-tab-button").click();
|
||||
scrollToTop();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue