summaryrefslogtreecommitdiffstats
path: root/g4f/gui
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-02-12 12:08:26 +0100
committerGitHub <noreply@github.com>2024-02-12 12:08:26 +0100
commitdd5478636460560bd6538c6b08a81c92d61b6595 (patch)
tree128a4681385f6f1adc8bee8cf745affc0103d204 /g4f/gui
parentMerge pull request #1577 from hlohaus/openai (diff)
parentAdd variant example (diff)
downloadgpt4free-dd5478636460560bd6538c6b08a81c92d61b6595.tar
gpt4free-dd5478636460560bd6538c6b08a81c92d61b6595.tar.gz
gpt4free-dd5478636460560bd6538c6b08a81c92d61b6595.tar.bz2
gpt4free-dd5478636460560bd6538c6b08a81c92d61b6595.tar.lz
gpt4free-dd5478636460560bd6538c6b08a81c92d61b6595.tar.xz
gpt4free-dd5478636460560bd6538c6b08a81c92d61b6595.tar.zst
gpt4free-dd5478636460560bd6538c6b08a81c92d61b6595.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 = '';