This commit is contained in:
justumen
2024-09-16 00:26:40 +02:00
parent 5b412a1243
commit a3f930d8c6
8 changed files with 104 additions and 57 deletions

View File

@@ -22,16 +22,12 @@ app.registerExtension({
})
.catch(error => console.error('Error:', error));
});
// Set seed widget to hidden input
const seedWidget = node.widgets.find((w) => w.name === "seed");
if (seedWidget) {
seedWidget.type = "HIDDEN";
}
}
}
});
// BASIC BUTTON
// app.registerExtension({
// name: "Bjornulf.PauseResume",
// async nodeCreated(node) {
// if (node.comfyClass === "Bjornulf_PauseResume") {
// node.addWidget("button","Resume","Resume", (...args) => { console.log("lol"); } )
// }
// }
// });
});

View File

@@ -4,33 +4,31 @@ app.registerExtension({
name: "Bjornulf.PickInput",
async nodeCreated(node) {
if (node.comfyClass === "Bjornulf_PickInput") {
const updateInputButtons = (numInputs) => {
// Remove all existing widgets
node.widgets.length = 1;
// Re-add the number_of_inputs widget
// const numInputsWidget = node.addWidget("number", "Number of Inputs", "number_of_inputs", (v) => {
// updateInputs();
// app.graph.setDirtyCanvas(true);
// return v;
// }, { min: 1, max: 10, step: 1, precision: 0 });
// Remove only the dynamic widgets (input buttons and stop button)
node.widgets = node.widgets.filter((w) => !w.dynamicWidget);
// Add new input buttons
for (let i = 1; i < numInputs + 1; i++) {
node.addWidget("button", `Input ${i}`, `input_button_${i}`, () => {
fetch(`/bjornulf_select_input_${i}`, { method: "GET" })
.then((response) => response.text())
.then((data) => {
console.log(`Input ${i} response:`, data);
// You can update the UI here if needed
})
.catch((error) => console.error("Error:", error));
});
for (let i = 1; i <= numInputs; i++) {
const inputButton = node.addWidget(
"button",
`Input ${i}`,
`input_button_${i}`,
() => {
fetch(`/bjornulf_select_input_${i}`, { method: "GET" })
.then((response) => response.text())
.then((data) => {
console.log(`Input ${i} response:`, data);
// You can update the UI here if needed
})
.catch((error) => console.error("Error:", error));
}
);
inputButton.dynamicWidget = true; // Tag as dynamic
}
// Re-add the Stop button
node.addWidget("button", "Stop", "Stop", () => {
// Add the Stop button
const stopButton = node.addWidget("button", "Stop", "Stop", () => {
fetch("/bjornulf_stop_pick", { method: "GET" })
.then((response) => response.text())
.then((data) => {
@@ -39,6 +37,7 @@ app.registerExtension({
})
.catch((error) => console.error("Error:", error));
});
stopButton.dynamicWidget = true; // Tag as dynamic
node.setSize(node.computeSize());
};
@@ -61,7 +60,6 @@ app.registerExtension({
input.name.startsWith("input_")
);
// const Everything = Symbol('Everything');
// Determine if we need to add or remove inputs
if (existingInputs.length < numInputs) {
// Add new inputs if not enough existing
@@ -86,12 +84,6 @@ app.registerExtension({
node.setSize(node.computeSize());
};
// Set seed widget to hidden input
const seedWidget = node.widgets.find((w) => w.name === "seed");
if (seedWidget) {
seedWidget.type = "HIDDEN";
}
// Move number_of_inputs to the top initially
const numInputsWidget = node.widgets.find(
(w) => w.name === "number_of_inputs"
@@ -109,6 +101,12 @@ app.registerExtension({
// Delay the initial update to ensure node is fully initialized
setTimeout(updateInputs, 0);
// Hide the seed widget
const seedWidget = node.widgets.find((w) => w.name === "seed");
if (seedWidget) {
seedWidget.type = "HIDDEN";
}
}
},
});
});

View File

@@ -36,10 +36,10 @@ app.registerExtension({
};
// Set seed widget to hidden input
const seedWidget = node.widgets.find(w => w.name === "seed");
if (seedWidget) {
seedWidget.type = "HIDDEN";
}
// const seedWidget = node.widgets.find(w => w.name === "seed");
// if (seedWidget) {
// seedWidget.type = "HIDDEN";
// }
// Move number_of_images to the top initially
const numInputsWidget = node.widgets.find(w => w.name === "number_of_images");