adding a semicolon... yay!
[cxgn-jslib.git] / CXGN / Fasta.js
blob23deac5331046b9bb2c6d244b79e233e8371733c
1 /**
3 =head1 Fasta.js
5 AJAX object for building an AGI list and getting a Fasta file back, in XML format within <fasta> tags
8 =head1 AUTHOR
10 Chris Carpita <csc32@cornell.edu>
12 =cut
16 JSAN.use("CXGN.Request");
18 //Hotlist is defined as a single object instead of a class. We can't have more than one!
19 var Fasta = window.Fasta || {};
20 Fasta = { //buttonId: id of the clicked button, for changing the button
21         _agis: new Object,
22         _agi_list: "",
23         addAgi: function (agi) {
24                 Fasta._agis[agi] = 1;   
25         },
26         removeAgi: function (agi) {
27                 Fasta._agis[agi] = 0;
28         },
29         _build_string: function () {
30                 var new_string = '';
31                 var i = 0;
32                 for (var agi in Fasta._agis){
33                         if(Fasta._agis[agi] == 1){
34                                 if(i>0) new_string += "::";
35                                 new_string += agi;
36                                 i++;
37                         }
38                 }
39                 Fasta._agi_list = new_string;
40         },
41         request: function (type){
42                 var req = new Request();
43                 if(req.isValid()){
44                         Fasta._build_string();
45                         var param = "agi_list=" + Fasta._agi_list + "&type=" + type;
46                         req.send("/scraps/fasta.pl", param, "POST");
47                 }
48         },
49         _response: function(doc) {
50                 doc.normalize();
51                 var fasta = doc.getElementsByTagName("fasta")[0].firstChild.nodeValue;
52                 var type = doc.getElementsByTagName("type")[0].firstChild.nodeValue;
53                 document.getElementById("hotlist_fasta_textarea").value = fasta;
54                 document.getElementById("hotlist_fasta_content").style.display = "block";
55                 
56         }