1
1
var generate_button = document . getElementById ( "Generate" ) ;
2
2
generate_button . insertAdjacentHTML ( "afterend" , '<div style="position:relative;"> <label style="color:#9ca3af;white-space:nowrap;position:absolute;right:0px;"><input type="checkbox" id="force-search" name="accept"> Force web search </label> </div>' ) ;
3
- generate_button . style . setProperty ( "position" , "relative" ) ;
4
- generate_button . style . setProperty ( "top" , "10px" ) ;
5
- generate_button . style . setProperty ( "margin-left" , "-10px" ) ;
6
3
7
4
var stop_button = document . getElementById ( "stop" ) ;
8
- stop_button . style . setProperty ( "position" , "relative" ) ;
9
- stop_button . style . setProperty ( "top" , "10px" ) ;
10
- stop_button . style . setProperty ( "margin-left" , "-10px" ) ;
11
-
12
5
var chat_input = document . getElementById ( "chat-input" ) ;
13
- chat_input . style . marginBottom = "5px" ;
14
6
15
- var checkbox = document . getElementById ( "force-search" ) ;
7
+ function set_margins ( generate_button , stop_button , chat_input , reset = false ) {
8
+ if ( reset ) {
9
+ generate_button . style . setProperty ( "position" , "" ) ;
10
+ generate_button . style . setProperty ( "top" , "" ) ;
11
+ generate_button . style . setProperty ( "margin-left" , "" ) ;
12
+
13
+ stop_button . style . setProperty ( "position" , "" ) ;
14
+ stop_button . style . setProperty ( "top" , "" ) ;
15
+ stop_button . style . setProperty ( "margin-left" , "" ) ;
16
+
17
+ chat_input . style . marginBottom = "" ;
18
+ }
19
+ else {
20
+ generate_button . style . setProperty ( "position" , "relative" ) ;
21
+ generate_button . style . setProperty ( "top" , "10px" ) ;
22
+ generate_button . style . setProperty ( "margin-left" , "-10px" ) ;
23
+
24
+ stop_button . style . setProperty ( "position" , "relative" ) ;
25
+ stop_button . style . setProperty ( "top" , "10px" ) ;
26
+ stop_button . style . setProperty ( "margin-left" , "-10px" ) ;
27
+
28
+ chat_input . style . marginBottom = "5px" ;
29
+ }
30
+ }
31
+ set_margins ( generate_button , stop_button , chat_input ) ;
32
+
33
+ var force_search_checkbox = document . getElementById ( "force-search" ) ;
16
34
var gradio_force_search_checkbox = document . getElementById ( "Force-search-checkbox" ) . children [ 1 ] . firstChild ;
17
- checkbox . addEventListener ( 'change' , function ( ) {
35
+ force_search_checkbox . addEventListener ( 'change' , function ( ) {
18
36
if ( this . checked ) {
19
37
if ( ! gradio_force_search_checkbox . checked ) {
20
38
gradio_force_search_checkbox . click ( ) ;
@@ -24,4 +42,18 @@ checkbox.addEventListener('change', function() {
24
42
gradio_force_search_checkbox . click ( ) ;
25
43
}
26
44
}
27
- } ) ;
45
+ } ) ;
46
+
47
+ var gradio_show_force_search_box = document . getElementById ( "show-force-search-box" ) . children [ 1 ] . firstChild ;
48
+ gradio_show_force_search_box . addEventListener ( 'change' , function ( ) {
49
+ if ( this . checked ) {
50
+ force_search_checkbox . parentElement . parentElement . style . display = '' ;
51
+ set_margins ( generate_button , stop_button , chat_input ) ;
52
+ } else {
53
+ force_search_checkbox . parentElement . parentElement . style . display = 'none' ;
54
+ set_margins ( generate_button , stop_button , chat_input , true ) ;
55
+ }
56
+ } ) ;
57
+
58
+ const event = new Event ( "change" ) ;
59
+ gradio_show_force_search_box . dispatchEvent ( event ) ;
0 commit comments