Spaces:
Sleeping
Sleeping
Merge pull request #2 from ZnS77/feature/customizedDisable
Browse files- app.py +4 -3
- html_codes.py +21 -8
app.py
CHANGED
|
@@ -186,9 +186,9 @@ if __name__ == "__main__":
|
|
| 186 |
open=False):
|
| 187 |
gr.Markdown(SDG_DETAILS)
|
| 188 |
# initialization of different group contents
|
| 189 |
-
group_a_content = gr.Group(visible=False)
|
| 190 |
-
group_b_content = gr.Group(visible=False)
|
| 191 |
-
group_c_content = gr.Group(visible=False)
|
| 192 |
|
| 193 |
|
| 194 |
|
|
@@ -252,6 +252,7 @@ if __name__ == "__main__":
|
|
| 252 |
|
| 253 |
|
| 254 |
with group_b_content:
|
|
|
|
| 255 |
with gr.Row():
|
| 256 |
create_initial_btn = gr.Button("Create")
|
| 257 |
with gr.Row():
|
|
|
|
| 186 |
open=False):
|
| 187 |
gr.Markdown(SDG_DETAILS)
|
| 188 |
# initialization of different group contents
|
| 189 |
+
group_a_content = gr.Group(visible=False, elem_id="group-a")
|
| 190 |
+
group_b_content = gr.Group(visible=False, elem_id="group-b")
|
| 191 |
+
group_c_content = gr.Group(visible=False, elem_id="group-c")
|
| 192 |
|
| 193 |
|
| 194 |
|
|
|
|
| 252 |
|
| 253 |
|
| 254 |
with group_b_content:
|
| 255 |
+
# gr.HTML("<p>Group B Content</p>")
|
| 256 |
with gr.Row():
|
| 257 |
create_initial_btn = gr.Button("Create")
|
| 258 |
with gr.Row():
|
html_codes.py
CHANGED
|
@@ -1,17 +1,30 @@
|
|
| 1 |
no_copy_paste_js = """
|
| 2 |
function disableCopyPaste() {
|
| 3 |
-
//
|
| 4 |
-
document.addEventListener(
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
});
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
});
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
}
|
| 16 |
"""
|
| 17 |
|
|
|
|
| 1 |
no_copy_paste_js = """
|
| 2 |
function disableCopyPaste() {
|
| 3 |
+
// Disable copy-paste globally
|
| 4 |
+
document.addEventListener("copy", function (e) {
|
| 5 |
+
const target = e.target.closest("#group-b");
|
| 6 |
+
console.log("Copy event target:", e.target, "Closest group-b:", target);
|
| 7 |
+
if (!target) {
|
| 8 |
+
e.preventDefault();
|
| 9 |
+
alert("Copy is disabled");
|
| 10 |
+
}
|
| 11 |
});
|
| 12 |
|
| 13 |
+
document.addEventListener("cut", function (e) {
|
| 14 |
+
const target = e.target.closest("#group-b");
|
| 15 |
+
if (!target) {
|
| 16 |
+
e.preventDefault();
|
| 17 |
+
alert("Cut is disabled");
|
| 18 |
+
}
|
| 19 |
});
|
| 20 |
|
| 21 |
+
document.addEventListener("paste", function (e) {
|
| 22 |
+
const target = e.target.closest("#group-b");
|
| 23 |
+
if (!target) {
|
| 24 |
+
e.preventDefault();
|
| 25 |
+
alert("Paste is disabled");
|
| 26 |
+
}
|
| 27 |
+
});
|
| 28 |
}
|
| 29 |
"""
|
| 30 |
|