Fix #5662 - Gitlive - create a tracking branch
[gitlive] / old_seed_version / 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     // called on startup..??
19     // clear list, and call again to refresh..
20     
21     fetch: function(callback)
22     {
23         // have we got the status in the last 15 mins..
24         // we should not need to get it again... - it's probably not changed.
25         
26         if (this.list.length) {
27             callback( this.list);
28         }
29         
30         _this = this;
31         // do the request to get the task..
32         var r = new XMLHttpRequest({
33             onreadystatechange : function() {
34                 print("Got result.");
35                 if (this.status != 4) {
36                     return;
37                 }
38                 
39                   
40                 var res = JSON.parse(this.responseText);
41                 
42                 //print(JSON.stringify(res,null,4))
43                 //print([ res.success , res.data.length ]);
44                 if (!res.success || !res.data.length)  {
45                     print("NO tasks returned");
46                     Projects.list = []; //res.data;
47                     return;
48                 }
49                 Projects.list = res.data;
50                 
51                 //print("Current task:" + JSON.stringify(_this.curTask,null,4));
52                 callback(res.data);
53             }
54             
55         });
56         var netrc  = Netrc.forHost('git.roojs.com');
57         
58         r.open('GET',
59                "http://roojs.com/admin.php/Roo/Projects?sort=code&dir=ASC&active=1&limit=999"
60                ,true, netrc.login, netrc.password  );
61         // print("Getting current task: "  +  "http://roojs.com/admin.php/Roo/mtrack_ticket?repo_shortname=" + repo.name);        
62         r.send();
63         
64     },
65     
66     
67     
68       
69     
70 };
71
72
73
74  
75 //-------------- testing
76 /*
77 Gtk = imports.gi.Gtk;
78 Gtk.init(Seed.argv);
79 Projects.fetch( function(list) { print(JSON.stringify(list,null,4)); } );
80 Gtk.main();
81  */