Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -180,9 +180,9 @@ def create_arena_interface():
|
|
| 180 |
left_button = gr.Button("👈 Left video looks better", size="lg")
|
| 181 |
right_button = gr.Button("Right video looks better ", size="lg")
|
| 182 |
|
| 183 |
-
# Replace the old passkey section with a hidden keyboard
|
| 184 |
with gr.Row(visible=False) as secret_row:
|
| 185 |
-
keyboard_status = gr.Textbox(value="", label="Status", interactive=
|
| 186 |
|
| 187 |
# Simplified tab structure - just the rankings tab (hidden by default)
|
| 188 |
rankings_tab = gr.Tab("Current Rankings", visible=False)
|
|
@@ -258,27 +258,27 @@ def create_arena_interface():
|
|
| 258 |
fn=reset_data, inputs=[], outputs=[reset_warning, reset_confirm, reset_button, rankings_table]
|
| 259 |
)
|
| 260 |
|
| 261 |
-
def check_secret_sequence(
|
| 262 |
-
"""Check if the
|
| 263 |
# Get passkey from environment variable
|
| 264 |
correct_passkey = os.environ.get("PASSKEY", "").lower()
|
| 265 |
|
| 266 |
-
# Track the sequence in the component's value
|
| 267 |
-
current_sequence = keyboard_status.value + evt.key.lower()
|
| 268 |
# Keep only the last N characters where N is the length of the passkey
|
| 269 |
-
current_sequence =
|
| 270 |
|
| 271 |
is_visible = current_sequence == correct_passkey
|
| 272 |
return {
|
| 273 |
-
keyboard_status: current_sequence,
|
| 274 |
download_section: gr.Row(visible=is_visible),
|
| 275 |
download_output: gr.File(visible=is_visible),
|
| 276 |
rankings_tab: gr.Tab(visible=is_visible),
|
| 277 |
}
|
| 278 |
|
| 279 |
-
# Add
|
| 280 |
-
|
| 281 |
-
|
|
|
|
|
|
|
|
|
|
| 282 |
|
| 283 |
def load_new_comparison():
|
| 284 |
"""Load a new random comparison."""
|
|
|
|
| 180 |
left_button = gr.Button("👈 Left video looks better", size="lg")
|
| 181 |
right_button = gr.Button("Right video looks better ", size="lg")
|
| 182 |
|
| 183 |
+
# Replace the old passkey section with a hidden keyboard tracker
|
| 184 |
with gr.Row(visible=False) as secret_row:
|
| 185 |
+
keyboard_status = gr.Textbox(value="", label="Status", interactive=True)
|
| 186 |
|
| 187 |
# Simplified tab structure - just the rankings tab (hidden by default)
|
| 188 |
rankings_tab = gr.Tab("Current Rankings", visible=False)
|
|
|
|
| 258 |
fn=reset_data, inputs=[], outputs=[reset_warning, reset_confirm, reset_button, rankings_table]
|
| 259 |
)
|
| 260 |
|
| 261 |
+
def check_secret_sequence(text: str) -> Dict:
|
| 262 |
+
"""Check if the typed text matches the secret sequence."""
|
| 263 |
# Get passkey from environment variable
|
| 264 |
correct_passkey = os.environ.get("PASSKEY", "").lower()
|
| 265 |
|
|
|
|
|
|
|
| 266 |
# Keep only the last N characters where N is the length of the passkey
|
| 267 |
+
current_sequence = text.lower()[-len(correct_passkey):]
|
| 268 |
|
| 269 |
is_visible = current_sequence == correct_passkey
|
| 270 |
return {
|
|
|
|
| 271 |
download_section: gr.Row(visible=is_visible),
|
| 272 |
download_output: gr.File(visible=is_visible),
|
| 273 |
rankings_tab: gr.Tab(visible=is_visible),
|
| 274 |
}
|
| 275 |
|
| 276 |
+
# Add change handler for the keyboard status
|
| 277 |
+
keyboard_status.change(
|
| 278 |
+
fn=check_secret_sequence,
|
| 279 |
+
inputs=[keyboard_status],
|
| 280 |
+
outputs=[download_section, download_output, rankings_tab],
|
| 281 |
+
)
|
| 282 |
|
| 283 |
def load_new_comparison():
|
| 284 |
"""Load a new random comparison."""
|