summaryrefslogtreecommitdiffstats
path: root/g4f/gui/client/js
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-12 11:41:27 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-12 11:41:27 +0100
commitaba4b96f23ef38ca75195b3b78a88bb92035b4a9 (patch)
tree92575678f27d48e2258e823fa299ed21af6cbad2 /g4f/gui/client/js
parentImprove preview in image generation of Gemini (diff)
downloadgpt4free-aba4b96f23ef38ca75195b3b78a88bb92035b4a9.tar
gpt4free-aba4b96f23ef38ca75195b3b78a88bb92035b4a9.tar.gz
gpt4free-aba4b96f23ef38ca75195b3b78a88bb92035b4a9.tar.bz2
gpt4free-aba4b96f23ef38ca75195b3b78a88bb92035b4a9.tar.lz
gpt4free-aba4b96f23ef38ca75195b3b78a88bb92035b4a9.tar.xz
gpt4free-aba4b96f23ef38ca75195b3b78a88bb92035b4a9.tar.zst
gpt4free-aba4b96f23ef38ca75195b3b78a88bb92035b4a9.zip
Diffstat (limited to '')
-rw-r--r--g4f/gui/client/js/chat.v1.js29
1 files changed, 10 insertions, 19 deletions
diff --git a/g4f/gui/client/js/chat.v1.js b/g4f/gui/client/js/chat.v1.js
index a243b1de..2042d174 100644
--- a/g4f/gui/client/js/chat.v1.js
+++ b/g4f/gui/client/js/chat.v1.js
@@ -52,6 +52,12 @@ const handle_ask = async () => {
}
await add_message(window.conversation_id, "user", message);
window.token = message_id();
+
+ if (imageInput.dataset.src) URL.revokeObjectURL(imageInput.dataset.src);
+ const input = imageInput && imageInput.files.length > 0 ? imageInput : cameraInput
+ if (input.files.length > 0) imageInput.dataset.src = URL.createObjectURL(input.files[0]);
+ else delete imageInput.dataset.src
+
message_box.innerHTML += `
<div class="message">
<div class="user">
@@ -64,10 +70,6 @@ const handle_ask = async () => {
? '<img src="' + imageInput.dataset.src + '" alt="Image upload">'
: ''
}
- ${cameraInput.dataset.src
- ? '<img src="' + cameraInput.dataset.src + '" alt="Image capture">'
- : ''
- }
</div>
</div>
`;
@@ -683,24 +685,13 @@ observer.observe(message_input, { attributes: true });
document.getElementById("version_text").innerHTML = text
})()
for (const el of [imageInput, cameraInput]) {
- console.log(el.files);
el.addEventListener('click', async () => {
el.value = '';
- delete el.dataset.src;
- });
- do_load = async () => {
- if (el.files.length) {
- delete imageInput.dataset.src;
- delete cameraInput.dataset.src;
- const reader = new FileReader();
- reader.addEventListener('load', (event) => {
- el.dataset.src = event.target.result;
- });
- reader.readAsDataURL(el.files[0]);
+ if (imageInput.dataset.src) {
+ URL.revokeObjectURL(imageInput.dataset.src);
+ delete imageInput.dataset.src
}
- }
- do_load()
- el.addEventListener('change', do_load);
+ });
}
fileInput.addEventListener('click', async (event) => {
fileInput.value = '';