From 4b05574606d14cc50e16097a330e01242a1fc659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Tue, 29 Nov 2016 17:33:08 +0100 Subject: [PATCH] Fix export and version comparison MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- .../addressBook/addressBook_controller.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/js/components/addressBook/addressBook_controller.js b/js/components/addressBook/addressBook_controller.js index 636f09e92..69aa63f90 100644 --- a/js/components/addressBook/addressBook_controller.js +++ b/js/components/addressBook/addressBook_controller.js @@ -4,8 +4,22 @@ angular.module('contactsApp') ctrl.showUrl = false; /* globals oc_config */ + + function compareVersion(version1, version2) { + for(var i = 0; i < Math.max(version1.length, version2.length); i++) { + a = version1[i] || 0; + b = version2[i] || 0; + if(Number(a) < Number(b)) { + return true + } + if(version1[i] !== version2[i]) { + return false + } + } + return false; + } /* eslint-disable camelcase */ - ctrl.canExport = oc_config.version.split('.') >= [9, 0, 2, 0]; + ctrl.canExport = compareVersion([9, 0, 2, 0], oc_config.version.split('.')); /* eslint-enable camelcase */ ctrl.toggleShowUrl = function() {