hallisky commited on
Commit
e511669
1 Parent(s): 48c598c

Confirmation fades out

Browse files
Files changed (2) hide show
  1. app.py +2 -8
  2. utils.py +23 -0
app.py CHANGED
@@ -10,6 +10,7 @@ from uuid import uuid4
10
  import os
11
  from pathlib import Path
12
  from huggingface_hub import CommitScheduler
 
13
 
14
  # TODO make it so that feedback is only saved on prev. example if user makes another obfuscation
15
  # and changes slider but doesn't hit obfuscate
@@ -244,6 +245,7 @@ demo = gr.Blocks()
244
  with demo:
245
  latest_obfuscation = gr.State({})
246
  gr.Markdown(DESCRIPTION)
 
247
  with gr.Row():
248
  with gr.Column(variant="panel"):
249
  gr.Markdown("# 1) Input Text\n### Enter the text to be obfuscated.")
@@ -354,14 +356,6 @@ with demo:
354
  outputs=[feedback_rating, feedback_text, confirmation_message]
355
  )
356
 
357
- hide_code = """
358
- () => {
359
- document.getElementById('confirmation-message').style.display = 'block';
360
- setTimeout(() => {
361
- document.getElementById('confirmation-message').style.display = 'none';
362
- }, 5000);
363
- }
364
- """ # Hides the message after 5 seconds
365
  save_feedback_button.click(
366
  fn=None,
367
  inputs=[],
 
10
  import os
11
  from pathlib import Path
12
  from huggingface_hub import CommitScheduler
13
+ from utils import hide_code, hide_css
14
 
15
  # TODO make it so that feedback is only saved on prev. example if user makes another obfuscation
16
  # and changes slider but doesn't hit obfuscate
 
245
  with demo:
246
  latest_obfuscation = gr.State({})
247
  gr.Markdown(DESCRIPTION)
248
+ gr.HTML(hide_css)
249
  with gr.Row():
250
  with gr.Column(variant="panel"):
251
  gr.Markdown("# 1) Input Text\n### Enter the text to be obfuscated.")
 
356
  outputs=[feedback_rating, feedback_text, confirmation_message]
357
  )
358
 
 
 
 
 
 
 
 
 
359
  save_feedback_button.click(
360
  fn=None,
361
  inputs=[],
utils.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ hide_code = """
2
+ () => {
3
+ const confirmationMessage = document.getElementById('confirmation-message');
4
+ confirmationMessage.style.display = 'block';
5
+ confirmationMessage.style.opacity = 1;
6
+ setTimeout(() => {
7
+ confirmationMessage.style.transition = 'opacity 8s';
8
+ confirmationMessage.style.opacity = 0;
9
+ }, 1000);
10
+ setTimeout(() => {
11
+ confirmationMessage.style.display = 'none';
12
+ }, 9200); // 2000ms for transition
13
+ }
14
+ """
15
+
16
+ # Add CSS for the fade-out effect
17
+ hide_css = """
18
+ <style>
19
+ #confirmation-message {
20
+ opacity: 1;
21
+ }
22
+ </style>
23
+ """