mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-05-14 00:16:43 +08:00
JS fixes and features
This commit is contained in:
parent
27b3d3e3a3
commit
59d11b615d
@ -4,6 +4,9 @@ import { app } from "../../../scripts/app.js";
|
|||||||
app.registerExtension({
|
app.registerExtension({
|
||||||
name: "KJNodes.browserstatus",
|
name: "KJNodes.browserstatus",
|
||||||
setup() {
|
setup() {
|
||||||
|
if (!app.ui.settings.getSettingValue("KJNodes.browserStatus")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
api.addEventListener("status", ({ detail }) => {
|
api.addEventListener("status", ({ detail }) => {
|
||||||
let title = "ComfyUI";
|
let title = "ComfyUI";
|
||||||
let favicon = "green";
|
let favicon = "green";
|
||||||
@ -11,7 +14,6 @@ app.registerExtension({
|
|||||||
|
|
||||||
if (queueRemaining) {
|
if (queueRemaining) {
|
||||||
favicon = "red";
|
favicon = "red";
|
||||||
|
|
||||||
title = `00% - ${queueRemaining} | ${title}`;
|
title = `00% - ${queueRemaining} | ${title}`;
|
||||||
}
|
}
|
||||||
let link = document.querySelector("link[rel~='icon']");
|
let link = document.querySelector("link[rel~='icon']");
|
||||||
@ -22,9 +24,8 @@ app.registerExtension({
|
|||||||
}
|
}
|
||||||
link.href = new URL(`../${favicon}.png`, import.meta.url);
|
link.href = new URL(`../${favicon}.png`, import.meta.url);
|
||||||
document.title = title;
|
document.title = title;
|
||||||
|
|
||||||
});
|
});
|
||||||
//add progress to the title
|
//add progress to the title
|
||||||
api.addEventListener("progress", ({ detail }) => {
|
api.addEventListener("progress", ({ detail }) => {
|
||||||
const { value, max } = detail;
|
const { value, max } = detail;
|
||||||
const progress = Math.floor((value / max) * 100);
|
const progress = Math.floor((value / max) * 100);
|
||||||
@ -34,8 +35,19 @@ app.registerExtension({
|
|||||||
const paddedProgress = String(progress).padStart(2, '0');
|
const paddedProgress = String(progress).padStart(2, '0');
|
||||||
title = `${paddedProgress}% ${title.replace(/^\d+%\s/, '')}`;
|
title = `${paddedProgress}% ${title.replace(/^\d+%\s/, '')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
document.title = title;
|
document.title = title;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
init() {
|
||||||
|
if (!app.ui.settings.getSettingValue("KJNodes.browserStatus")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const pythongossFeed = app.extensions.find(
|
||||||
|
(e) => e.name === 'pysssss.FaviconStatus',
|
||||||
|
)
|
||||||
|
if (pythongossFeed) {
|
||||||
|
console.warn("KJNodes - Overriding pysssss.FaviconStatus")
|
||||||
|
app.extensions = app.extensions.filter(item => item !== pythongossFeed);
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
@ -1,7 +1,5 @@
|
|||||||
import { app } from "../../../scripts/app.js";
|
import { app } from "../../../scripts/app.js";
|
||||||
|
|
||||||
|
|
||||||
var nodeAutoColor = true
|
|
||||||
// Adds context menu entries, code partly from pyssssscustom-scripts
|
// Adds context menu entries, code partly from pyssssscustom-scripts
|
||||||
|
|
||||||
function addMenuHandler(nodeType, cb) {
|
function addMenuHandler(nodeType, cb) {
|
||||||
@ -45,13 +43,9 @@ app.registerExtension({
|
|||||||
content: "Add SetNode",
|
content: "Add SetNode",
|
||||||
callback: () => {addNode("SetNode", this, { side:"right", offset: 30 });
|
callback: () => {addNode("SetNode", this, { side:"right", offset: 30 });
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
async setup(app) {
|
async setup(app) {
|
||||||
const onChange = (value) => {
|
const onChange = (value) => {
|
||||||
@ -144,5 +138,15 @@ app.registerExtension({
|
|||||||
{ value: false, text: "Off", selected: value === false },
|
{ value: false, text: "Off", selected: value === false },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
app.ui.settings.addSetting({
|
||||||
|
id: "KJNodes.browserStatus",
|
||||||
|
name: "🦛 KJNodes: 🟢 Stoplight browser status icon 🔴",
|
||||||
|
defaultValue: false,
|
||||||
|
type: "boolean",
|
||||||
|
options: (value) => [
|
||||||
|
{ value: true, text: "On", selected: value === true },
|
||||||
|
{ value: false, text: "Off", selected: value === false },
|
||||||
|
],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -182,13 +182,16 @@ const create_documentation_stylesheet = () => {
|
|||||||
let startX, startY, startWidth, startHeight
|
let startX, startY, startWidth, startHeight
|
||||||
|
|
||||||
resizeHandle.addEventListener('mousedown', function (e) {
|
resizeHandle.addEventListener('mousedown', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
isResizing = true;
|
isResizing = true;
|
||||||
startX = e.clientX;
|
startX = e.clientX;
|
||||||
startY = e.clientY;
|
startY = e.clientY;
|
||||||
startWidth = parseInt(document.defaultView.getComputedStyle(docElement).width, 10);
|
startWidth = parseInt(document.defaultView.getComputedStyle(docElement).width, 10);
|
||||||
startHeight = parseInt(document.defaultView.getComputedStyle(docElement).height, 10);
|
startHeight = parseInt(document.defaultView.getComputedStyle(docElement).height, 10);
|
||||||
});
|
},
|
||||||
|
{ signal: this.docCtrl.signal },
|
||||||
|
);
|
||||||
|
|
||||||
// close button
|
// close button
|
||||||
const closeButton = document.createElement('div');
|
const closeButton = document.createElement('div');
|
||||||
@ -208,7 +211,9 @@ const create_documentation_stylesheet = () => {
|
|||||||
this.show_doc = !this.show_doc
|
this.show_doc = !this.show_doc
|
||||||
docElement.parentNode.removeChild(docElement)
|
docElement.parentNode.removeChild(docElement)
|
||||||
docElement = null
|
docElement = null
|
||||||
});
|
},
|
||||||
|
{ signal: this.docCtrl.signal },
|
||||||
|
);
|
||||||
|
|
||||||
document.addEventListener('mousemove', function (e) {
|
document.addEventListener('mousemove', function (e) {
|
||||||
if (!isResizing) return;
|
if (!isResizing) return;
|
||||||
@ -216,11 +221,15 @@ const create_documentation_stylesheet = () => {
|
|||||||
const newHeight = startHeight + e.clientY - startY;
|
const newHeight = startHeight + e.clientY - startY;
|
||||||
docElement.style.width = `${newWidth}px`;
|
docElement.style.width = `${newWidth}px`;
|
||||||
docElement.style.height = `${newHeight}px`;
|
docElement.style.height = `${newHeight}px`;
|
||||||
});
|
},
|
||||||
|
{ signal: this.docCtrl.signal },
|
||||||
|
);
|
||||||
|
|
||||||
document.addEventListener('mouseup', function () {
|
document.addEventListener('mouseup', function () {
|
||||||
isResizing = false
|
isResizing = false
|
||||||
})
|
},
|
||||||
|
{ signal: this.docCtrl.signal },
|
||||||
|
)
|
||||||
|
|
||||||
document.body.appendChild(docElement)
|
document.body.appendChild(docElement)
|
||||||
}
|
}
|
||||||
@ -283,6 +292,11 @@ const create_documentation_stylesheet = () => {
|
|||||||
} else {
|
} else {
|
||||||
this.show_doc = !this.show_doc
|
this.show_doc = !this.show_doc
|
||||||
}
|
}
|
||||||
|
if (this.show_doc) {
|
||||||
|
this.docCtrl = new AbortController()
|
||||||
|
} else {
|
||||||
|
this.docCtrl.abort()
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
|
|||||||
@ -144,7 +144,7 @@ app.registerExtension({
|
|||||||
this.menuItem2 = document.createElement("a");
|
this.menuItem2 = document.createElement("a");
|
||||||
this.menuItem2.href = "#";
|
this.menuItem2.href = "#";
|
||||||
this.menuItem2.id = "menu-item-2";
|
this.menuItem2.id = "menu-item-2";
|
||||||
this.menuItem2.textContent = "Placeholder";
|
this.menuItem2.textContent = "Copy coordinates to clipboard";
|
||||||
styleMenuItem(this.menuItem2);
|
styleMenuItem(this.menuItem2);
|
||||||
// Add hover effect to menu items
|
// Add hover effect to menu items
|
||||||
this.menuItem1.addEventListener('mouseover', function() {
|
this.menuItem1.addEventListener('mouseover', function() {
|
||||||
@ -243,8 +243,8 @@ function createSplineEditor(context, reset=false) {
|
|||||||
|
|
||||||
context.menuItem2.addEventListener('click', function(e) {
|
context.menuItem2.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// Add functionality for menu item 2
|
navigator.clipboard.writeText(JSON.stringify(points));
|
||||||
console.log('Option 2 clicked');
|
console.log('Copied coordinates to clipboard');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -275,6 +275,7 @@ function createSplineEditor(context, reset=false) {
|
|||||||
var points_to_sample = pointsWidget.value
|
var points_to_sample = pointsWidget.value
|
||||||
interpolationWidget.callback = () => {
|
interpolationWidget.callback = () => {
|
||||||
interpolation = interpolationWidget.value
|
interpolation = interpolationWidget.value
|
||||||
|
updatePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
tensionWidget.callback = () => {
|
tensionWidget.callback = () => {
|
||||||
@ -405,8 +406,7 @@ function createSplineEditor(context, reset=false) {
|
|||||||
return `F: ${frame}, X: ${normalizedX.toFixed(2)}, Y: ${normalizedY.toFixed(2)}`;
|
return `F: ${frame}, X: ${normalizedX.toFixed(2)}, Y: ${normalizedY.toFixed(2)}`;
|
||||||
})
|
})
|
||||||
.textStyle("orange")
|
.textStyle("orange")
|
||||||
|
|
||||||
|
|
||||||
vis.render();
|
vis.render();
|
||||||
var svgElement = vis.canvas();
|
var svgElement = vis.canvas();
|
||||||
svgElement.style['zIndex'] = "2"
|
svgElement.style['zIndex'] = "2"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user