返回提交历史
Modified
g4f/gui/client/static/js/chat.v1.js
+9
-15
XFEstudio/gpt4free
Clean up chat.v1.js
6bf6c5e5
代码差异
1 个文件
+9
-15
@@ -57,10 +57,9 @@ function filter_message(text) {
57
57
)
58
58
}
59
59
60
function fallback_copy (text) {
61
console.warn("Entering fallback_copy...")
60
function fallback_clipboard (text) {
62
61
var textBox = document.createElement("textarea");
63
textBox.value = text; // Avoid scrolling to bottom
62
textBox.value = text;
64
63
textBox.style.top = "0";
65
64
textBox.style.left = "0";
66
65
textBox.style.position = "fixed";
@@ -70,12 +69,11 @@ function fallback_copy (text) {
70
69
try {
71
70
var success = document.execCommand('copy');
72
71
var msg = success ? 'succeeded' : 'failed';
73
console.log('Fallback: Copying text command ' + msg);
74
} catch (err) {
75
console.error('Fallback: Unable to copy', err);
76
};
72
console.log('Clipboard Fallback: Copying text command ' + msg);
73
} catch (e) {
74
console.error('Clipboard Fallback: Unable to copy', e);
75
}
77
76
document.body.removeChild(textBox);
78
79
77
}
80
78
81
79
hljs.addPlugin(new CopyButtonPlugin());
@@ -118,14 +116,12 @@ const register_message_buttons = async () => {
118
116
const copyText = await get_message(window.conversation_id, message_el.dataset.index);
119
117
120
118
try {
121
console.warn("copyText type: ", typeof copyText)
122
console.warn("Current Text: " + copyText);
123
119
await navigator.clipboard.writeText(copyText);
124
120
} catch (e) {
125
console.error("Clipboard API failed!")
126
121
console.error(e);
127
fallback_copy(copyText);
128
};
122
console.error("Clipboard API failed! Fallback to document.exec("copy")...");
123
fallback_clipboard(copyText);
124
}
129
125
130
126
el.classList.add("clicked");
131
127
setTimeout(() => el.classList.remove("clicked"), 1000);
@@ -133,8 +129,6 @@ const register_message_buttons = async () => {
133
129
}
134
130
});
135
131
136
137
138
132
document.querySelectorAll(".message .fa-volume-high").forEach(async (el) => {
139
133
if (!("click" in el.dataset)) {
140
134
el.dataset.click = "true";