1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
<link rel="stylesheet" href="/static/new/css/autocomplete.css" />
<style TYPE="text/css">
.global_search_input{
padding:9px 8px;
text-decoration: none;
border: none;
border-radius: 5px;
}
.global_search_input:focus{
outline: none;
}
.btn-stc {
padding:9px 8px;
border-left:none;
border-radius:0 40px 40px 0;
cursor: pointer;
height: 40px;
width: 64px;
margin:0;
border:1px solid #d3d3d3;
background-color: white;
position: absolute;
top:0;
left: 100%;
right: 0;
border-left: none;
}
.clear-input-button:hover{
cursor: pointer
}
.clear-input-button {
position:absolute;
right:10px;
top:12px;
color:#336699;
display:none
}
.clear-input--touched:focus + .clear-input-button, .clear-input--touched:hover + .clear-input-button, .clear-input--touched + .clear-input-button:hover {
display: inline-flex;
}
</style>
<div class="container-fluid"
style="width: 100%;
min-width: 650px;
position: relative;
background-color: #d5d5d5;
height: 100px">
<form method="get" action="/gsearch" id="globalsearchform">
<div class="form-group">
<div class="controls">
<select name="type">
<option value="gene">Genes / Molecules</option>
<option value="phenotype" {% if type=="phenotype" %}selected{% endif %}>Phenotypes</option>
</select>
<div class="col-8 autocomplete"
style="margin-left: 30px;
margin-right: 10px;
position:relative">
<input autocomplete="off"
class="global_search_input clear-input"
id="term"
style="width:45vw"
type="text"
required
placeholder="Enter you search term here (ex: cytochrome AND P450)"
style="position:relative"
name="terms">
<span style="" title="Clear" class="glyphicon glyphicon-remove clear-input-button"></span>
<button type="submit"
class="btn-stc "
style="position: absolute;
background-color: #336699">
<font style="color:white;">Search</font>
</button>
</div>
<span style="margin-left: 60px;">
<a style=""
target="_blank"
title="See more Search Xapian Hints"
href="https://issues.genenetwork.org/topics/xapian/xapian-search-queries">
<sup>
<i><b >See more Hints </b></i>
</sup>
</a>
</span>
<span style="padding: 5px;margin-left: 60px;" id="gnqna_home">
<a href="/gnqna"><b>GNQA Search</b></a>
</span>
</div>
</div>
</form>
</div>
<script src="{{ url_for('js', filename='jquery/jquery.min.js') }}"
type="text/javascript"></script>
<script src="/static/new/javascript/search_autocomplete.js"></script>
<script type="text/javascript">
$(document).ready(function() {
const urlParams = new URLSearchParams(window.location.search)
let term = urlParams.get("terms")
//should web scrap
var global_search_hint = [
"cytochrome",
"cytochrome AND P450",
"cytochrome NEAR P450",
"cytochrome -P450",
"cytochrome NOT P450",
"species:human",
"group:BXD",
"Hs:chr4:9930021 species:mouse",
"Hs:chr4:9130000..9980000 species:mouse",
"mean:5..7",
"mean:7..",
"Hs:chr4:9930021",
"Hs:chr4:9930021 species:mouse",
"Hs:chr4:9130000..9980000 species:mouse",
"bx*",
"*"
]
autocomplete(document.getElementById("term"), global_search_hint);
$("#term").keyup(function(event) {
if (event.keyCode === 13) {
event.preventDefault();
$('#globalsearchform').attr('action', "/gsearch").submit();
if ($("#term").val().trim() != "") {
saveBeforeSubmit($("#term").val().trim())
$("#globalsearchform")[0].submit();
}
}
})
});
const input = document.querySelector(".clear-input");
const clearButton = document.querySelector(".clear-input-button");
const handleInputChange = e => {
if (e.target.value && !input.classList.contains("clear-input--touched")) {
input.classList.add("clear-input--touched");
} else if (!e.target.value && input.classList.contains("clear-input--touched")) {
input.classList.remove("clear-input--touched");
}
};
const handleButtonClick = e => {
console.log("clicked this button")
input.value = '';
input.focus();
input.classList.remove("clear-input--touched");
};
clearButton.addEventListener("click", handleButtonClick);
input.addEventListener("input", handleInputChange);
</script>
|