Sebastiankay commited on
Commit
d4c4975
1 Parent(s): 3798fc3

24. Sept. 2024, 22:17

Browse files
Files changed (1) hide show
  1. _res/_custom.js +11 -10
_res/_custom.js CHANGED
@@ -69,6 +69,8 @@ function gradioCustomJS() {
69
  // MARK: Selectors & Elements
70
  const gradioApp = document.querySelector("gradio-app")
71
  const gradioContainer = document.querySelector("body > gradio-app > div.gradio-container")
 
 
72
  const alertModalElem = document.createElement("div")
73
  const alertModalElemP = document.createElement("p")
74
  const alertModalElemI = document.createElement("i")
@@ -126,28 +128,27 @@ function gradioCustomJS() {
126
  }
127
 
128
  onDomChange(() => {
129
- console.log("changed: " + document.querySelector("#dominant_image_color > label > textarea").value)
130
- if (document.querySelector("#dominant_image_color > label > textarea").value.match(/^rgb\((\d{1,3}),(\s\d{1,3}),(\s\d{1,3})\)$/) && document.querySelector("#output_image > div.image-container.svelte-1p15vfy > button > div > img").src) {
131
- document.querySelector("#output_image > div.image-container.svelte-1p15vfy > button > div > img").style.opacity = "0"
132
  document.querySelector("body > gradio-app > div").classList.add("fade-bg")
133
  document.querySelector("gradio-app").style.opacity = "0"
134
  setTimeout(() => {
135
- usedColor = document.querySelector("#dominant_image_color > label > textarea").value
136
  body.style.setProperty("--primary-600", usedColor)
137
  body.style.setProperty("--text-color-by-luminance", anpasseTextfarbe(usedColor))
138
- document.querySelector("gradio-app").classList.add("has-bg-image")
139
- body.style.setProperty("--bg-image-path", `url("${document.querySelector("#output_image > div.image-container.svelte-1p15vfy > button > div > img").src}")`)
140
  }, 400)
141
  setTimeout(() => {
142
- document.querySelector("gradio-app").style.opacity = "1"
143
- document.querySelector("#output_image > div.image-container.svelte-1p15vfy > button > div > img").style.opacity = "1"
144
- document.querySelector("#dominant_image_color > label > textarea").value = ""
145
  }, 800)
146
  setTimeout(() => {
147
  //document.querySelector("body > gradio-app > div").classList.remove("fade-bg")
148
  }, 2000)
149
  }
150
- //document.querySelector("body").style.setProperty("--primary-700", document.querySelector("#dominant_image_color > label > textarea").value)
151
  })
152
 
153
  // MARK: SVGs
 
69
  // MARK: Selectors & Elements
70
  const gradioApp = document.querySelector("gradio-app")
71
  const gradioContainer = document.querySelector("body > gradio-app > div.gradio-container")
72
+ const dominantColorField = document.querySelector("#dominant_image_color > label > textarea")
73
+ const outputImageElem = document.querySelector("#output_image > div.image-container.svelte-1p15vfy > button > div > img")
74
  const alertModalElem = document.createElement("div")
75
  const alertModalElemP = document.createElement("p")
76
  const alertModalElemI = document.createElement("i")
 
128
  }
129
 
130
  onDomChange(() => {
131
+ console.log("changed: " + dominantColorField.value)
132
+ if (dominantColorField.value.match(/^rgb\((\d{1,3}),(\s\d{1,3}),(\s\d{1,3})\)$/) && outputImageElem.src) {
133
+ outputImageElem.style.opacity = "0"
134
  document.querySelector("body > gradio-app > div").classList.add("fade-bg")
135
  document.querySelector("gradio-app").style.opacity = "0"
136
  setTimeout(() => {
137
+ usedColor = dominantColorField.value
138
  body.style.setProperty("--primary-600", usedColor)
139
  body.style.setProperty("--text-color-by-luminance", anpasseTextfarbe(usedColor))
140
+ gradioApp.classList.add("has-bg-image")
141
+ body.style.setProperty("--bg-image-path", `url("${outputImageElem.src}")`)
142
  }, 400)
143
  setTimeout(() => {
144
+ gradioApp.style.opacity = "1"
145
+ outputImageElem.style.opacity = "1"
146
+ dominantColorField.value = ""
147
  }, 800)
148
  setTimeout(() => {
149
  //document.querySelector("body > gradio-app > div").classList.remove("fade-bg")
150
  }, 2000)
151
  }
 
152
  })
153
 
154
  // MARK: SVGs