-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
250 lines (195 loc) · 9.25 KB
/
test.html
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<style>
#accordion h4{
background-color: #FAFAFA;
border: 1px solid grey;
border-radius: 5px 5px 5px 5px;
font: 18px georgia,arial;
padding: 5px;
cursor: pointer;
}
#accordion div{
background-color: #fcfcfc;
border: 0.5px solid grey;
border-radius: 5px 5px 5px 5px;
display: block;
font: italic 17px monotype;
}
li{
padding: 10px 0;
}
</style>
</head>
<body style="font-size:62.5%;">
<div id="search">
<input id="txtTerm" type="text" value="pmp22" />
<select id="drpDatabase" disabled="disabled" >
<option value="select">Select Database</option>
<option value="/sites/gquery">All Databases</option>
<option value="pubmed" selected="selected">PubMed</option>
<option value="/protein">Protein</option>
<option value="/nuccore">Nucleotide</option>
<option value="/nucgss">GSS</option>
<option value="/nucest">EST</option>
<option value="/structure">Structure</option>
<option value="/genome">Genome</option>
<option value="/assembly">Assembly</option>
<option value="/bioproject">BioProject</option>
<option value="/biosample">BioSample</option>
<option value="/biosystems">BioSystems</option>
<option value="/books">Books</option>
<option value="/cdd">Conserved Domains</option>
<option value="/clone">Clone</option>
<option value="/gap">dbGaP</option>
<option value="/dbvar">dbVar</option>
<option value="/epigenomics">Epigenomics</option>
<option value="/gene">Gene</option>
<option value="/gds">GEO DataSets</option>
<option value="/geoprofiles">GEO Profiles</option>
<option value="/homologene">HomoloGene</option>
<option value="/mesh">MeSH</option>
<option value="/ncbisearch">NCBI Web Site</option>
<option value="/nlmcatalog">NLM Catalog</option>
<option value="/omia">OMIA</option>
<option value="/omim">OMIM</option>
<option value="/pmc">PMC</option>
<option value="/popset">PopSet</option>
<option value="/probe">Probe</option>
<option value="/proteinclusters">Protein Clusters</option>
<option value="/pcassay">PubChem BioAssay</option>
<option value="/pccompound">PubChem Compound</option>
<option value="/pcsubstance">PubChem Substance</option>
<option value="/pubmedhealth">PubMed Health</option>
<option value="/snp">SNP</option>
<option value="/sra">SRA</option>
<option value="/taxonomy">Taxonomy</option>
<option value="/toolkit">ToolKit</option>
<option value="/toolkitall">ToolKitAll</option>
<option value="/unigene">UniGene</option>
<option value="/unists">UniSTS</option>
</select>
<input id="btnSearch" type="button" value="button" />
</div>
<div id="accordion">
</div>
</body>
</html>
<script type="text/javascript">
// This will search all Article Ids in Databse
$("#btnSearch").click(function () {
$('#accordion').empty();
var term = $("#txtTerm").val();
var database = $("#drpDatabase").val();
var listUrl = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=" + database + "&term=" + term + "&datetype=edat&usehistory=y";
$.get(listUrl, function (listXml) {
lDocElt = listXml.documentElement;
var articleCountArray = lDocElt.getElementsByTagName("Count");
var articleCount = articleCountArray[0].textContent;
var QueryKeyArray = lDocElt.getElementsByTagName("QueryKey");
var QueryKey = QueryKeyArray[0].textContent;
var WebEnvArray = lDocElt.getElementsByTagName("WebEnv");
var WebEnv = WebEnvArray[0].textContent;
retmax = 10; // number of records to return per loop
var fetchUrl = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=' + database + '&query_key=' + QueryKey + '&WebEnv=' + WebEnv + '&retstart=0&retmax=10&retmode=xml';
$.get(fetchUrl, function (detailXml) {
var ArticleSet = detailXml.documentElement; // root Element
PubmedArticles = ArticleSet.getElementsByTagName('PubmedArticle');
// looping through PubmedArticle
for (pubmedCount = 0; pubmedCount < PubmedArticles.length; pubmedCount++) {
var articleChildren = PubmedArticles[pubmedCount].childNodes;
//looping through pubmedArticles Children
for(pmchildCounter = 0; pmchildCounter < articleChildren.length; pmchildCounter++){
// if its an element node, go for its child nodes
if(PubmedArticles[pubmedCount].childNodes[pmchildCounter].nodeType == 1){
var vPubmedChildNode = PubmedArticles[pubmedCount].childNodes[pmchildCounter];
switch(vPubmedChildNode.nodeName)
{
case 'MedlineCitation':
var mcChildren = vPubmedChildNode.childNodes;
mcChildCounter = 1;
while(mcChildCounter < mcChildren.length){
if(mcChildren[mcChildCounter].nodeName == 'Article'){
ArticleChildCounter = 1;
var pArticleTitle = pAbstract = pAuthorList = '';
while(ArticleChildCounter < mcChildren[mcChildCounter].childNodes.length){
//alert(mcChildren[mcChildCounter].childNodes[ArticleChildCounter].nodeName);
switch(mcChildren[mcChildCounter].childNodes[ArticleChildCounter].nodeName){
case 'ArticleTitle':
// get nodeValue
pArticleTitle = '<h4>'+mcChildren[mcChildCounter].childNodes[ArticleChildCounter].textContent+'</h4>';
break;
case 'Abstract':
var Abstract = mcChildren[mcChildCounter].childNodes[ArticleChildCounter];
var AbstractChildCounter = 1;
//loop for AbstractText
//pAbstract = '<p><ul>';
while(AbstractChildCounter < Abstract.childNodes.length){
pAbstract = pAbstract+ '<li>'+Abstract.childNodes[AbstractChildCounter].textContent+'</li>';
AbstractChildCounter = AbstractChildCounter+2;
}
pAbstract = '<div><ul>'+ pAbstract + '</ul></div>';
break;
case 'AuthorList':
// loop for Author
break;
}
ArticleChildCounter = ArticleChildCounter+2;
}
}
//mcChildCounter++;
mcChildCounter = mcChildCounter+2;
}
break;
case 'PubmedData':
break;
}
}
}
$('#accordion').append(pArticleTitle+pAbstract);
}
$("#accordion > :header").click(function() {
$(this).next('div').toggle('very slow');
return false;
}).next('div').hide();
//we need a loop to fetch "retmax" records per hit, till we reach maxNode Count, for now ignoring it !!
//while()
//{
// innerLoopCounter = 0;
//
// var ArticleTitleArray = dDocElt.getElementsByTagName("ArticleTitle");
//
// // getting all abstract text in seperate <p>
// var AbstractTextArray = dDocElt.getElementsByTagName("AbstractText");
//
//
//
// while(innerLoopCounter < retmax)
// {
// content = '<h4>' + ArticleTitleArray[innerLoopCounter].textContent + '</h4><div><p>asdasd asdasd assad asdasd asdasd asdasd </p></div>';
// $('#accordion').append(content);
// innerLoopCounter++;
// }
//
// //retstart = loopCounter; // records start from
// //loopCounter = loopCounter + retmax;
// //} // while end
//
// //comment
// $("#accordion > :header").click(function() {
// $(this).next().toggle('slow');
// return false;
// }).next().hide();
//
// //comment
//
//
}); // inner get end
});
});
</script>