annotate Blast output page example trimmed_files/blast.js @ 20:53cd304c5f26

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