From 565d9620972c0ef04bdbb37f37cc44264896958c Mon Sep 17 00:00:00 2001 From: Olga Brani Date: Tue, 15 May 2012 14:32:08 +0300 Subject: [PATCH] Client downloads --- cloudcms/static/cloudcms/js/client-downloads.js | 59 +++++++++++++++++++++- cloudcms/static/cloudcms/js/os.js | 9 ++-- cloudcms/templates/content/client_downloads.html | 17 +++++-- 3 files changed, 75 insertions(+), 10 deletions(-) diff --git a/cloudcms/static/cloudcms/js/client-downloads.js b/cloudcms/static/cloudcms/js/client-downloads.js index 578d884..15234c1 100644 --- a/cloudcms/static/cloudcms/js/client-downloads.js +++ b/cloudcms/static/cloudcms/js/client-downloads.js @@ -1,9 +1,66 @@ +var ClientDownloads = function( wrapper, clients, cl_default) { + this.el = $(wrapper); + this.clients = clients; + this.cl_default = cl_default; +} + +ClientDownloads.prototype.update = function() { + + + var current_os = BrowserDetect.OS; + //var current_os = "linux"; + var current_client = _.filter(this.clients, function(el){return el.os == current_os}); + + if (_.isEmpty(current_client)){ + current_os = this.cl_default; + var current_client = _.filter(this.clients, function(el){return el.os == current_os})[0]; + + + } else { + current_client = current_client[0]; + } + this.el.find("#os").html(current_client.os); + this.el.find(".btn_01").attr('href',current_client.link); + + var new_list = _.filter(this.clients, function(el){return el.os != current_os}); + + first = new_list.shift(); + popped = new_list.pop(); + + this.el.find(".other-clients").append(""+first.os+""); + var self = this; + _.each(new_list, function(client) { + self.el.find(".other-clients").append(", "+client.os+"") + }) + this.el.find(".other-clients").append(" and "+popped.os+"."); +} + + + + + +/* kpap + + var ClientDownloads = function(wrapper, clients) { this.el = $(wrapper); this.clients = clients; + console.log("test"); + console.log(this.clients); + console.log("end test") } ClientDownloads.prototype.update = function() { console.log("updating clients"); -} + + var current_os = "linux"; + var current_client = _.filter(this.clients, function(el){return el.os == current_os})[0]; + this.el.find(".current-os-link").html(current_client.os); + + var self = this; + _.each(this.clients, function(client) { + self.el.find(".other-clients").append(""+client.os+"") + }) + console.log(current_client); +}*/ diff --git a/cloudcms/static/cloudcms/js/os.js b/cloudcms/static/cloudcms/js/os.js index 8dfaba7..ee556a8 100644 --- a/cloudcms/static/cloudcms/js/os.js +++ b/cloudcms/static/cloudcms/js/os.js @@ -1,3 +1,4 @@ +//http://www.quirksmode.org/js/detect.html var BrowserDetect = { init: function () { this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; @@ -94,22 +95,22 @@ var BrowserDetect = { { string: navigator.platform, subString: "Win", - identity: "Windows" + identity: "windows" }, { string: navigator.platform, subString: "Mac", - identity: "Mac" + identity: "MacOS" }, { string: navigator.userAgent, subString: "iPhone", - identity: "iPhone/iPod" + identity: "iPhone" }, { string: navigator.platform, subString: "Linux", - identity: "Linux" + identity: "linux" } ] diff --git a/cloudcms/templates/content/client_downloads.html b/cloudcms/templates/content/client_downloads.html index fa376b4..96b0d34 100644 --- a/cloudcms/templates/content/client_downloads.html +++ b/cloudcms/templates/content/client_downloads.html @@ -1,14 +1,21 @@
- + + DOWNLOAD THE PITHOS CLIENT +   + +

Also available for

-- 1.7.10.4