Statistics
| Branch: | Tag: | Revision:

root / cloudcms / static / cloudcms / js / client-downloads.js @ 7e5c8125

History | View | Annotate | Download (1.8 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_client = _.filter(this.clients, function(el){return el.os == current_os});
12
   
13
    if (_.isEmpty(current_client)){
14
            current_os = this.cl_default;
15
            var current_client = _.filter(this.clients, function(el){return el.os == current_os})[0];
16
            
17
   
18
    } else {
19
            current_client = current_client[0];
20
    }
21
    this.el.find("#os").html('for '+current_client.os);
22
    this.el.find(".btn_01").attr('href',current_client.link);
23
    
24
    var new_list = _.filter(this.clients, function(el){return el.os != current_os});
25
    
26
    first = new_list.shift();
27
    popped = new_list.pop();
28
    
29
    this.el.find(".other-clients").append("<a href='"+first.link+"'>"+first.os+"</a>"); 
30
    var self = this;
31
    _.each(new_list, function(client) {
32
            self.el.find(".other-clients").append(", <a href='"+client.link+"'>"+client.os+"</a>")
33
    })
34
    this.el.find(".other-clients").append(" and <a href='"+popped.link+"'>"+popped.os+"</a>.");
35
}
36

    
37
 
38

    
39

    
40

    
41
/* kpap
42

43

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

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