comparison Blast output page example trimmed_files/blast.js @ 1:ffe82516a83c

add trimmed down html example
author Jan Kanis <jan.code@jankanis.nl>
date Tue, 06 May 2014 17:36:10 +0200
parents
children
comparison
equal deleted inserted replaced
0:bad241dc701f 1:ffe82516a83c
1
2 function printfire()
3 {
4 // Firefox
5 if (document.createEvent && window.dispatchEvent) {
6 printfire.args = arguments;
7 var ev = document.createEvent("Events");
8 ev.initEvent("printfire", false, true);
9 window.dispatchEvent(ev);
10 }
11 }
12 //This functions handle setting defaults for protein or nulcleotide suite search page when
13 //one of blast program radio buttons is clicked - not used now
14 function AdjustMoreOptionsStyle()
15 {
16 var optsEl = document.getElementById("moreopts");
17 if(optsEl && optsEl.style.height != "0px") {
18 optsEl.style.height = optsEl.scrollHeight + "px";
19 }
20 }
21
22 //Strip (taxid:XXX) from organism list selection
23 //sgRunFunc="AdjustOrganism();"
24 function AdjustOrganism()
25 {
26 var words = $("qorganism").value.split(" (taxid");
27 $("qorganism").value = words[0];
28 }
29
30
31 /* JS Common to all BLAST pages */
32
33
34 function setResultsTarget()
35 {
36 //var newWin = $("newwin");
37 var newWin = this;
38 var searchFrm = $(newWin.getAttribute("form"));
39 if(newWin && newWin.checked == true) {
40 if(newWin.getAttribute("winType") == "random") {
41 searchFrm.target = "Blast_Results_for_" + Math.floor(Math.pow(10,10) *Math.random());
42 }
43 else {
44 searchFrm.target = $("resPageTarget").value;
45 }
46 }
47 else {
48 searchFrm.target = "";
49 }
50 }
51
52 function diffFromDefault(elem)
53 {
54 var currentVal = "";
55 var ret = 0;
56
57 if (!(elem)) return;
58 var defVal = elem.getAttribute("defVal"); //Default value
59 var elShowDiff = utils.getParent(elem);
60 if(!elem.type) {//div element for example
61 //Check if parent elem has "hide" class
62 if(utils.hasClass(utils.getParent(elem), "hide")) {
63 currentVal = "hide";
64 }
65 else {
66 currentVal = "show";
67 }
68 elShowDiff = elem;
69 }
70 else if(elem.type == "select-one") {
71 if(elem[elem.selectedIndex].value) currentVal = elem[elem.selectedIndex].value;
72 //If Default value is not specified - the first one in the selection list is the default
73 if (!defVal && elem[0].value) defVal = elem[0].value;
74 }
75 else if(elem.type == "select-multiple") {
76 currentVal = "";//for now
77 }
78 else if(elem.type == "checkbox") {
79 //alert("defVal1=" + elem.id + " " + defVal);
80 //var defVal = elem.defVal; //Default value
81 //alert("defVal2=" + defVal);
82 if(elem.checked == true) currentVal = "checked"
83 else currentVal = "unchecked";
84 }
85 else {
86 currentVal = elem.value;
87 }
88
89
90 var numdiff = parseInt($("NUM_DIFFS").value,10);
91 var optsNumDiff = parseInt($("NUM_OPTS_DIFFS").value,10);
92 if(defVal != currentVal) {
93 if(!utils.hasClass(elShowDiff, "nondef")) {
94 utils.addClass(elShowDiff, "nondef");
95 numdiff++;
96 if(utils.hasClass(elem,"opts")) optsNumDiff++;
97 }
98 ret = 1;
99 }
100 else {
101 if(utils.hasClass(elShowDiff, "nondef")) {
102 utils.removeClass(elShowDiff, "nondef");
103 //alert("noDiff-" + elem.id);
104 if(numdiff != 0) numdiff--;
105 if(utils.hasClass(elem,"opts")) optsNumDiff--;
106 }
107 ret=0;
108 }
109 $("NUM_DIFFS").value = numdiff;
110 $("NUM_OPTS_DIFFS").value = optsNumDiff;
111 if(numdiff > 0) {
112 $("diffMes").style.display = "inline";
113 }
114 else {
115 $("diffMes").style.display = "none";
116 }
117 //alert(elem.id + " " + $("NUM_DIFFS").value);
118 return ret;
119 }
120
121 function setDefalValue(elem)
122 {
123 var currentVal;
124 var defVal = elem.getAttribute("defVal"); //Default value
125 if(elem.type == "select-one") {
126 //If Default value is not specified - the first one in the selection list is the default
127 if(!defVal) defVal = elem[0].value;
128 for(j=0; j < elem.options.length; j++) {
129 if(elem.options[j].value == defVal) {
130 elem.options[j].selected = true;
131 break;
132 }
133 }
134 }
135 else if(elem.type == "checkbox" || elem.type == "radio") {
136 if(!defVal) defVal = "checked";
137 if(defVal == "checked") elem.checked = true
138 else elem.checked = false;
139 }
140 else {
141 if(!defVal) defVal = "";
142 elem.value = defVal;
143 }
144
145 var elShowDiff = utils.getParent(elem);
146 if(utils.hasClass(elShowDiff, "nondef")) {
147 utils.removeClass(elShowDiff, "nondef");
148 }
149 //alert(elem.id + " " + $("NUM_DIFFS").value);
150 }
151
152 function newResultsWinInit() {
153 jQuery("[class='newwin']").each(function(index) {
154 utils.addEvent(this, "click", setResultsTarget, false);
155 });
156 }
157
158 function resetOrganismSuggest(orgEntryElem)
159 {
160 //suggestHint is in the hidden field used for SRA
161 var defaultMessage = ($("suggestHint")) ? $("suggestHint").value : "Enter organism name or id--completions will be suggested";
162 var suggestHint = $("qorganism").getAttribute("suggestHint");
163 if(suggestHint) defaultMessage = suggestHint;
164 if(orgEntryElem.value == "") {
165 orgEntryElem.value = defaultMessage;
166 }
167 if(orgEntryElem.value == defaultMessage) {
168 utils.addClass(orgEntryElem,"orgHint");
169 }
170 }
171
172 function setupOrganismSuggest(orgEntryElem)
173 {
174 resetOrganismSuggest(orgEntryElem);
175 utils.addEvent(orgEntryElem, "focus", function() {
176 clearOrgSuggest(orgEntryElem);
177 }, false);
178 }
179
180 function clearOrgSuggest(orgEntryElem)
181 {
182 if(utils.hasClass(orgEntryElem,"orgHint")) {
183 orgEntryElem.value="";
184 utils.removeClass(orgEntryElem,"orgHint");
185 }
186 }
187
188 function InitCustomButton(bn)
189 {
190 utils.addEvent(bn, "mouseover", function() {this.src = this.getAttribute("mouseovImg");}, false);
191 utils.addEvent(bn, "mouseout", function() {this.src = this.getAttribute("mouseoutImg");}, false);
192 utils.addEvent(bn, "mousedown", function() {this.src = this.getAttribute("mousedownImg");}, false);
193 utils.addEvent(bn, "mouseup", function() {this.src = this.getAttribute("mouseupImg");}, false);
194 }
195
196 function showHideElem(id,hide)
197 {
198 if($(id)) {
199 if(hide) {
200 if(!utils.hasClass($(id),"hidden")) utils.addClass($(id), "hidden");
201 }
202 else {
203 if(utils.hasClass($(id),"hidden")) utils.removeClass($(id), "hidden");
204 }
205 }
206 }
207
208 function resetOrganismControls(orgEntryElem) {
209 resetOrganismSuggest(orgEntryElem);
210 if ($("orgExcl")) $("orgExcl").checked = false;
211 utils.replaceInHtml("", $("orgs"));
212 if ($("frOrgs")) utils.replaceInHtml("", $("frOrgs"));
213 if ($("numOrg")) $("numOrg").value = 1;
214 }
215
216 function AddOrgRow(e,orgName,exclName) {
217 e = e || window.event;
218 utils.preventDefault(e);
219 var checkedExclude = new Array();
220 var orgDict = jQuery($($("qorganism"))).ncbiautocomplete("option","dictionary");
221 orgDict = (!orgDict || orgDict == "") ? "taxids_sg" : orgDict;
222 var len = $("qorganism").getAttribute("size");
223
224 var newOrgFieldID = "qorganism" + $("numOrg").value;
225 var newOrgField = " <div><input name=\"" + orgName + $("numOrg").value + "\" size=\"" + len + "\" id=\"" + newOrgFieldID +
226 "\" type=\"text\" data-jigconfig=\"dictionary:'" + orgDict + "'\" autocomplete=\"off\" class=\"jig-ncbiautocomplete multiOrg\" />";
227 if (exclName != "") {
228 newOrgField += "<span class=\"orgExcl\">" +
229 "<input type=\"checkbox\" name=\"" + exclName + $("numOrg").value + "\" class=\"oExcl cb\" id=\"orgExcl" + $("numOrg").value + "\" />" +
230 "<label for=\"orgExcl" + $("numOrg").value + "\" class=\"right oExclRl\">Exclude</label></span>";
231 }
232 newOrgField += "</div>";
233 if (navigator.userAgent.match(/ie/i)) {
234 for (i = 1; i < $("numOrg").value; i++) {
235 if ($("orgExcl" + i)) checkedExclude[i] = $("orgExcl" + i).checked;
236 }
237 }
238 if (!navigator.userAgent.match(/firefox/i)) {
239 jQuery($($(orgs))).append(newOrgField,true);
240 }
241 else {
242 utils.insertInHtml(newOrgField, $("orgs"));
243 }
244
245 if (navigator.userAgent.match(/ie/i)) {
246 for (i = 1; i < $("numOrg").value; i++) {
247 if ($("orgExcl" + i)) $("orgExcl" + i).checked = checkedExclude[i];
248 }
249 }
250 setupOrganismSuggest($(newOrgFieldID));
251 jQuery($($(newOrgFieldID))).ncbiautocomplete();
252 $("numOrg").value++;
253 }
254
255 function adjustOrgVal(orgEntryElem)
256 {
257 //if (utils.hasClass($("searchForm").EQ_MENU, "orgHint")) $("searchForm").EQ_MENU.value = "";
258 clearOrgSuggest(orgEntryElem);
259 if ($("numOrg")) {
260 for (i = 1; i < $("numOrg").value; i++) {
261 if ($("qorganism" + i)) {
262 clearOrgSuggest($("qorganism" + i));
263 }
264 }
265 }
266 }
267
268 function getUrlCompForEntryField(elem) {
269 var url = "";
270 if (elem && elem.value != "") {
271 url = "&" + elem.name + "=" + escape(elem.value);
272 }
273 return url;
274 }
275
276
277 function getUrlCompForCheckedField(elem) {
278 var url = "";
279 if (elem && elem.checked) {
280 url = "&" + elem.name + "=" + elem.value;
281 }
282 return url;
283
284 }
285
286 function getUrlCompForOptionsField(elem) {
287 var url = "";
288 if (elem) {
289 url = "&" + elem.name + "=" + elem[elem.selectedIndex].value;
290 }
291 return url;
292 }
293
294 function getUrlCompForMultiOptionsField(elem) {
295 var url = "";
296 if (elem) {
297 for (i = 0; i < elem.options.length; i++) {
298 if (elem.options[i].selected) {
299 url += "&" + elem.name + "=" + elem.options[i].value;
300 }
301 }
302 }
303 return url;
304 }
305
306
307 utils.addEvent(window, 'load', newResultsWinInit, false);
308