From f10a840de645287a90e2c81f5b3c2f10c07abcfc Mon Sep 17 00:00:00 2001 From: pythongosssss <125205205+pythongosssss@users.noreply.github.com> Date: Fri, 5 May 2023 21:33:56 +0100 Subject: [PATCH] Remove random --- #do-not-use/noob-nodes/noobNodes.js | 158 ---------------------------- play-audio/playAudio.js | 74 ------------- 2 files changed, 232 deletions(-) delete mode 100644 #do-not-use/noob-nodes/noobNodes.js delete mode 100644 play-audio/playAudio.js diff --git a/#do-not-use/noob-nodes/noobNodes.js b/#do-not-use/noob-nodes/noobNodes.js deleted file mode 100644 index da6e615..0000000 --- a/#do-not-use/noob-nodes/noobNodes.js +++ /dev/null @@ -1,158 +0,0 @@ -import { app } from "/scripts/app.js"; -import { ComfyWidgets } from "/scripts/widgets.js"; - -app.registerExtension({ - name: "test", - addCustomNodeDefs(defs) { - defs["Txt2Img"] = { - name: "Txt2Img", - category: "basic", - input: { - required: { - clip: ["CLIP"], - positive: [ - "STRING", - { - multiline: true, - placeholder: "Positive", - }, - ], - negative: [ - "STRING", - { - multiline: true, - placeholder: "Negative", - }, - ], - }, - }, - output: ["CONDITIONING", "CONDITIONING"], - }; - }, - nodeCreated(node, app) { - if (node.constructor.type === "Txt2Img") { - node.size = [400, 500]; - - node.getInnerNodes = function () { - const assignValue = (ourName, theirNode, theirName) => { - if (!theirName) { - theirName = ourName; - } - const ourWidget = this.widgets.find((w) => w.name === ourName); - if (!ourWidget) { - throw new Error("Unable to find Txt2Img widget: " + ourName); - } - const thierWidget = theirNode.widgets.find((w) => w.name === theirName); - if (!thierWidget) { - throw new Error("Unable to find " + theirNode.constructor.type + " widget: " + ourName); - } - thierWidget.value = ourWidget.value; - }; - - const clip1 = LiteGraph.createNode("CLIPTextEncode"); - clip1.graph = app.graph; - assignValue("positive", clip1, "text"); - - const clip2 = LiteGraph.createNode("CLIPTextEncode"); - clip2.graph = app.graph; - assignValue("negative", clip2, "text"); - - clip1.inputs[0].link = this.inputs[0].link; - clip2.inputs[0].link = this.inputs[0].link; - clip1.outputs[0].links = this.outputs[0].links; - clip2.outputs[0].links = this.outputs[1].links; - - clip1.id = -1; - clip2.id = -2; - - return [clip1, clip2]; - }; - } - }, - - // addCustomNodeDefs(defs) { - // // Simple node added using same format as nodes from the server - // defs["Txt2Img"] = { - // name: "Txt2Img", - // category: "basic", - // input: { - // required: { - // model: ["MODEL"], - // clip: ["CLIP"], - // ...defs["EmptyLatentImage"].input.required, - // ...defs["VAELoader"].input.required, - // positive: [ - // "STRING", - // { - // multiline: true, - // placeholder: "Positive", - // }, - // ], - // negative: [ - // "STRING", - // { - // multiline: true, - // placeholder: "Negative", - // }, - // ], - // seed: defs["KSampler"].input.required.seed, - // steps: defs["KSampler"].input.required.steps, - // cfg: defs["KSampler"].input.required.cfg, - // sampler_name: defs["KSampler"].input.required.sampler_name, - // scheduler: defs["KSampler"].input.required.scheduler, - // }, - // }, - // output: ["IMAGE", "VAE"], - // }; - // }, - // nodeCreated(node, app) { - // if (node.constructor.type === "Txt2Img") { - // node.size = [400, 500]; - - // node.getInnerNodes = function () { - // const assignValues = (theirNode) => { - // for (const w of theirNode.widgets) { - // const ow = node.widgets.find((ow) => ow.name === w.name); - // if (ow) { - // w.value = ow.value; - // } - // } - // }; - - // const assignValue = (ourName, theirNode, theirName) => { - // if (!theirName) { - // theirName = ourName; - // } - // const ourWidget = this.widgets.find((w) => w.name === ourName); - // if (!ourWidget) { - // throw new Error("Unable to find Txt2Img widget: " + ourName); - // } - // const thierWidget = theirNode.widgets.find((w) => w.name === theirName); - // if (!thierWidget) { - // throw new Error("Unable to find " + theirNode.constructor.type + " widget: " + ourName); - // } - // thierWidget.value = ourWidget.value; - // }; - - // const img = LiteGraph.createNode("EmptyLatentImage"); - // assignValues(img); - - // const vae = LiteGraph.createNode("VAELoader"); - // assignValues(img); - - // const clip1 = LiteGraph.createNode("CLIPTextEncode"); - // assignValue("positive", clip1, "text"); - - // const clip2 = LiteGraph.createNode("CLIPTextEncode"); - // assignValue("negative", clip1, "text"); - - // const sampler = LiteGraph.createNode("KSampler"); - // assignValues(sampler); - - // debugger; - - // return [img, vae, clip1, clip2, sampler]; - // }; - // } - // }, -}); diff --git a/play-audio/playAudio.js b/play-audio/playAudio.js deleted file mode 100644 index fc1eb6c..0000000 --- a/play-audio/playAudio.js +++ /dev/null @@ -1,74 +0,0 @@ -import { app } from "/scripts/app.js"; - -app.registerExtension({ - name: "pysssss.PlayAudio", - async beforeRegisterNodeDef(nodeType, nodeData, app) { - if (nodeData.name === "SaveAudioNode") { - const WIDGETS = Symbol(); - nodeType.prototype.onExecuted = function (data) { - if (WIDGETS in this) { - // Clear all other widgets - if (this.widgets) { - this.widgets.length = this[WIDGETS]; - } - if (this.widgets_values) { - this.widgets_values.length = this.widgets.length; - } - } else { - // On first execute store widget count - this[WIDGETS] = this.widgets?.length || 0; - } - - // For each file create a seek bar + play button - for (const file of data) { - let isTick = true; - const audio = new Audio(`/view?filename=${encodeURIComponent(file)}`); - const slider = this.addWidget( - "slider", - "loading", - 0, - (v) => { - if (!isTick) { - audio.currentTime = v; - } - isTick = false; - }, - { - min: 0, - max: 0, - } - ); - - const button = this.addWidget("button", `Play ${file}`, "play", () => { - try { - if (audio.paused) { - audio.play(); - button.name = `Pause ${file}`; - } else { - audio.pause(); - button.name = `Play ${file}`; - } - } catch (error) { - alert(error); - } - app.canvas.setDirty(true); - }); - audio.addEventListener("timeupdate", () => { - isTick = true; - slider.value = audio.currentTime; - app.canvas.setDirty(true); - }); - audio.addEventListener("ended", () => { - button.name = `Play ${file}`; - app.canvas.setDirty(true); - }); - audio.addEventListener("loadedmetadata", () => { - slider.options.max = audio.duration; - slider.name = `(${audio.duration})`; - app.canvas.setDirty(true); - }); - } - }; - } - }, -});