Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
automatic1111
GitHub Repository: automatic1111/stable-diffusion-webui
Path: blob/master/javascript/extensions.js
3055 views
1
2
function extensions_apply(_disabled_list, _update_list, disable_all) {
3
var disable = [];
4
var update = [];
5
const extensions_input = gradioApp().querySelectorAll('#extensions input[type="checkbox"]');
6
if (extensions_input.length == 0) {
7
throw Error("Extensions page not yet loaded.");
8
}
9
extensions_input.forEach(function(x) {
10
if (x.name.startsWith("enable_") && !x.checked) {
11
disable.push(x.name.substring(7));
12
}
13
14
if (x.name.startsWith("update_") && x.checked) {
15
update.push(x.name.substring(7));
16
}
17
});
18
19
restart_reload();
20
21
return [JSON.stringify(disable), JSON.stringify(update), disable_all];
22
}
23
24
function extensions_check() {
25
var disable = [];
26
27
gradioApp().querySelectorAll('#extensions input[type="checkbox"]').forEach(function(x) {
28
if (x.name.startsWith("enable_") && !x.checked) {
29
disable.push(x.name.substring(7));
30
}
31
});
32
33
gradioApp().querySelectorAll('#extensions .extension_status').forEach(function(x) {
34
x.innerHTML = "Loading...";
35
});
36
37
38
var id = randomId();
39
requestProgress(id, gradioApp().getElementById('extensions_installed_html'), null, function() {
40
41
});
42
43
return [id, JSON.stringify(disable)];
44
}
45
46
function install_extension_from_index(button, url) {
47
button.disabled = "disabled";
48
button.value = "Installing...";
49
50
var textarea = gradioApp().querySelector('#extension_to_install textarea');
51
textarea.value = url;
52
updateInput(textarea);
53
54
gradioApp().querySelector('#install_extension_button').click();
55
}
56
57
function config_state_confirm_restore(_, config_state_name, config_restore_type) {
58
if (config_state_name == "Current") {
59
return [false, config_state_name, config_restore_type];
60
}
61
let restored = "";
62
if (config_restore_type == "extensions") {
63
restored = "all saved extension versions";
64
} else if (config_restore_type == "webui") {
65
restored = "the webui version";
66
} else {
67
restored = "the webui version and all saved extension versions";
68
}
69
let confirmed = confirm("Are you sure you want to restore from this state?\nThis will reset " + restored + ".");
70
if (confirmed) {
71
restart_reload();
72
gradioApp().querySelectorAll('#extensions .extension_status').forEach(function(x) {
73
x.innerHTML = "Loading...";
74
});
75
}
76
return [confirmed, config_state_name, config_restore_type];
77
}
78
79
function toggle_all_extensions(event) {
80
gradioApp().querySelectorAll('#extensions .extension_toggle').forEach(function(checkbox_el) {
81
checkbox_el.checked = event.target.checked;
82
});
83
}
84
85
function toggle_extension() {
86
let all_extensions_toggled = true;
87
for (const checkbox_el of gradioApp().querySelectorAll('#extensions .extension_toggle')) {
88
if (!checkbox_el.checked) {
89
all_extensions_toggled = false;
90
break;
91
}
92
}
93
94
gradioApp().querySelector('#extensions .all_extensions_toggle').checked = all_extensions_toggled;
95
}
96
97