mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 03:01:54 +00:00
Merge pull request #55 from InventivetalentDev/master
add options to use Array.filter instead of loop & limit result size, …
This commit is contained in:
15862
build/litegraph.js
15862
build/litegraph.js
File diff suppressed because it is too large
Load Diff
8239
build/litegraph.min.js
vendored
8239
build/litegraph.min.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -6755,6 +6755,9 @@ LGraphCanvas.prototype.prompt = function( title, value, callback, event )
|
|||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LGraphCanvas.search_filter = false;
|
||||||
|
LGraphCanvas.search_limit = -1;
|
||||||
LGraphCanvas.prototype.showSearchBox = function(event)
|
LGraphCanvas.prototype.showSearchBox = function(event)
|
||||||
{
|
{
|
||||||
var that = this;
|
var that = this;
|
||||||
@@ -6883,30 +6886,48 @@ LGraphCanvas.prototype.showSearchBox = function(event)
|
|||||||
selected.scrollIntoView();
|
selected.scrollIntoView();
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshHelper()
|
function refreshHelper() {
|
||||||
{
|
timeout = null;
|
||||||
timeout = null;
|
var str = input.value;
|
||||||
var str = input.value;
|
first = null;
|
||||||
first = null;
|
helper.innerHTML = "";
|
||||||
helper.innerHTML = "";
|
if (!str)
|
||||||
if(!str)
|
return;
|
||||||
return;
|
|
||||||
|
|
||||||
if( that.onSearchBox )
|
if (that.onSearchBox){
|
||||||
that.onSearchBox( help, str, graphcanvas );
|
that.onSearchBox(help, str, graphcanvas);
|
||||||
else
|
} else {
|
||||||
for( var i in LiteGraph.registered_node_types )
|
function addResult(result) {
|
||||||
if(i.indexOf(str) != -1)
|
var help = document.createElement("div");
|
||||||
{
|
if (!first) first = result;
|
||||||
var help = document.createElement("div");
|
help.innerText = result;
|
||||||
if(!first) first = i;
|
help.className = "litegraph lite-search-item";
|
||||||
help.innerText = i;
|
help.addEventListener("click", function (e) {
|
||||||
help.className = "litegraph lite-search-item";
|
select(this.innerText);
|
||||||
help.addEventListener("click", function(e){
|
});
|
||||||
select( this.innerText );
|
helper.appendChild(help);
|
||||||
});
|
}
|
||||||
helper.appendChild(help);
|
let c = 0;
|
||||||
|
if(LGraphCanvas.search_filter) {
|
||||||
|
str = str.toLowerCase();
|
||||||
|
|
||||||
|
var keys = Object.keys(LiteGraph.registered_node_types);
|
||||||
|
var filtered = keys.filter(function (item) {
|
||||||
|
return item.toLowerCase().indexOf(str) !== -1;
|
||||||
|
});
|
||||||
|
for(var i = 0; i < filtered.length; i++) {
|
||||||
|
addResult(filtered[i]);
|
||||||
|
if(LGraphCanvas.search_limit !== -1 && c++ > LGraphCanvas.search_limit) break;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (var i in LiteGraph.registered_node_types) {
|
||||||
|
if (i.indexOf(str) != -1) {
|
||||||
|
addResult(i);
|
||||||
|
if(LGraphCanvas.search_limit !== -1 && c++ > LGraphCanvas.search_limit) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dialog;
|
return dialog;
|
||||||
|
|||||||
Reference in New Issue
Block a user