aboutsummaryrefslogtreecommitdiffstats
path: root/javascript
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2022-09-18 19:25:18 +0000
committerAUTOMATIC <16777216c@gmail.com>2022-09-18 19:25:18 +0000
commitf3d83fd68ab2458f0a24fb242e557b95c1294bb1 (patch)
treeebc699c6c11aea4a9e66f6b2d0593ea1988f4289 /javascript
parent21086e60a9e4ad6f677ccc7719be651356c18a2e (diff)
downloadstable-diffusion-webui-gfx803-f3d83fd68ab2458f0a24fb242e557b95c1294bb1.tar.gz
stable-diffusion-webui-gfx803-f3d83fd68ab2458f0a24fb242e557b95c1294bb1.tar.bz2
stable-diffusion-webui-gfx803-f3d83fd68ab2458f0a24fb242e557b95c1294bb1.zip
add read access to settings for jsavascript
add an option to disable lightbox modal
Diffstat (limited to 'javascript')
-rw-r--r--javascript/imageviewer.js4
-rw-r--r--javascript/ui.js39
2 files changed, 41 insertions, 2 deletions
diff --git a/javascript/imageviewer.js b/javascript/imageviewer.js
index 95b8108d..880f1183 100644
--- a/javascript/imageviewer.js
+++ b/javascript/imageviewer.js
@@ -70,8 +70,8 @@ function showGalleryImage(){
e.style.cursor='pointer'
e.addEventListener('click', function (evt) {
- showModal(evt)
-
+ if(!opts.js_modal_lightbox) return;
+ showModal(evt)
},true);
}
});
diff --git a/javascript/ui.js b/javascript/ui.js
index c39e96a1..f3860d2e 100644
--- a/javascript/ui.js
+++ b/javascript/ui.js
@@ -59,3 +59,42 @@ function ask_for_style_name(_, prompt_text, negative_prompt_text) {
name_ = prompt('Style name:')
return name_ === null ? [null, null, null]: [name_, prompt_text, negative_prompt_text]
}
+
+opts = {}
+function apply_settings(jsdata){
+ console.log(jsdata)
+
+ opts = JSON.parse(jsdata)
+
+ return jsdata
+}
+
+onUiUpdate(function(){
+ if(Object.keys(opts).length != 0) return;
+
+ json_elem = gradioApp().getElementById('settings_json')
+ if(json_elem == null) return;
+
+ textarea = json_elem.querySelector('textarea')
+ jsdata = textarea.value
+ opts = JSON.parse(jsdata)
+
+
+ Object.defineProperty(textarea, 'value', {
+ set: function(newValue) {
+ var valueProp = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value');
+ var oldValue = valueProp.get.call(textarea);
+ valueProp.set.call(textarea, newValue);
+
+ if (oldValue != newValue) {
+ opts = JSON.parse(textarea.value)
+ }
+ },
+ get: function() {
+ var valueProp = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value');
+ return valueProp.get.call(textarea);
+ }
+ });
+
+ json_elem.parentElement.style.display="none"
+})