aboutsummaryrefslogtreecommitdiffstats
path: root/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'javascript')
-rw-r--r--javascript/extensions.js22
-rw-r--r--javascript/hints.js4
-rw-r--r--javascript/imageviewerGamepad.js36
-rw-r--r--javascript/ui.js16
4 files changed, 76 insertions, 2 deletions
diff --git a/javascript/extensions.js b/javascript/extensions.js
index 72924a28..3c2f995a 100644
--- a/javascript/extensions.js
+++ b/javascript/extensions.js
@@ -47,3 +47,25 @@ function install_extension_from_index(button, url){
gradioApp().querySelector('#install_extension_button').click()
}
+
+function config_state_confirm_restore(_, config_state_name, config_restore_type) {
+ if (config_state_name == "Current") {
+ return [false, config_state_name, config_restore_type];
+ }
+ let restored = "";
+ if (config_restore_type == "extensions") {
+ restored = "all saved extension versions";
+ } else if (config_restore_type == "webui") {
+ restored = "the webui version";
+ } else {
+ restored = "the webui version and all saved extension versions";
+ }
+ let confirmed = confirm("Are you sure you want to restore from this state?\nThis will reset " + restored + ".");
+ if (confirmed) {
+ restart_reload();
+ gradioApp().querySelectorAll('#extensions .extension_status').forEach(function(x){
+ x.innerHTML = "Loading..."
+ })
+ }
+ return [confirmed, config_state_name, config_restore_type];
+}
diff --git a/javascript/hints.js b/javascript/hints.js
index 00920b84..23d85710 100644
--- a/javascript/hints.js
+++ b/javascript/hints.js
@@ -85,7 +85,6 @@ titles = {
"vram": "Torch active: Peak amount of VRAM used by Torch during generation, excluding cached data.\nTorch reserved: Peak amount of VRAM allocated by Torch, including all active and cached data.\nSys VRAM: Peak amount of VRAM allocation across all applications / total GPU VRAM (peak utilization%).",
"Eta noise seed delta": "If this values is non-zero, it will be added to seed and used to initialize RNG for noises when using samplers with Eta. You can use this to produce even more variation of images, or you can use this to match images of other software if you know what you are doing.",
- "Do not add watermark to images": "If this option is enabled, watermark will not be added to created images. Warning: if you do not add watermark, you may be behaving in an unethical manner.",
"Filename word regex": "This regular expression will be used extract words from filename, and they will be joined using the option below into label text used for training. Leave empty to keep filename text as it is.",
"Filename join string": "This string will be used to join split words into a single line if the option above is enabled.",
@@ -111,7 +110,8 @@ titles = {
"Resize height to": "Resizes image to this height. If 0, height is inferred from either of two nearby sliders.",
"Multiplier for extra networks": "When adding extra network such as Hypernetwork or Lora to prompt, use this multiplier for it.",
"Discard weights with matching name": "Regular expression; if weights's name matches it, the weights is not written to the resulting checkpoint. Use ^model_ema to discard EMA weights.",
- "Extra networks tab order": "Comma-separated list of tab names; tabs listed here will appear in the extra networks UI first and in order lsited."
+ "Extra networks tab order": "Comma-separated list of tab names; tabs listed here will appear in the extra networks UI first and in order lsited.",
+ "Negative Guidance minimum sigma": "Skip negative prompt for steps where image is already mostly denoised; the higher this value, the more skips there will be; provides increased performance in exchange for minor quality reduction."
}
diff --git a/javascript/imageviewerGamepad.js b/javascript/imageviewerGamepad.js
new file mode 100644
index 00000000..29bd7140
--- /dev/null
+++ b/javascript/imageviewerGamepad.js
@@ -0,0 +1,36 @@
+ let delay = 350//ms
+ window.addEventListener('gamepadconnected', (e) => {
+ console.log("Gamepad connected!")
+ const gamepad = e.gamepad;
+ setInterval(() => {
+ const xValue = gamepad.axes[0].toFixed(2);
+ if (xValue < -0.3) {
+ modalPrevImage(e);
+ } else if (xValue > 0.3) {
+ modalNextImage(e);
+ }
+
+ }, delay);
+ });
+
+
+ /*
+ Primarily for vr controller type pointer devices.
+ I use the wheel event because there's currently no way to do it properly with web xr.
+ */
+
+ let isScrolling = false;
+ window.addEventListener('wheel', (e) => {
+ if (isScrolling) return;
+ isScrolling = true;
+
+ if (e.deltaX <= -0.6) {
+ modalPrevImage(e);
+ } else if (e.deltaX >= 0.6) {
+ modalNextImage(e);
+ }
+
+ setTimeout(() => {
+ isScrolling = false;
+ }, delay);
+ }); \ No newline at end of file
diff --git a/javascript/ui.js b/javascript/ui.js
index 4a440193..0ba92ef8 100644
--- a/javascript/ui.js
+++ b/javascript/ui.js
@@ -361,3 +361,19 @@ function selectCheckpoint(name){
desiredCheckpointName = name;
gradioApp().getElementById('change_checkpoint').click()
}
+
+function currentImg2imgSourceResolution(_, _, scaleBy){
+ var img = gradioApp().querySelector('#mode_img2img > div[style="display: block;"] img')
+ return img ? [img.naturalWidth, img.naturalHeight, scaleBy] : [0, 0, scaleBy]
+}
+
+function updateImg2imgResizeToTextAfterChangingImage(){
+ // At the time this is called from gradio, the image has no yet been replaced.
+ // There may be a better solution, but this is simple and straightforward so I'm going with it.
+
+ setTimeout(function() {
+ gradioApp().getElementById('img2img_update_resize_to').click()
+ }, 500);
+
+ return []
+}