Projects.js
[gitlive] / Projects.js
1
2 XObject = imports.XObject.XObject;
3 XMLHttpRequest = imports.XMLHttpRequest.XMLHttpRequest;
4 Netrc = imports.Netrc.Netrc;
5 Date = imports.Date.Date;
6 /**
7  *
8  * Projects - 
9  *
10  *
11  *
12  */
13
14 Projects = {
15     
16     list : [],
17     
18      
19     fetch: function(repo, callback)
20     {
21         // have we got the status in the last 15 mins..
22         // we should not need to get it again... - it's probably not changed.
23         
24         if (this.list.length) {
25             return this.list;
26         }
27         
28         _this = this;
29         // do the request to get the task..
30         var r = new XMLHttpRequest({
31             onreadystatechange : function() {
32                 print("Got result.");
33                 if (this.status != 4) {
34                     return;
35                 }
36                 
37                   
38                 var res = JSON.parse(this.responseText);
39                 
40                 //print(JSON.stringify(res,null,4))
41                 //print([ res.success , res.data.length ]);
42                 if (!res.success || !res.data.length)  {
43                     print("NO tasks returned");
44                     callback([]);
45                     return;
46                 }
47                 
48                 //print("Current task:" + JSON.stringify(_this.curTask,null,4));
49                 callback(res.data);
50             }
51             
52         });
53         var netrc  = Netrc.forHost('git.roojs.com');
54         
55         r.open('GET',
56                "http://roojs.com/admin.php/Roo/Projects"
57                ,true, netrc.login, netrc.password  );
58         // print("Getting current task: "  +  "http://roojs.com/admin.php/Roo/mtrack_ticket?repo_shortname=" + repo.name);        
59         r.send();
60         
61     },
62     
63     
64     
65       
66     
67 };
68
69
70
71
72  
73
74
75
76
77
78
79
80 //-------------- testing
81 /*
82 Gtk = imports.gi.Gtk;
83 Gtk.init(Seed.argv);
84 Tasks.notify( { repo : imports.Scm.Repo.Repo.get('gitlive') } );
85 Gtk.main();
86 */