Code cleanup
This commit is contained in:
@@ -13,6 +13,7 @@ js_dest_path = os.path.join(comfy_path, "web", "extensions", "SDPromptReader")
|
||||
os.makedirs(js_dest_path, exist_ok=True)
|
||||
|
||||
files_to_copy = [
|
||||
"utils.js",
|
||||
"promptDisplay.js",
|
||||
"parameterDisplay.js",
|
||||
"seedGen.js",
|
||||
|
||||
+3
-10
@@ -1,14 +1,6 @@
|
||||
import {app} from "../../scripts/app.js";
|
||||
import {ComfyWidgets} from "../../scripts/widgets.js";
|
||||
|
||||
// Create a read-only string widget
|
||||
function createWidget(app, node, widgetName, type) {
|
||||
const widget = ComfyWidgets[type](node, widgetName, ["STRING", {multiline: true}], app).widget;
|
||||
widget.inputEl.readOnly = true;
|
||||
widget.inputEl.style.textAlign = "center";
|
||||
widget.inputEl.style.fontSize = "0.75rem";
|
||||
return widget;
|
||||
}
|
||||
import {createTextWidget} from "./utils.js"
|
||||
|
||||
app.registerExtension({
|
||||
name: "sd_prompt_reader.extractorDisplay",
|
||||
@@ -20,7 +12,8 @@ app.registerExtension({
|
||||
const result = onNodeCreated?.apply(this, arguments);
|
||||
|
||||
// Create widgets
|
||||
const value_display = createWidget(app, this, "value_display", "STRING");
|
||||
const styles = {textAlign: "center", fontSize: "0.75rem"}
|
||||
const value_display = createTextWidget(app, this, "value_display", styles);
|
||||
};
|
||||
|
||||
// Update widgets
|
||||
|
||||
+3
-9
@@ -1,13 +1,6 @@
|
||||
import {app} from "../../scripts/app.js";
|
||||
import {ComfyWidgets} from "../../scripts/widgets.js";
|
||||
|
||||
// Create a read-only string widget with opacity set
|
||||
function createWidget(app, node, widgetName) {
|
||||
const widget = ComfyWidgets["STRING"](node, widgetName, ["STRING", {multiline: true}], app).widget;
|
||||
widget.inputEl.readOnly = true;
|
||||
widget.inputEl.style.opacity = 0.7;
|
||||
return widget;
|
||||
}
|
||||
import {createTextWidget} from "./utils.js"
|
||||
|
||||
// Displays file list on the node
|
||||
app.registerExtension({
|
||||
@@ -20,7 +13,8 @@ app.registerExtension({
|
||||
const result = onNodeCreated?.apply(this, arguments);
|
||||
|
||||
// Create prompt and setting widgets
|
||||
const fileList = createWidget(app, this, "fileList");
|
||||
const styles = {opacity: 0.7}
|
||||
const fileList =createTextWidget(app, this, "fileList", styles);
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
+4
-11
@@ -1,14 +1,6 @@
|
||||
import {app} from "../../scripts/app.js";
|
||||
import {ComfyWidgets} from "../../scripts/widgets.js";
|
||||
|
||||
// Create a read-only string widget
|
||||
function createWidget(app, node, widgetName, type) {
|
||||
const widget = ComfyWidgets[type](node, widgetName, ["STRING", {multiline: true}], app).widget;
|
||||
widget.inputEl.readOnly = true;
|
||||
widget.inputEl.style.textAlign = "center";
|
||||
widget.inputEl.style.fontSize = "0.75rem";
|
||||
return widget;
|
||||
}
|
||||
import {createTextWidget} from "./utils.js"
|
||||
|
||||
app.registerExtension({
|
||||
name: "sd_prompt_reader.parameterDisplay",
|
||||
@@ -20,8 +12,9 @@ app.registerExtension({
|
||||
const result = onNodeCreated?.apply(this, arguments);
|
||||
|
||||
// Create widgets
|
||||
const steps_display = createWidget(app, this, "steps_display", "STRING");
|
||||
const aspect_ratio_display = createWidget(app, this, "aspect_ratio_display", "STRING");
|
||||
const styles = {textAlign: "center", fontSize: "0.75rem"}
|
||||
const steps_display = createTextWidget(app, this, "steps_display", styles);
|
||||
const aspect_ratio_display = createTextWidget(app, this, "aspect_ratio_display", styles);
|
||||
|
||||
// Resize the node
|
||||
const nodeWidth = this.size[0];
|
||||
|
||||
+5
-11
@@ -1,13 +1,6 @@
|
||||
import {app} from "../../scripts/app.js";
|
||||
import {ComfyWidgets} from "../../scripts/widgets.js";
|
||||
|
||||
// Create a read-only string widget with opacity set
|
||||
function createWidget(app, node, widgetName) {
|
||||
const widget = ComfyWidgets["STRING"](node, widgetName, ["STRING", {multiline: true}], app).widget;
|
||||
widget.inputEl.readOnly = true;
|
||||
widget.inputEl.style.opacity = 0.7;
|
||||
return widget;
|
||||
}
|
||||
import {createTextWidget} from "./utils.js"
|
||||
|
||||
// Displays prompt and setting on the node
|
||||
app.registerExtension({
|
||||
@@ -20,9 +13,10 @@ app.registerExtension({
|
||||
const result = onNodeCreated?.apply(this, arguments);
|
||||
|
||||
// Create prompt and setting widgets
|
||||
const positive = createWidget(app, this, "positive");
|
||||
const negative = createWidget(app, this, "negative");
|
||||
const setting = createWidget(app, this, "setting");
|
||||
const styles = {opacity: 0.7}
|
||||
const positive = createTextWidget(app, this, "positive", styles);
|
||||
const negative = createTextWidget(app, this, "negative", styles);
|
||||
const setting = createTextWidget(app, this, "setting", styles);
|
||||
// Resize the node
|
||||
const nodeWidth = this.size[0];
|
||||
const nodeHeight = this.size[1];
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import {app} from "../../scripts/app.js";
|
||||
import {ComfyWidgets} from "../../scripts/widgets.js";
|
||||
|
||||
// Create a read-only string widget
|
||||
export function createTextWidget(app, node, widgetName, styles = {}) {
|
||||
const widget = ComfyWidgets["STRING"](node, widgetName, ["STRING", {multiline: true}], app).widget;
|
||||
widget.inputEl.readOnly = true;
|
||||
Object.assign(widget.inputEl.style, styles);
|
||||
return widget;
|
||||
}
|
||||
Reference in New Issue
Block a user