summaryrefslogtreecommitdiffstats
path: root/g4f
diff options
context:
space:
mode:
authorfoxfire52 <foxfire52@virgilio.it>2024-10-26 12:29:58 +0200
committerGitHub <noreply@github.com>2024-10-26 12:29:58 +0200
commit6bf6c5e5e97633050b0bdf61f0c4730b40c08851 (patch)
treea8883fe7fdb4e74d6b3a2f41ea30966ed90c5092 /g4f
parentPatch version.py (diff)
downloadgpt4free-6bf6c5e5e97633050b0bdf61f0c4730b40c08851.tar
gpt4free-6bf6c5e5e97633050b0bdf61f0c4730b40c08851.tar.gz
gpt4free-6bf6c5e5e97633050b0bdf61f0c4730b40c08851.tar.bz2
gpt4free-6bf6c5e5e97633050b0bdf61f0c4730b40c08851.tar.lz
gpt4free-6bf6c5e5e97633050b0bdf61f0c4730b40c08851.tar.xz
gpt4free-6bf6c5e5e97633050b0bdf61f0c4730b40c08851.tar.zst
gpt4free-6bf6c5e5e97633050b0bdf61f0c4730b40c08851.zip
Diffstat (limited to 'g4f')
-rw-r--r--g4f/gui/client/static/js/chat.v1.js24
1 files changed, 9 insertions, 15 deletions
diff --git a/g4f/gui/client/static/js/chat.v1.js b/g4f/gui/client/static/js/chat.v1.js
index 5309a04d..2777e79a 100644
--- a/g4f/gui/client/static/js/chat.v1.js
+++ b/g4f/gui/client/static/js/chat.v1.js
@@ -57,10 +57,9 @@ function filter_message(text) {
)
}
-function fallback_copy (text) {
- console.warn("Entering fallback_copy...")
+function fallback_clipboard (text) {
var textBox = document.createElement("textarea");
- textBox.value = text; // Avoid scrolling to bottom
+ textBox.value = text;
textBox.style.top = "0";
textBox.style.left = "0";
textBox.style.position = "fixed";
@@ -70,12 +69,11 @@ function fallback_copy (text) {
try {
var success = document.execCommand('copy');
var msg = success ? 'succeeded' : 'failed';
- console.log('Fallback: Copying text command ' + msg);
- } catch (err) {
- console.error('Fallback: Unable to copy', err);
- };
+ console.log('Clipboard Fallback: Copying text command ' + msg);
+ } catch (e) {
+ console.error('Clipboard Fallback: Unable to copy', e);
+ }
document.body.removeChild(textBox);
-
}
hljs.addPlugin(new CopyButtonPlugin());
@@ -118,14 +116,12 @@ const register_message_buttons = async () => {
const copyText = await get_message(window.conversation_id, message_el.dataset.index);
try {
- console.warn("copyText type: ", typeof copyText)
- console.warn("Current Text: " + copyText);
await navigator.clipboard.writeText(copyText);
} catch (e) {
- console.error("Clipboard API failed!")
console.error(e);
- fallback_copy(copyText);
- };
+ console.error("Clipboard API failed! Fallback to document.exec("copy")...");
+ fallback_clipboard(copyText);
+ }
el.classList.add("clicked");
setTimeout(() => el.classList.remove("clicked"), 1000);
@@ -133,8 +129,6 @@ const register_message_buttons = async () => {
}
});
-
-
document.querySelectorAll(".message .fa-volume-high").forEach(async (el) => {
if (!("click" in el.dataset)) {
el.dataset.click = "true";