1 /** NOTICE ** This is a DEPRECATED module, hence the lower-case file-name. I will eventually move everything here-in to separate modules. This will allow for a graceful transition to well-factored code **/
5 ************** Misc Secretary Functions ***********************************HEADER************************
11 document.getElementById('selectedblastp').innerHTML = "";
12 document.getElementById('selectedblastnfull').innerHTML = "";
13 document.getElementById('selectedblastncds').innerHTML = "";
15 if (window.getSelection)
17 txt = window.getSelection();
18 foundIn = 'window.getSelection()';
20 else if (document.getSelection)
22 txt = document.getSelection();
23 foundIn = 'document.getSelection()';
25 else if (document.selection)
27 txt = document.selection.createRange().text;
28 foundIn = 'document.selection.createRange()';
31 //fixtxt = txt.replace(/<br>/ig, "");
32 var fixtxt = new String(txt);
34 fixtxt = fixtxt.replace(/\W/ig, "");
35 if (fixtxt.match(/^[A-Z]+$/)) {
41 function selectedblastp(selection){
42 HTML = "<a class='external' href='http://www.ncbi.nlm.nih.gov/blast/Blast.cgi?CMD=Put&QUERY=" + selection + "&DATABASE=nr&PROGRAM=blastp&FILTER=L&HITLIST_SZE=500'>Perform BLASTP on Selection (" + selection.length + " aa)</a>";
43 document.getElementById('selectedblastp').innerHTML = HTML;
47 function selectedblastnfull(selection){
48 HTML = "<a class='external' href='http://www.ncbi.nlm.nih.gov/blast/Blast.cgi?CMD=Put&QUERY=" + selection + "&DATABASE=nr&PROGRAM=blastn&FILTER=L&HITLIST_SZE=500'>Perform BLASTN on Selection (" + selection.length + " bp)</a>";
49 document.getElementById('selectedblastnfull').innerHTML = HTML;
52 function selectedblastncds(selection){
53 HTML = "<a class='external' href='http://www.ncbi.nlm.nih.gov/blast/Blast.cgi?CMD=Put&QUERY=" + selection + "&DATABASE=nr&PROGRAM=blastn&FILTER=L&HITLIST_SZE=500'>Perform BLASTN on Selection (" + selection.length + " bp)</a>";
54 document.getElementById('selectedblastncds').innerHTML = HTML;
58 function closebox(boxID) {
59 document.getElementById(boxID).style.display="none";
63 /** Only works on <span> tags for a given class name, currently alters the following properties:
64 ***** color, backgroundColor, border, fontWeight **/
65 function classAlter(className, styleProperty, styleValue) {
66 for (i=0;i<document.getElementsByTagName("span").length; i++) {
67 if (document.getElementsByTagName("span").item(i).className == className){
68 document.getElementsByTagName("span").item(i).style[styleProperty] = styleValue;
70 if(1 == 0){ //change back if thing above doesn't work
71 if(styleProperty == "color"){
72 document.getElementsByTagName("span").item(i).style.color = styleValue;
74 else if(styleProperty == "backgroundColor"){
75 document.getElementsByTagName("span").item(i).style.backgroundColor = styleValue;
77 else if(styleProperty == "border"){
78 document.getElementsByTagName("span").item(i).style.border = styleValue;
80 else if(styleProperty == "fontWeight"){
81 document.getElementsByTagName("span").item(i).style.fontWeight = styleValue;
87 /* Must match value in class highlightColor of the css file
89 var searchHighlightColor = "#c9c9ff";
90 var searchHighlight = 0;
92 //Ensures that cookie object is instantiated, as well as Highlight Toggle-dependent functions
93 function prepareSearchHighlight(){
95 if(UserPrefs.get('searchHighlight')){
96 searchHighlight = UserPrefs.get('searchHighlight');
99 //Ok, this may look weird. What we are doing is priming browser cache by calling the toggle function, which calls the classAlter function
100 // and iterates through all of the <span> tags. Therefore, the switches occur more quickly when the user first clicks the button.
101 if (searchHighlight == 1){
103 toggleSearchHighlight(); //this will set searchHighlight back to 1, don't worry ;)
107 toggleSearchHighlight();
111 function toggleSearchHighlight(nocookieset){
113 classAlter("searchHighlight", "backgroundColor", "white");
114 document.getElementById("highlightSelector").style.display = "inline";
115 document.getElementById("unhighlightSelector").style.display = "none";
117 UserPrefs.set('searchHighlight', 0);
118 if(!nocookieset) UserPrefs.setCookie();
121 classAlter("searchHighlight", "backgroundColor", searchHighlightColor);
122 document.getElementById("highlightSelector").style.display = "none";
123 document.getElementById("unhighlightSelector").style.display = "inline";
125 UserPrefs.set('searchHighlight', 1);
126 if(!nocookieset) UserPrefs.setCookie();
131 ************** Secretary Database Query Functions *********************HEADER*****************************
135 var selectTextColorBg = "#771111"; //background color of active text
136 var selectTextColor = "#332277"; //color of unselected checkbox text
138 var joiners = new Array();
140 for(var i=0; i<10; i++) joiners.push("AND");
142 function selectModify(num, type){
145 document.getElementById("condcontainer" + num).style.display = "none";
146 document.getElementById("selrem" + num).style.display = "none";
147 if(num<10) document.getElementById("seladd" + num).style.display = "none";
148 document.getElementById("seladd" + (num-1)).style.display = "inline";
149 if (num > 1) document.getElementById("selrem" + (num-1)).style.display = "inline";
150 document.getElementById("condvar"+num).value="";
151 document.getElementById("condop"+num).value="=";
152 document.getElementById("condoperand"+num).value="";
155 if(num<10) document.getElementById("condcontainer" + (num+1)).style.display="inline";
156 if(num<10) document.getElementById("selrem" + (num+1)).style.display="inline";
157 if(num<9) document.getElementById("seladd" + (num+1)).style.display="inline";
158 document.getElementById("seladd" + num).style.display="none";
159 if(num>0) document.getElementById("selrem" + num).style.display="none"
163 function selectSwitch(value, item){
164 box = document.getElementById("cb." + value);
165 text = document.getElementById("text." + value);
168 box = document.getElementById("cb." + value + "." + item);
169 text = document.getElementById("text." + value + "." + item);
173 text.style.backgroundColor = "white";
174 text.style.color = selectTextColor;
175 text.style.fontWeight = "normal";
179 text.style.backgroundColor = selectTextColorBg;
180 text.style.color = "white";
181 text.style.fontWeight = "bold";
183 if(value != "COUNT"){
184 document.getElementById("cb.COUNT").checked = false;
185 text = document.getElementById("text.COUNT");
186 text.style.color = "#332277"
187 text.style.backgroundColor = "white";
188 text.style.fontWeight = "normal";
195 function cbColorSwitch(value, item){
197 box = document.getElementById("cb." + value);
198 text = document.getElementById("text." + value);
201 box = document.getElementById("cb." + value + "." + item);
202 text = document.getElementById("text." + value + "." + item);
207 text.style.backgroundColor = "white";
208 text.style.color = selectTextColor;
209 text.style.fontWeight = "normal";
212 text.style.backgroundColor = selectTextColorBg;
213 text.style.color = "white";
214 text.style.fontWeight = "bold";
219 function switchJoin(id){
220 joinercontent = document.getElementById("joinercontent"+id);
221 formjoiner = document.getElementById("formjoiner" + id);
222 if (joinercontent.innerHTML=="AND"){
223 joinercontent.innerHTML="OR";
224 joiners[id-1] = "OR";
225 formjoiner.value = "OR";
228 joinercontent.innerHTML="AND";
229 joiners[id-1] = "AND";
230 formjoiner.value = "AND";
234 function switchParen(id){
235 formparen = document.getElementById("formparen"+id);
236 parencontent = document.getElementById("parencontent"+id);
237 jointop = document.getElementById("jointop"+id);
238 joinbottom = document.getElementById("joinbottom"+id);
240 if(formparen.value=='0'){
242 parencontent.innerHTML = "<span style='color:#442277'>(Unjoin)</span>";
243 jointop.innerHTML="";
244 joinbottom.innerHTML="";
248 parencontent.innerHTML = "(Join)";
249 jointop.innerHTML="<br>";
250 joinbottom.innerHTML="<br>";
255 function variableChange(id){
256 variable = document.getElementById("condvar" + id);
257 operator = document.getElementById("condop" + id);
258 type = variable.value.charAt(0);
259 if(type=="f" || type=="i") operator.value = ">";
260 else if(type=="r") operator.value = "REGEXP";
261 else if(type=="t") operator.value = "FULLTEXT";
264 function chartTypeChange(){
265 ctype = document.getElementById("charttype");
266 pie_opt = document.getElementById("pie_options");
267 bar_opt = document.getElementById("bar_options");
269 pie_opt.style.display = "none";
270 bar_opt.style.display = "none";
272 else if(ctype.value=="pie"){
273 pie_opt.style.display = "block";
274 bar_opt.style.display = "none";
277 pie_opt.style.display = "none";
278 bar_opt.style.display = "block";
286 function killAnimateDots(){
290 function animateDots(){
296 document.getElementById("dots"+last).style.display="none";
297 document.getElementById("dots"+num).style.display="inline";
299 if(live) setTimeout("animateDots()", 500);
303 function closeBox(name){
304 document.getElementById(name+"_hide").style.display="none";
305 document.getElementById(name+"_show").style.display="inline";
306 document.getElementById(name+"_table").style.display="none";
307 document.getElementById(name+"_box").style.borderColor="#555555";
308 document.getElementById(name+"_header").style.backgroundColor="#555555";
311 function openBox(name){
312 document.getElementById(name+"_hide").style.display="inline";
313 document.getElementById(name+"_show").style.display="none";
314 document.getElementById(name+"_table").style.display="inline";
316 var activeColor = "";
317 if(name=="chart") activeColor = "#444499";
318 else if(name=="select") activeColor = "#770000";
319 else if(name=="cond") activeColor = "#551155";
321 document.getElementById(name+"_box").style.borderColor = activeColor;
322 document.getElementById(name+"_header").style.backgroundColor = activeColor;
327 *************** Hotlist Functions ***************************HEADER****************************************
330 function RequestWaitIndicator(waitElementId) {
332 RequestWaitIndicator.numWaits += 1;
333 this.id = "RWI:" + RequestWaitIndicator.numWaits;
334 RequestWaitIndicator.waitHash[this.id] = 1;
335 this.waitElementId = waitElementId;
336 setTimeout("RequestWaitIndicator.displayElement('" + this.id + "', '" + this.waitElementId + "')", 1000);
338 this.stopWait = function () {
339 RequestWaitIndicator.waitHash[this.id] = 0;
340 Effects.hideElement(waitElementId);
343 RequestWaitIndicator.numWaits = 0;
344 RequestWaitIndicator.waitHash = {};
345 RequestWaitIndicator.displayElement = function (waitId, elementId) {
346 if (RequestWaitIndicator.waitHash[waitId]){
347 Effects.showElement(elementId);
353 ********* User account related functions ****************HEADER************************************************
358 var http_request = false;
360 function makeRequest(url, parameters, type) {
362 http_request = false;
364 if (window.XMLHttpRequest) { // Mozilla, Safari,...
365 http_request = new XMLHttpRequest();
366 if (http_request.overrideMimeType) {
367 http_request.overrideMimeType('text/xml');
369 } else if (window.ActiveXObject) { // IE
371 http_request = new ActiveXObject("Msxml2.XMLHTTP");
374 http_request = new ActiveXObject("Microsoft.XMLHTTP");
379 //print("<!--Async XML Request Failed-->");
382 if (type=='username') http_request.onreadystatechange = alertContentsName;
383 http_request.open('GET', url + parameters, true);
384 http_request.send(null);
388 function alertContentsName() {
389 if (http_request.readyState == 4) {
390 if (http_request.status == 200) {
391 check_name_response(http_request.responseText);
400 function check_password(password){
402 document.getElementById('quickwarning').innerHTML = " ";
403 document.getElementById('choosepw').style.color= "black";
405 else if(password.length < 7){
406 document.getElementById('quickwarning').innerHTML = "Password must be at least 7 characters long";
407 document.getElementById('choosepw').style.color= "#dd4444";
410 document.getElementById('quickwarning').innerHTML = " ";
411 document.getElementById('choosepw').style.color = "black";
415 function check_password_match(passwordrep){
416 password = document.cf.password.value;
417 if(passwordrep=="" || password.length==0){
418 document.getElementById('quickwarning').innerHTML = " "
419 document.getElementById('confirmpw').style.color = "black";
421 else if(passwordrep != password){
422 document.getElementById('quickwarning').innerHTML = "Repeated password doesn't match";
423 document.getElementById('confirmpw').style.color = "#dd4444";
426 document.getElementById('quickwarning').innerHTML = " ";
427 document.getElementById('confirmpw').style.color = "black";
433 function check_name(username){
435 document.getElementById('quickwarning').innerHTML = " ";
436 document.getElementById('chooseuname').style.color = "black";
437 document.getElementById('uname_available').style.display = "none";
438 document.getElementById('uname_taken').style.display = "none";
440 else if(username.length < 7){
441 document.getElementById('quickwarning').firstChild.nodeValue = "Username must be at least 7 characters long";
442 document.getElementById('chooseuname').style.color = "#dd4444";
443 document.getElementById('uname_available').style.display = "none";
444 document.getElementById('uname_taken').style.display = "none";
447 document.getElementById('quickwarning').innerHTML = " ";
448 document.getElementById('chooseuname').style.color = "black";
449 makeRequest('scraps/check_name_avail.pl', '?username=' + username, 'username');
453 function check_email(email){
455 var ereg = /^[^@]+@[^@]+$/;
457 document.getElementById('quickwarning').innerHTML = " ";
458 document.getElementById('chooseemail').style.color = "black";
460 else if(!email.match(ereg)){
461 document.getElementById('quickwarning').innerHTML = "E-mail not of the form: name@address";
462 document.getElementById('chooseemail').style.color = "#dd4444";
466 document.getElementById('quickwarning').innerHTML = " ";
467 document.getElementById('chooseemail').style.color = "black";
471 function check_name_response(response){
473 document.getElementById('uname_available').style.display = "inline";
474 document.getElementById('uname_taken').style.display = "none";
476 else if(response=='0') {
477 document.getElementById('uname_available').style.display = "none";
478 document.getElementById('uname_taken').style.display = "inline";
481 document.getElementById('uname_available').style.display = "none";
482 document.getElementById('uname_taken').style.display = "none";
487 function hide_warning(){
488 document.getElementById('login_warning').style.display="none";
492 document.getElementById('login_box').style.display="none";
493 document.getElementById('createaccount_box').style.display="block";
494 document.getElementById('newuname').focus();
498 function hide_create(){
499 document.getElementById("createaccount_box").style.display="none";
500 document.getElementById("userbar_container").style.display="block";
501 document.getElementById("login_warning").style.display="none";
505 function hide_login(){
506 document.getElementById("login_box").style.display="none";
507 document.getElementById("userbar_container").style.display="block";
508 document.getElementById("login_warning").style.display="none";
512 function show_login(){
513 document.getElementById("login_box").style.display="block";
514 document.getElementById("userbar_container").style.display="none";
515 document.getElementById("uname").focus();
516 document.getElementById("login_warning").style.display="none";
523 **** List Functions ****************************HEADER**********************************************************
525 var http_request_mylistpage = false;
526 var workinglist = "";
530 var lastNewList = "";
533 function makeRequestMylist(url, parameters, type, list) {
536 http_request_mylistpage = false;
538 if (window.XMLHttpRequest) { // Mozilla, Safari,...
539 http_request_mylistpage = new XMLHttpRequest();
540 if (http_request_mylistpage.overrideMimeType) {
541 http_request_mylistpage.overrideMimeType('text/xml');
543 } else if (window.ActiveXObject) { // IE
545 http_request_mylistpage = new ActiveXObject("Msxml2.XMLHTTP");
548 http_request_mylistpage = new ActiveXObject("Microsoft.XMLHTTP");
552 if (!http_request_mylistpage) {
555 if (type=='alterlist') http_request_mylistpage.onreadystatechange = alertContentsList;
556 if (type=='FASTA') http_request_mylistpage.onreadystatechange = alertContentsFASTA;
557 http_request_mylistpage.open('GET', url + parameters, true);
558 http_request_mylistpage.send(null);
563 function alertContentsList() {
564 if (http_request_mylistpage.readyState == 4) {
565 if (http_request_mylistpage.status == 200) {
566 mylist_response(http_request_mylistpage.responseText);
574 function alertContentsFASTA(list){
575 if (http_request_mylistpage.readyState == 4) {
576 if (http_request_mylistpage.status == 200) {
577 fasta_response(http_request_mylistpage.responseText);
586 function createFASTA(type, list) {
587 document.getElementById(list+'_fetch').style.display='inline';
588 document.getElementById(list+'_cleartool').style.display="none";
589 document.getElementById(list+'_createfastalinks').style.display="none";
590 if(type!="full" && type!="cds" && type!="prot" && type!="cdna") type="full";
592 var RequestURL = "fastacreate.php?user=<?php echo $username?>&type=" + type + "&list="+list;
593 makeRequestMylist(RequestURL, "", "FASTA", list);
597 function fasta_response(output) {
598 var list = workinglist;
599 document.getElementById(list+"_FASTAbox").value = output;
600 document.getElementById(list+"_FASTAholder").style.display="block";
601 document.getElementById(list+"_fetch").style.display='none';
602 document.getElementById(list+"_cleartool").style.display="inline";
603 document.getElementById(list+"_createfastalinks").style.display = "inline";
608 if(lastAction=="add") action = "remove";
609 else if(lastAction=="remove") action = "add";
616 function alterList(newlist, action, list){
620 lastNewList = newlist;
622 var RequestURL = "alterlist.php?user=<?php echo $username?>&md5pass=<?php echo $password?>";
623 RequestURL += "&list="+list+"&newlist=" + newlist + "&action=" + action;
624 makeRequestMylist(RequestURL, "", "alterlist", list);
627 var clear_reload = 0;
628 function clearList(list){
630 RequestURL = "alterlist.php?user=<?php echo $username?>&md5pass=<?php echo $password?>";
631 RequestURL += "&list="+list+"&clear=1";
632 makeRequestMylist(RequestURL, "", "alterlist", list);
636 function alterLink(id, action, list){
638 if(action=="add") HTML = "<a href='#' onclick='alterList(\"" + id + "\", \"add\", \""+list+"\"); alterLink(\"" + id + "\", \"remove\", \""+list+"\"); return false;' style='text-decoration:none'>[ <img src='/img/hotlist_add.png' border=0 align='absmiddle'> Re-Add ]</a>";
639 else if (action=="remove") HTML = "<a href='#' onclick='alterList(\"" + id + "\", \"remove\", \""+list+"\"); alterLink(\"" + id + "\", \"add\", \""+list+"\"); return false;' style='text-decoration:none'>[ <img src='/img/hotlist_remove.png' border=0 align='absmiddle'> Remove ]</a>";
640 document.getElementById(list + "_" + id).innerHTML = HTML;
644 function mylist_response(output){
646 var list = workinglist;
647 output = output.toString();
649 if (output.charAt(0) == 'q'){
651 output = output.substring(1);
652 listsize = output * 1;
653 if(list=="hotlist") document.getElementById('hlsize').firstChild.nodeValue = listsize;
654 document.getElementById(list+"_headercount").innerHTML = listsize + " Genes";
655 if(listsize==0 && clear_reload==1) window.location.reload();