summaryrefslogtreecommitdiffstats
path: root/g4f/gui
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-01-29 18:14:46 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-01-29 18:14:46 +0100
commita28bab938704a15c825c1b45a8983c72e8c90ace (patch)
tree0a3ee26bb1f9e7bf7c1a5a739ed59015248acbfb /g4f/gui
parentMerge pull request #1523 from u66u/which-webdriver (diff)
downloadgpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar
gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar.gz
gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar.bz2
gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar.lz
gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar.xz
gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar.zst
gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.zip
Diffstat (limited to '')
-rw-r--r--g4f/gui/client/js/chat.v1.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/g4f/gui/client/js/chat.v1.js b/g4f/gui/client/js/chat.v1.js
index 99a75569..86eef8c9 100644
--- a/g4f/gui/client/js/chat.v1.js
+++ b/g4f/gui/client/js/chat.v1.js
@@ -59,6 +59,10 @@ const handle_ask = async () => {
</div>
<div class="content" id="user_${token}">
${markdown_render(message)}
+ ${imageInput.dataset.src
+ ? '<img src="' + imageInput.dataset.src + '" alt="Image upload">'
+ : ''
+ }
</div>
</div>
`;
@@ -666,6 +670,18 @@ observer.observe(message_input, { attributes: true });
})()
imageInput.addEventListener('click', async (event) => {
imageInput.value = '';
+ delete imageInput.dataset.src;
+});
+imageInput.addEventListener('change', async (event) => {
+ if (imageInput.files.length) {
+ const reader = new FileReader();
+ reader.addEventListener('load', (event) => {
+ imageInput.dataset.src = event.target.result;
+ });
+ reader.readAsDataURL(imageInput.files[0]);
+ } else {
+ delete imageInput.dataset.src;
+ }
});
fileInput.addEventListener('click', async (event) => {
fileInput.value = '';