mrfakename commited on
Commit
95b1085
·
verified ·
1 Parent(s): 53dabb2

Update app/ui_vote.py

Browse files
Files changed (1) hide show
  1. app/ui_vote.py +26 -26
app/ui_vote.py CHANGED
@@ -83,31 +83,31 @@ with gr.Blocks() as vote:
83
  bbetter.click(b_is_better, outputs=nxt_outputs, inputs=[model1, model2, useridstate])
84
 
85
  # Add custom JS for keyboard shortcuts
86
- vote.load(None, None, js="""function() {
87
- document.addEventListener('keydown', function(e) {
88
- // Only handle shortcuts if we're on the vote tab
89
- if (!document.querySelector('#vote-a-button')?.offsetParent) {
90
- // Check if random button is visible
91
- if (document.querySelector('#vote-random-button')?.offsetParent) {
92
- if (e.key === 'r') {
93
- document.getElementById('vote-random-button')?.click();
94
- } else if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
95
- document.getElementById('vote-synth-button')?.click();
96
- }
97
- }
98
- return;
99
- }
100
 
101
- // Only handle A and B keys when not typing in an input
102
- if (document.activeElement.tagName === 'INPUT' ||
103
- document.activeElement.tagName === 'TEXTAREA') {
104
- return;
105
- }
106
 
107
- if (e.key.toLowerCase() === 'a') {
108
- document.getElementById('vote-a-button')?.click();
109
- } else if (e.key.toLowerCase() === 'b') {
110
- document.getElementById('vote-b-button')?.click();
111
- }
112
- });
113
- }""")
 
83
  bbetter.click(b_is_better, outputs=nxt_outputs, inputs=[model1, model2, useridstate])
84
 
85
  # Add custom JS for keyboard shortcuts
86
+ # vote.load(None, None, js="""function() {
87
+ # document.addEventListener('keydown', function(e) {
88
+ # // Only handle shortcuts if we're on the vote tab
89
+ # if (!document.querySelector('#vote-a-button')?.offsetParent) {
90
+ # // Check if random button is visible
91
+ # if (document.querySelector('#vote-random-button')?.offsetParent) {
92
+ # if (e.key === 'r') {
93
+ # document.getElementById('vote-random-button')?.click();
94
+ # } else if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
95
+ # document.getElementById('vote-synth-button')?.click();
96
+ # }
97
+ # }
98
+ # return;
99
+ # }
100
 
101
+ # // Only handle A and B keys when not typing in an input
102
+ # if (document.activeElement.tagName === 'INPUT' ||
103
+ # document.activeElement.tagName === 'TEXTAREA') {
104
+ # return;
105
+ # }
106
 
107
+ # if (e.key.toLowerCase() === 'a') {
108
+ # document.getElementById('vote-a-button')?.click();
109
+ # } else if (e.key.toLowerCase() === 'b') {
110
+ # document.getElementById('vote-b-button')?.click();
111
+ # }
112
+ # });
113
+ # }""")