Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -136,7 +136,7 @@ with gr.Blocks() as demo:
|
|
| 136 |
remove_timeline_button = gr.Button("ํ์๋ผ์ธ ์ ๊ฑฐ")
|
| 137 |
|
| 138 |
# ์ถ๋ ฅ์ฐฝ 3๊ฐ: ๊ฐ์1 ํ์๋ผ์ธ ์ ๊ฑฐ, ๊ฐ์2 ํ์๋ผ์ธ ์ ๊ฑฐ, ๊ฐ์3 ํ์๋ผ์ธ ์ ๊ฑฐ (๊ฐ๋ก๋ก ๋์ด)
|
| 139 |
-
# ๊ฐ Textbox์ elem_id๋ฅผ ๋ถ์ฌํ์ฌ JavaScript
|
| 140 |
with gr.Row():
|
| 141 |
cleaned1 = gr.Textbox(label="๊ฐ์1 ํ์๋ผ์ธ ์ ๊ฑฐ", lines=10, elem_id="cleaned1")
|
| 142 |
cleaned2 = gr.Textbox(label="๊ฐ์2 ํ์๋ผ์ธ ์ ๊ฑฐ", lines=10, elem_id="cleaned2")
|
|
@@ -172,28 +172,41 @@ with gr.Blocks() as demo:
|
|
| 172 |
# ํด๋ฆฝ๋ณด๋ ๋ณต์ฌ ๊ธฐ๋ฅ์ ์ํ JavaScript ์ฝ๋๋ฅผ ํฌํจํ๋ HTML ์ปดํฌ๋ํธ
|
| 173 |
custom_script = """
|
| 174 |
<script>
|
| 175 |
-
function setupClipboard(copyButtonId,
|
| 176 |
const copyButton = document.getElementById(copyButtonId);
|
| 177 |
-
if(copyButton){
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
if (text.trim() === "") {
|
| 184 |
-
|
| 185 |
} else {
|
| 186 |
navigator.clipboard.writeText(text).then(function() {
|
| 187 |
-
|
|
|
|
| 188 |
}, function(err) {
|
| 189 |
-
|
|
|
|
| 190 |
});
|
| 191 |
}
|
|
|
|
|
|
|
| 192 |
}
|
| 193 |
-
}
|
| 194 |
-
|
|
|
|
|
|
|
| 195 |
}
|
| 196 |
-
// DOMContentLoaded ์ดํ์ ์ด๋ฒคํธ ์ค์
|
| 197 |
document.addEventListener("DOMContentLoaded", function(){
|
| 198 |
setupClipboard("copy1", "cleaned1", "copy_result1");
|
| 199 |
setupClipboard("copy2", "cleaned2", "copy_result2");
|
|
|
|
| 136 |
remove_timeline_button = gr.Button("ํ์๋ผ์ธ ์ ๊ฑฐ")
|
| 137 |
|
| 138 |
# ์ถ๋ ฅ์ฐฝ 3๊ฐ: ๊ฐ์1 ํ์๋ผ์ธ ์ ๊ฑฐ, ๊ฐ์2 ํ์๋ผ์ธ ์ ๊ฑฐ, ๊ฐ์3 ํ์๋ผ์ธ ์ ๊ฑฐ (๊ฐ๋ก๋ก ๋์ด)
|
| 139 |
+
# ๊ฐ Textbox์ elem_id๋ฅผ ๋ถ์ฌํ์ฌ JavaScript์์ ์ ๊ทผํ ์ ์๊ฒ ํจ.
|
| 140 |
with gr.Row():
|
| 141 |
cleaned1 = gr.Textbox(label="๊ฐ์1 ํ์๋ผ์ธ ์ ๊ฑฐ", lines=10, elem_id="cleaned1")
|
| 142 |
cleaned2 = gr.Textbox(label="๊ฐ์2 ํ์๋ผ์ธ ์ ๊ฑฐ", lines=10, elem_id="cleaned2")
|
|
|
|
| 172 |
# ํด๋ฆฝ๋ณด๋ ๋ณต์ฌ ๊ธฐ๋ฅ์ ์ํ JavaScript ์ฝ๋๋ฅผ ํฌํจํ๋ HTML ์ปดํฌ๋ํธ
|
| 173 |
custom_script = """
|
| 174 |
<script>
|
| 175 |
+
function setupClipboard(copyButtonId, textContainerId, resultContainerId) {
|
| 176 |
const copyButton = document.getElementById(copyButtonId);
|
| 177 |
+
if (!copyButton) {
|
| 178 |
+
console.error("๋ฒํผ " + copyButtonId + "๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.");
|
| 179 |
+
return;
|
| 180 |
+
}
|
| 181 |
+
copyButton.addEventListener('click', function() {
|
| 182 |
+
console.log(copyButtonId + " ํด๋ฆญ๋จ");
|
| 183 |
+
// ํ
์คํธ๋ฐ์ค ์ปจํ
์ด๋ ๋ด๋ถ์ textarea ์์๋ฅผ ์ฐพ์
|
| 184 |
+
const textContainer = document.getElementById(textContainerId);
|
| 185 |
+
const resultContainer = document.getElementById(resultContainerId);
|
| 186 |
+
if (textContainer && resultContainer) {
|
| 187 |
+
const textarea = textContainer.querySelector("textarea");
|
| 188 |
+
const resultArea = resultContainer.querySelector("textarea");
|
| 189 |
+
if (textarea && resultArea) {
|
| 190 |
+
var text = textarea.value;
|
| 191 |
if (text.trim() === "") {
|
| 192 |
+
resultArea.value = "๋ณต์ฌํ ๋ด์ฉ์ด ์์ต๋๋ค.";
|
| 193 |
} else {
|
| 194 |
navigator.clipboard.writeText(text).then(function() {
|
| 195 |
+
console.log("ํด๋ฆฝ๋ณด๋์ ๋ณต์ฌ๋จ: " + text);
|
| 196 |
+
resultArea.value = "๋ณต์ฌ์๋ฃ";
|
| 197 |
}, function(err) {
|
| 198 |
+
console.error("๋ณต์ฌ ์คํจ: " + err);
|
| 199 |
+
resultArea.value = "๋ณต์ฌ ์คํจ";
|
| 200 |
});
|
| 201 |
}
|
| 202 |
+
} else {
|
| 203 |
+
console.error("textarea ์์๋ฅผ ์ฐพ์ง ๋ชปํ์ต๋๋ค.");
|
| 204 |
}
|
| 205 |
+
} else {
|
| 206 |
+
console.error("ํ
์คํธ ๋๋ ๊ฒฐ๊ณผ ์ปจํ
์ด๋๋ฅผ ์ฐพ์ง ๋ชปํ์ต๋๋ค.");
|
| 207 |
+
}
|
| 208 |
+
});
|
| 209 |
}
|
|
|
|
| 210 |
document.addEventListener("DOMContentLoaded", function(){
|
| 211 |
setupClipboard("copy1", "cleaned1", "copy_result1");
|
| 212 |
setupClipboard("copy2", "cleaned2", "copy_result2");
|