1 /*** Third-party Javascript Code **************************************************************************
2 **********************************************************************************************************
5 /** NOTICE: This code has been modified for ease of use. Please download the original from
6 http://www.jaaulde.com/test_bed/cookieLib/ for the original (and latest) versions
8 Copyright (c) 2005, James Auldridge
10 Code licensed under the BSD License:
11 http://www.jaaulde.com/license.txt
14 var Cookie
= window
.Cookie
|| {};
16 get: function(cookieName
) {
17 var cookieNameStart
,valueStart
,valueEnd
,value
;
18 cookieNameStart
= document
.cookie
.indexOf(cookieName
+'=');
19 if (cookieNameStart
< 0) {return null;}
20 valueStart
= document
.cookie
.indexOf(cookieName
+'=') + cookieName
.length
+ 1;
21 valueEnd
= document
.cookie
.indexOf(";",valueStart
);
22 if (valueEnd
== -1){valueEnd
= document
.cookie
.length
;}
23 value
= document
.cookie
.substring(valueStart
,valueEnd
);
24 value
= unescape(value
);
25 if (value
== "") {return null;}
28 set: function(cookieName
,value
,hoursToLive
,path
,domain
,secure
) {
29 var domainRegEx
= /[^.]+\.[^.]+$/;
30 domain
= window
.location
.hostname
.match(domainRegEx
);
31 if(domain
== 'cornell.edu') domain
= 'sgn.cornell.edu';
32 var expireString
,timerObj
,expireAt
,pathString
,domainString
,secureString
,setCookieString
;
33 if (!hoursToLive
|| typeof hoursToLive
!= 'number' || parseInt(hoursToLive
)=='NaN'){
37 timerObj
= new Date();
38 timerObj
.setTime(timerObj
.getTime()+(parseInt(hoursToLive
)*60*60*1000));
39 expireAt
= timerObj
.toGMTString();
40 expireString
= "; expires="+expireAt
;
42 pathString
= "; path=";
43 (!path
|| path
=="") ? pathString
+= "/" : pathString
+= path
;
44 domainString
= "; domain=";
45 (!domain
|| domain
=="") ? domainString
+= window
.location
.hostname
: domainString
+= domain
;
46 (secure
=== true) ? secureString
= "; secure" : secureString
= "";
47 value
= escape(value
);
48 setCookieString
= cookieName
+"="+value
+expireString
+pathString
+domainString
;
49 document
.cookie
= setCookieString
;
51 del: function(cookieName
,path
,domain
){
52 (!path
|| !path
.length
) ? path
="" : path
=path
;
53 (!domain
|| !domain
.length
) ? domain
="" : domain
=domain
;
54 Cookie
.utils
.cookies
.set(cookieName
,"",-8760,path
,domain
);
57 Cookie
.utils
.cookies
.set('cT','acc');
58 var runTest
= Cookie
.utils
.cookies
.get('cT');
59 if (runTest
== 'acc'){
60 Cookie
.utils
.cookies
.del('cT');
72 /** Javascript Code written by C. Carpita and ******* ***************************************************
73 *********************************************************************************************************
74 *********************************************************************************************************
80 ************** Misc Secretary Functions ***********************************HEADER************************
86 document
.getElementById('selectedblastp').innerHTML
= "";
87 document
.getElementById('selectedblastnfull').innerHTML
= "";
88 document
.getElementById('selectedblastncds').innerHTML
= "";
90 if (window
.getSelection
)
92 txt
= window
.getSelection();
93 foundIn
= 'window.getSelection()';
95 else if (document
.getSelection
)
97 txt
= document
.getSelection();
98 foundIn
= 'document.getSelection()';
100 else if (document
.selection
)
102 txt
= document
.selection
.createRange().text
;
103 foundIn
= 'document.selection.createRange()';
106 //fixtxt = txt.replace(/<br>/ig, "");
107 var fixtxt
= new String(txt
);
109 fixtxt
= fixtxt
.replace(/\W/ig, "");
110 if (fixtxt
.match(/^[A-Z]+$/)) {
116 function selectedblastp(selection
){
117 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>";
118 document
.getElementById('selectedblastp').innerHTML
= HTML
;
122 function selectedblastnfull(selection
){
123 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>";
124 document
.getElementById('selectedblastnfull').innerHTML
= HTML
;
127 function selectedblastncds(selection
){
128 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>";
129 document
.getElementById('selectedblastncds').innerHTML
= HTML
;
133 function closebox(boxID
) {
134 document
.getElementById(boxID
).style
.display
="none";
138 /** Only works on <span> tags for a given class name, currently alters the following properties:
139 ***** color, backgroundColor, border, fontWeight **/
140 function classAlter(className
, styleProperty
, styleValue
) {
141 for (i
=0;i
<document
.getElementsByTagName("span").length
; i
++) {
142 if (document
.getElementsByTagName("span").item(i
).className
== className
){
143 if(styleProperty
== "color"){
144 document
.getElementsByTagName("span").item(i
).style
.color
= styleValue
;
146 else if(styleProperty
== "backgroundColor"){
147 document
.getElementsByTagName("span").item(i
).style
.backgroundColor
= styleValue
;
149 else if(styleProperty
== "border"){
150 document
.getElementsByTagName("span").item(i
).style
.border
= styleValue
;
152 else if(styleProperty
== "fontWeight"){
153 document
.getElementsByTagName("span").item(i
).style
.fontWeight
= styleValue
;
159 /* Must match value in class highlightColor of the css file
161 var searchHighlightColor
= "#c9c9ff";
162 var searchHighlight
= 0;
164 //Ensures that cookie object is instantiated, as well as Highlight Toggle-dependent functions
165 function prepareSearchHighlight(){
167 if(UserPrefs
.get('searchHighlight')){
168 searchHighlight
= UserPrefs
.get('searchHighlight');
171 //Ok, this may look weird. What we are doing is priming browser cache by calling the toggle function, which calls the classAlter function
172 // and iterates through all of the <span> tags. Therefore, the switches occur more quickly when the user first clicks the button.
173 if (searchHighlight
== 1){
175 toggleSearchHighlight(); //this will set searchHighlight back to 1, don't worry ;)
179 toggleSearchHighlight();
183 function toggleSearchHighlight(nocookieset
){
185 classAlter("searchHighlight", "backgroundColor", "white");
186 document
.getElementById("highlightSelector").style
.display
= "inline";
187 document
.getElementById("unhighlightSelector").style
.display
= "none";
189 UserPrefs
.set('searchHighlight', 0);
190 if(!nocookieset
) UserPrefs
.setCookie();
193 classAlter("searchHighlight", "backgroundColor", searchHighlightColor
);
194 document
.getElementById("highlightSelector").style
.display
= "none";
195 document
.getElementById("unhighlightSelector").style
.display
= "inline";
197 UserPrefs
.set('searchHighlight', 1);
198 if(!nocookieset
) UserPrefs
.setCookie();
203 ************** Secretary Database Query Functions *********************HEADER*****************************
207 var selectTextColorBg
= "#771111"; //background color of active text
208 var selectTextColor
= "#332277"; //color of unselected checkbox text
210 var joiners
= new Array();
212 for(var i
=0; i
<10; i
++) joiners
.push("AND");
214 function selectModify(num
, type
){
217 document
.getElementById("condcontainer" + num
).style
.display
= "none";
218 document
.getElementById("selrem" + num
).style
.display
= "none";
219 if(num
<10) document
.getElementById("seladd" + num
).style
.display
= "none";
220 document
.getElementById("seladd" + (num
-1)).style
.display
= "inline";
221 if (num
> 1) document
.getElementById("selrem" + (num
-1)).style
.display
= "inline";
222 document
.getElementById("condvar"+num
).value
="";
223 document
.getElementById("condop"+num
).value
="=";
224 document
.getElementById("condoperand"+num
).value
="";
227 if(num
<10) document
.getElementById("condcontainer" + (num
+1)).style
.display
="inline";
228 if(num
<10) document
.getElementById("selrem" + (num
+1)).style
.display
="inline";
229 if(num
<9) document
.getElementById("seladd" + (num
+1)).style
.display
="inline";
230 document
.getElementById("seladd" + num
).style
.display
="none";
231 if(num
>0) document
.getElementById("selrem" + num
).style
.display
="none"
235 function selectSwitch(value
, item
){
236 box
= document
.getElementById("cb." + value
);
237 text
= document
.getElementById("text." + value
);
240 box
= document
.getElementById("cb." + value
+ "." + item
);
241 text
= document
.getElementById("text." + value
+ "." + item
);
245 text
.style
.backgroundColor
= "white";
246 text
.style
.color
= selectTextColor
;
247 text
.style
.fontWeight
= "normal";
251 text
.style
.backgroundColor
= selectTextColorBg
;
252 text
.style
.color
= "white";
253 text
.style
.fontWeight
= "bold";
255 if(value
!= "COUNT"){
256 document
.getElementById("cb.COUNT").checked
= false;
257 text
= document
.getElementById("text.COUNT");
258 text
.style
.color
= "#332277"
259 text
.style
.backgroundColor
= "white";
260 text
.style
.fontWeight
= "normal";
267 function cbColorSwitch(value
, item
){
269 box
= document
.getElementById("cb." + value
);
270 text
= document
.getElementById("text." + value
);
273 box
= document
.getElementById("cb." + value
+ "." + item
);
274 text
= document
.getElementById("text." + value
+ "." + item
);
279 text
.style
.backgroundColor
= "white";
280 text
.style
.color
= selectTextColor
;
281 text
.style
.fontWeight
= "normal";
284 text
.style
.backgroundColor
= selectTextColorBg
;
285 text
.style
.color
= "white";
286 text
.style
.fontWeight
= "bold";
291 function switchJoin(id
){
292 joinercontent
= document
.getElementById("joinercontent"+id
);
293 formjoiner
= document
.getElementById("formjoiner" + id
);
294 if (joinercontent
.innerHTML
=="AND"){
295 joinercontent
.innerHTML
="OR";
296 joiners
[id
-1] = "OR";
297 formjoiner
.value
= "OR";
300 joinercontent
.innerHTML
="AND";
301 joiners
[id
-1] = "AND";
302 formjoiner
.value
= "AND";
306 function switchParen(id
){
307 formparen
= document
.getElementById("formparen"+id
);
308 parencontent
= document
.getElementById("parencontent"+id
);
309 jointop
= document
.getElementById("jointop"+id
);
310 joinbottom
= document
.getElementById("joinbottom"+id
);
312 if(formparen
.value
=='0'){
314 parencontent
.innerHTML
= "<span style='color:#442277'>(Unjoin)</span>";
315 jointop
.innerHTML
="";
316 joinbottom
.innerHTML
="";
320 parencontent
.innerHTML
= "(Join)";
321 jointop
.innerHTML
="<br>";
322 joinbottom
.innerHTML
="<br>";
327 function variableChange(id
){
328 variable
= document
.getElementById("condvar" + id
);
329 operator
= document
.getElementById("condop" + id
);
330 type
= variable
.value
.charAt(0);
331 if(type
=="f" || type
=="i") operator
.value
= ">";
332 else if(type
=="r") operator
.value
= "REGEXP";
333 else if(type
=="t") operator
.value
= "FULLTEXT";
336 function chartTypeChange(){
337 ctype
= document
.getElementById("charttype");
338 pie_opt
= document
.getElementById("pie_options");
339 bar_opt
= document
.getElementById("bar_options");
341 pie_opt
.style
.display
= "none";
342 bar_opt
.style
.display
= "none";
344 else if(ctype
.value
=="pie"){
345 pie_opt
.style
.display
= "block";
346 bar_opt
.style
.display
= "none";
349 pie_opt
.style
.display
= "none";
350 bar_opt
.style
.display
= "block";
358 function killAnimateDots(){
362 function animateDots(){
368 document
.getElementById("dots"+last
).style
.display
="none";
369 document
.getElementById("dots"+num
).style
.display
="inline";
371 if(live
) setTimeout("animateDots()", 500);
375 function closeBox(name
){
376 document
.getElementById(name
+"_hide").style
.display
="none";
377 document
.getElementById(name
+"_show").style
.display
="inline";
378 document
.getElementById(name
+"_table").style
.display
="none";
379 document
.getElementById(name
+"_box").style
.borderColor
="#555555";
380 document
.getElementById(name
+"_header").style
.backgroundColor
="#555555";
383 function openBox(name
){
384 document
.getElementById(name
+"_hide").style
.display
="inline";
385 document
.getElementById(name
+"_show").style
.display
="none";
386 document
.getElementById(name
+"_table").style
.display
="inline";
388 var activeColor
= "";
389 if(name
=="chart") activeColor
= "#444499";
390 else if(name
=="select") activeColor
= "#770000";
391 else if(name
=="cond") activeColor
= "#551155";
393 document
.getElementById(name
+"_box").style
.borderColor
= activeColor
;
394 document
.getElementById(name
+"_header").style
.backgroundColor
= activeColor
;
399 *************** Hotlist Functions ***************************HEADER****************************************
402 //var user_pref_string is used (global already set in header))
403 //Used to set user_pref_string variables for the current user.
405 _preferences
: new Object
,
408 //the string is initially set server-side, so if we don't get
409 //anything, we try the client-side cookie
410 if(!user_pref_string
.length
) UserPrefs
.loadCookie();
412 if(user_pref_string
.length
&& user_pref_string
.indexOf('=') && user_pref_string
.indexOf(":")) {
413 var pref_array
= user_pref_string
.split(":");
414 for(var n
= 0; n
< pref_array
.length
; n
++) {
415 var key_val
= pref_array
[n
].split("=");
416 if(key_val
[0].length
>0 && key_val
[1].length
>0){
417 UserPrefs
._preferences
[key_val
[0]] = key_val
[1];
421 UserPrefs
.setCookie();
423 setCookie: function() {
424 var thisDate
= new Date();
425 var base
= new Date(0);
426 var skew
= base
.getTime();
427 var unix_epoch_time
= thisDate
.getTime();
428 if (skew
> 0) unix_epoch_time
-= skew
; //Steve Jobs is a prick!
429 UserPrefs
._preferences
.timestamp
= unix_epoch_time
;
430 UserPrefs
._preferences
.sp_person_id
= user_id
;
431 UserPrefs
._buildString();
432 Cookie
.set('user_prefs', user_pref_string
, 1000);
434 //sendPrefs will make an AJAX request to the server, writing the cookie string to the database. neat-o!
435 //ONLY use this when you anticipate that the user will set a preference and not load another page. The page-loading process will update the user_prefs string in the database from the user's cookie.
437 var req
= new Request();
440 var parameters
= "?sp_person_id=" + user_id
+ "&user_prefs=" + encodeURIComponent(user_pref_string
);
441 req
.sendRequest("/scraps/set_user_prefs.pl", parameters
);
446 loadCookie: function() {
447 user_pref_string
= Cookie
.get('user_prefs');
449 _buildString: function() {
452 for(var name
in UserPrefs
._preferences
){
453 if(i
>0) new_string
+= ":";
454 new_string
+= name
+ "=" + UserPrefs
._preferences
[name
];
457 user_pref_string
= new_string
;
459 set: function(name
, value
) {
460 UserPrefs
._preferences
[name
] = value
;
462 get: function(name
) {
463 return UserPrefs
._preferences
[name
];
469 //Encapsulates all of our visual effects on Secretary
472 switchHotlistButton: function(buttonId
, switchTo
, content
, clearOnClick
){
473 var button
= document
.getElementById(buttonId
);
474 var imgAdd
= document
.getElementById(buttonId
+ ":imgAdd");
475 var imgRemove
= document
.getElementById(buttonId
+ ":imgRemove");
477 var optionalText
= "All AGIs on this Page ";
478 if(!content
.match(/:/)) optionalText
= "";
479 if(switchTo
== 'remove'){
480 imgAdd
.style
.display
= "none";
481 imgRemove
.style
.display
= "inline";
482 button
.firstChild
.nodeValue
= "Remove " + optionalText
+ "from Hotlist";
484 button
.setAttribute("onClick", "alert('some')");
487 button
.setAttribute("onClick", "Hotlist.remove('" + buttonId
+ "', '" + content
+ "'); return false;");
490 else if (switchTo
== 'add'){
491 imgAdd
.style
.display
= "inline";
492 imgRemove
.style
.display
= "none";
493 button
.firstChild
.nodeValue
= "Add " + optionalText
+ "to Hotlist";
495 button
.setAttribute("onClick", "alert('some')");
498 button
.setAttribute("onClick", "Hotlist.add('" + buttonId
+ "', '" + content
+ "'); return false;");
501 else { alert("You sent a bad switchTo variable to switchHotlistButton"); }
503 showElement: function(elementId
, displayMethod
) {
504 var element
= document
.getElementById(elementId
);
507 dispMethod
= displayMethod
;
509 else { dispMethod
= "inline" }
510 element
.style
.display
= dispMethod
;
512 hideElement: function(elementId
, displayMethod
) {
513 var element
= document
.getElementById(elementId
);
516 dispMethod
= displayMethod
518 else { dispMethod
= "none"; } //alternative is "hidden", which causes it to continue occupying space on the page
519 element
.style
.display
= dispMethod
;
521 swapElements: function(elementIdFrom
, elementIdTo
, displayMethod
){
523 var dispMethod
= displayMethod
|| "inline";
524 var elementFrom
= document
.getElementById(elementIdFrom
);
525 var elementTo
= document
.getElementById(elementIdTo
);
526 elementFrom
.style
.display
= "none";
527 elementTo
.style
.display
= dispMethod
;
529 catch(e
) { alert(e
) }
535 function RequestWaitIndicator(waitElementId
) {
537 RequestWaitIndicator
.numWaits
+= 1;
538 this.id
= "RWI:" + RequestWaitIndicator
.numWaits
;
539 RequestWaitIndicator
.waitHash
[this.id
] = 1;
540 this.waitElementId
= waitElementId
;
541 setTimeout("RequestWaitIndicator.displayElement('" + this.id
+ "', '" + this.waitElementId
+ "')", 1000);
543 this.stopWait = function () {
544 RequestWaitIndicator
.waitHash
[this.id
] = 0;
545 Effects
.hideElement(waitElementId
);
548 RequestWaitIndicator
.numWaits
= 0;
549 RequestWaitIndicator
.waitHash
= {};
550 RequestWaitIndicator
.displayElement = function (waitId
, elementId
) {
551 if (RequestWaitIndicator
.waitHash
[waitId
]){
552 Effects
.showElement(elementId
);
559 //The returned XML file should contain all information needed to cause a page effect,
560 //rather than creating a custom response for each request, which is not possible due
561 //to the security issues that prevent the creation of instances of XMLHttpRequest()
562 //with unique properties
569 if(window
.XMLHttpRequest
) {
570 request
= new XMLHttpRequest();
572 else if (window
.ActiveXObject
) {
573 try { request
= new ActiveXObject("Msxml2.XMLHTTP");}
575 try { request
= new ActiveXObject ("Microsoft.XMLHTTP");}
582 request
.onreadystatechange = function() { loader
.onReadyState
.call() }
586 this.isValid= function () { return valid
}
587 this.onReadyState= function() { //override this function in a subclass!!
588 if(request
.readyState
==4){
589 if(request
.responseText
.indexOf('E:')==0) alert(request
.responseText
);
590 XMLroute(request
.responseXML
);
593 this.sendRequest= function(url
, parameters
, method
) {
594 if(!method
) { method
= "GET" }
595 request
.open(method
, url
+ parameters
, true);
600 //finds the calling object name in the XML response and directs the document to the appropriate handler
601 function XMLroute (response
) {
603 var caller
= doc
.getElementsByTagName("caller")[0].firstChild
.nodeValue
;
604 if(caller
=="Hotlist") {
605 Hotlist
._response(doc
);
608 // insert 'if' statements to route to other handlers
613 //Hotlist is defined as a single object instead of a class. We can't have more than one!
614 var Hotlist
= window
.Hotlist
|| {};
615 Hotlist
= { //buttonId: id of the clicked button, for changing the button
616 add: function(buttonId
, content
) {
617 if(!buttonId
) { alert("buttonId not sent!"); }
618 var waitIndicator
;// = new RequestWaitIndicator("hotlistWait:" + content);
619 var request
= new Request();
620 if(request
.isValid()) {
621 Effects
.switchHotlistButton(buttonId
, 'remove', content
, 1); //last argument clears onClick to prevent user interaction
622 var parameters
= "?owner=" + user_id
+ "&button_id=" + buttonId
+ "&cookie_string=" + cookie_string
+ "&action=add&content=" + content
;
623 request
.sendRequest("/scraps/hotlist.pl", parameters
);
625 else { alert('invalid request') }
627 remove: function (buttonId
, content
) {
628 if(!buttonId
) { alert("buttonId not sent!"); }
629 var waitIndicator
;// = new RequestWaitIndicator("hotlistWait:" + content);
630 var request
= new Request();
631 if(request
.isValid()) {
632 Effects
.switchHotlistButton(buttonId
, 'add', content
, 1);
633 var parameters
= "?owner=" + user_id
+ "&button_id=" + buttonId
+ "&cookie_string=" + cookie_string
+ "&action=remove&content=" + content
;
634 request
.sendRequest("/scraps/hotlist.pl", parameters
);
637 _response: function(doc
) {
638 var newsize
= doc
.getElementsByTagName("newsize")[0].firstChild
.nodeValue
;
639 var oldsize
= doc
.getElementsByTagName("oldsize")[0].firstChild
.nodeValue
;
640 var content
= doc
.getElementsByTagName("content")[0].firstChild
.nodeValue
;
641 var action
= doc
.getElementsByTagName("action")[0].firstChild
.nodeValue
;
642 var buttonId
= doc
.getElementsByTagName("buttonId")[0].firstChild
.nodeValue
;
643 if(newsize
> oldsize
){
644 Hotlist
._addResponse(buttonId
, content
, newsize
);
646 else if(newsize
< oldsize
) {
647 Hotlist
._removeResponse(buttonId
, content
, newsize
);
650 Hotlist
._nullResponse(buttonId
, content
, action
);
651 alert(doc
); //temporary
654 _addResponse: function(buttonId
, content
, newsize
){
655 Effects
.switchHotlistButton(buttonId
, 'remove', content
); //will restore onClick attribute
656 document
.getElementById('hlsize').firstChild
.nodeValue
= newsize
;
658 _removeResponse: function(buttonId
, content
, newsize
){
659 Effects
.switchHotlistButton(buttonId
, 'add', content
);
660 document
.getElementById('hlsize').firstChild
.nodeValue
= newsize
;
662 _nullResponse: function(buttonId
, content
, action
) {
663 if(action
== "add") {
664 Effects
.switchHotlistButton(buttonId
, 'add', content
); //change back
666 if(action
== "remove") {
667 Effects
.switchHotlistButton(buttonId
, 'add', content
); //change back
673 ********* User account related functions ****************HEADER************************************************
678 var http_request
= false;
680 function makeRequest(url
, parameters
, type
) {
682 http_request
= false;
684 if (window
.XMLHttpRequest
) { // Mozilla, Safari,...
685 http_request
= new XMLHttpRequest();
686 if (http_request
.overrideMimeType
) {
687 http_request
.overrideMimeType('text/xml');
689 } else if (window
.ActiveXObject
) { // IE
691 http_request
= new ActiveXObject("Msxml2.XMLHTTP");
694 http_request
= new ActiveXObject("Microsoft.XMLHTTP");
699 //print("<!--Async XML Request Failed-->");
702 if (type
=='username') http_request
.onreadystatechange
= alertContentsName
;
703 http_request
.open('GET', url
+ parameters
, true);
704 http_request
.send(null);
708 function alertContentsName() {
709 if (http_request
.readyState
== 4) {
710 if (http_request
.status
== 200) {
711 check_name_response(http_request
.responseText
);
720 function check_password(password
){
722 document
.getElementById('quickwarning').innerHTML
= " ";
723 document
.getElementById('choosepw').style
.color
= "black";
725 else if(password
.length
< 7){
726 document
.getElementById('quickwarning').innerHTML
= "Password must be at least 7 characters long";
727 document
.getElementById('choosepw').style
.color
= "#dd4444";
730 document
.getElementById('quickwarning').innerHTML
= " ";
731 document
.getElementById('choosepw').style
.color
= "black";
735 function check_password_match(passwordrep
){
736 password
= document
.cf
.password
.value
;
737 if(passwordrep
=="" || password
.length
==0){
738 document
.getElementById('quickwarning').innerHTML
= " "
739 document
.getElementById('confirmpw').style
.color
= "black";
741 else if(passwordrep
!= password
){
742 document
.getElementById('quickwarning').innerHTML
= "Repeated password doesn't match";
743 document
.getElementById('confirmpw').style
.color
= "#dd4444";
746 document
.getElementById('quickwarning').innerHTML
= " ";
747 document
.getElementById('confirmpw').style
.color
= "black";
753 function check_name(username
){
755 document
.getElementById('quickwarning').innerHTML
= " ";
756 document
.getElementById('chooseuname').style
.color
= "black";
757 document
.getElementById('uname_available').style
.display
= "none";
758 document
.getElementById('uname_taken').style
.display
= "none";
760 else if(username
.length
< 7){
761 document
.getElementById('quickwarning').firstChild
.nodeValue
= "Username must be at least 7 characters long";
762 document
.getElementById('chooseuname').style
.color
= "#dd4444";
763 document
.getElementById('uname_available').style
.display
= "none";
764 document
.getElementById('uname_taken').style
.display
= "none";
767 document
.getElementById('quickwarning').innerHTML
= " ";
768 document
.getElementById('chooseuname').style
.color
= "black";
769 makeRequest('scraps/check_name_avail.pl', '?username=' + username
, 'username');
773 function check_email(email
){
775 var ereg
= /^[^@]+@[^@]+$/;
777 document
.getElementById('quickwarning').innerHTML
= " ";
778 document
.getElementById('chooseemail').style
.color
= "black";
780 else if(!email
.match(ereg
)){
781 document
.getElementById('quickwarning').innerHTML
= "E-mail not of the form: name@address";
782 document
.getElementById('chooseemail').style
.color
= "#dd4444";
786 document
.getElementById('quickwarning').innerHTML
= " ";
787 document
.getElementById('chooseemail').style
.color
= "black";
791 function check_name_response(response
){
793 document
.getElementById('uname_available').style
.display
= "inline";
794 document
.getElementById('uname_taken').style
.display
= "none";
796 else if(response
=='0') {
797 document
.getElementById('uname_available').style
.display
= "none";
798 document
.getElementById('uname_taken').style
.display
= "inline";
801 document
.getElementById('uname_available').style
.display
= "none";
802 document
.getElementById('uname_taken').style
.display
= "none";
807 function hide_warning(){
808 document
.getElementById('login_warning').style
.display
="none";
812 document
.getElementById('login_box').style
.display
="none";
813 document
.getElementById('createaccount_box').style
.display
="block";
814 document
.getElementById('newuname').focus();
818 function hide_create(){
819 document
.getElementById("createaccount_box").style
.display
="none";
820 document
.getElementById("userbar_container").style
.display
="block";
821 document
.getElementById("login_warning").style
.display
="none";
825 function hide_login(){
826 document
.getElementById("login_box").style
.display
="none";
827 document
.getElementById("userbar_container").style
.display
="block";
828 document
.getElementById("login_warning").style
.display
="none";
832 function show_login(){
833 document
.getElementById("login_box").style
.display
="block";
834 document
.getElementById("userbar_container").style
.display
="none";
835 document
.getElementById("uname").focus();
836 document
.getElementById("login_warning").style
.display
="none";
843 **** List Functions ****************************HEADER**********************************************************
845 var http_request_mylistpage
= false;
846 var workinglist
= "";
850 var lastNewList
= "";
853 function makeRequestMylist(url
, parameters
, type
, list
) {
856 http_request_mylistpage
= false;
858 if (window
.XMLHttpRequest
) { // Mozilla, Safari,...
859 http_request_mylistpage
= new XMLHttpRequest();
860 if (http_request_mylistpage
.overrideMimeType
) {
861 http_request_mylistpage
.overrideMimeType('text/xml');
863 } else if (window
.ActiveXObject
) { // IE
865 http_request_mylistpage
= new ActiveXObject("Msxml2.XMLHTTP");
868 http_request_mylistpage
= new ActiveXObject("Microsoft.XMLHTTP");
872 if (!http_request_mylistpage
) {
875 if (type
=='alterlist') http_request_mylistpage
.onreadystatechange
= alertContentsList
;
876 if (type
=='FASTA') http_request_mylistpage
.onreadystatechange
= alertContentsFASTA
;
877 http_request_mylistpage
.open('GET', url
+ parameters
, true);
878 http_request_mylistpage
.send(null);
883 function alertContentsList() {
884 if (http_request_mylistpage
.readyState
== 4) {
885 if (http_request_mylistpage
.status
== 200) {
886 mylist_response(http_request_mylistpage
.responseText
);
894 function alertContentsFASTA(list
){
895 if (http_request_mylistpage
.readyState
== 4) {
896 if (http_request_mylistpage
.status
== 200) {
897 fasta_response(http_request_mylistpage
.responseText
);
906 function createFASTA(type
, list
) {
907 document
.getElementById(list
+'_fetch').style
.display
='inline';
908 document
.getElementById(list
+'_cleartool').style
.display
="none";
909 document
.getElementById(list
+'_createfastalinks').style
.display
="none";
910 if(type
!="full" && type
!="cds" && type
!="prot" && type
!="cdna") type
="full";
912 var RequestURL
= "fastacreate.php?user=<?php echo $username?>&type=" + type
+ "&list="+list
;
913 makeRequestMylist(RequestURL
, "", "FASTA", list
);
917 function fasta_response(output
) {
918 var list
= workinglist
;
919 document
.getElementById(list
+"_FASTAbox").value
= output
;
920 document
.getElementById(list
+"_FASTAholder").style
.display
="block";
921 document
.getElementById(list
+"_fetch").style
.display
='none';
922 document
.getElementById(list
+"_cleartool").style
.display
="inline";
923 document
.getElementById(list
+"_createfastalinks").style
.display
= "inline";
928 if(lastAction
=="add") action
= "remove";
929 else if(lastAction
=="remove") action
= "add";
936 function alterList(newlist
, action
, list
){
940 lastNewList
= newlist
;
942 var RequestURL
= "alterlist.php?user=<?php echo $username?>&md5pass=<?php echo $password?>";
943 RequestURL
+= "&list="+list
+"&newlist=" + newlist
+ "&action=" + action
;
944 makeRequestMylist(RequestURL
, "", "alterlist", list
);
947 var clear_reload
= 0;
948 function clearList(list
){
950 RequestURL
= "alterlist.php?user=<?php echo $username?>&md5pass=<?php echo $password?>";
951 RequestURL
+= "&list="+list
+"&clear=1";
952 makeRequestMylist(RequestURL
, "", "alterlist", list
);
956 function alterLink(id
, action
, list
){
958 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>";
959 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>";
960 document
.getElementById(list
+ "_" + id
).innerHTML
= HTML
;
964 function mylist_response(output
){
966 var list
= workinglist
;
967 output
= output
.toString();
969 if (output
.charAt(0) == 'q'){
971 output
= output
.substring(1);
972 listsize
= output
* 1;
973 if(list
=="hotlist") document
.getElementById('hlsize').firstChild
.nodeValue
= listsize
;
974 document
.getElementById(list
+"_headercount").innerHTML
= listsize
+ " Genes";
975 if(listsize
==0 && clear_reload
==1) window
.location
.reload();