Statistics
| Branch: | Tag: | Revision:

root / cloudcms / static / cloudcms / js / client-downloads.js @ 565d9620

History | View | Annotate | Download (1.9 kB)

1
var ClientDownloads = function( wrapper, clients, cl_default) {
2
    this.el = $(wrapper);
3
    this.clients = clients; 
4
    this.cl_default = cl_default;
5
}
6

    
7
ClientDownloads.prototype.update = function() {
8
    
9
     
10
    var current_os = BrowserDetect.OS;
11
    //var current_os = "linux";
12
    var current_client = _.filter(this.clients, function(el){return el.os == current_os});
13
   
14
    if (_.isEmpty(current_client)){
15
            current_os = this.cl_default;
16
            var current_client = _.filter(this.clients, function(el){return el.os == current_os})[0];
17
            
18
   
19
    } else {
20
            current_client = current_client[0];
21
    }
22
    this.el.find("#os").html(current_client.os);
23
    this.el.find(".btn_01").attr('href',current_client.link);
24
    
25
    var new_list = _.filter(this.clients, function(el){return el.os != current_os});
26
    
27
    first = new_list.shift();
28
    popped = new_list.pop();
29
    
30
    this.el.find(".other-clients").append("<a href='"+first.link+"'>"+first.os+"</a>"); 
31
    var self = this;
32
    _.each(new_list, function(client) {
33
            self.el.find(".other-clients").append(", <a href='"+client.link+"'>"+client.os+"</a>")
34
    })
35
    this.el.find(".other-clients").append(" and <a href='"+popped.link+"'>"+popped.os+"</a>.");
36
}
37

    
38
 
39

    
40

    
41

    
42
/* kpap
43

44

45
var ClientDownloads = function(wrapper, clients) {
46
    this.el = $(wrapper);
47
    this.clients = clients;
48
    console.log("test");
49
    console.log(this.clients);
50
    console.log("end test")
51
}
52

53
ClientDownloads.prototype.update = function() {
54
    console.log("updating clients");
55
    
56
    var current_os = "linux";
57
    var current_client = _.filter(this.clients, function(el){return el.os == current_os})[0];
58
    this.el.find(".current-os-link").html(current_client.os);
59
    
60
    var self = this;
61
    _.each(this.clients, function(client) {
62
            self.el.find(".other-clients").append("<span>"+client.os+"</span>")
63
    })
64
    console.log(current_client);
65
}*/
66