diff --git a/www/js/services/http-services.js b/www/js/services/http-services.js index 0d4e08b39085439512c7919e199eb092c77345d0..06ea8d0c8a4dab73284755acd5311a0cf0e91483 100644 --- a/www/js/services/http-services.js +++ b/www/js/services/http-services.js @@ -8,7 +8,12 @@ angular.module('cesium.http.services', ['cesium.cache.services']) var sockets = [], defaultCachePrefix = 'csHttp-', - allCachePrefixes = {}; + allCachePrefixes = {}, + regexp = { + POSITIVE_INTEGER: /^\d+$/, + VERSION_PART_REGEXP: /^[0-9]+|alpha[0-9]+|beta[0-9]+|rc[0-9]+|[0-9]+-SNAPSHOT$/ + } + ; if (!timeout) { timeout=4000; // default @@ -335,6 +340,7 @@ angular.module('cesium.http.services', ['cesium.cache.services']) uri = 'http://' + path; } + // Use a <a> element to parse var parser = document.createElement('a'); parser.href = uri; @@ -389,13 +395,13 @@ angular.module('cesium.http.services', ['cesium.cache.services']) var parts = parseUri(uri); if (!parts.protocol && options.type) { - parts.protocol = (options.type == 'email') ? 'mailto:' : - ((options.type == 'phone') ? 'tel:' : ''); + parts.protocol = (options.type === 'email') ? 'mailto:' : + ((options.type === 'phone') ? 'tel:' : ''); uri = parts.protocol + uri; } // On desktop, open into external tool - if (parts.protocol == 'mailto:' && Device.isDesktop()) { + if (parts.protocol === 'mailto:' && Device.isDesktop()) { try { nw.Shell.openExternal(uri); return; @@ -405,10 +411,10 @@ angular.module('cesium.http.services', ['cesium.cache.services']) } } - // Check if device is enable, on special tel: or mailto: protocole - var validProtocol = (parts.protocol == 'mailto:' || parts.protocol == 'tel:') && Device.enable; + // Check if device is enable, on special tel: or mailto: protocol + var validProtocol = (Device.enable && (parts.protocol === 'mailto:' || parts.protocol === 'tel:')); if (!validProtocol) { - if (options.onError && typeof options.onError == 'function') { + if (options.onError && typeof options.onError === 'function') { options.onError(uri); } return; @@ -491,11 +497,15 @@ angular.module('cesium.http.services', ['cesium.cache.services']) // First, validate both numbers are true version numbers function validateParts(parts) { - for (var i = 0; i < parts.length; ++i) { - if (!isPositiveInteger(parts[i])) { - return false; - } - parts[i] = parseInt(parts[i]); + for (var i = 0; i < parts.length; i++) { + var isNumber = regexp.POSITIVE_INTEGER.test(parts[i]); + // First part MUST be an integer + if (i === 0 && !isNumber) return false; + // If not integer, should be 'alpha', 'beta', etc. + if (!isNumber && !regexp.VERSION_PART_REGEXP.test(parts[i])) return false; + + // Convert string to int (need by compare operators) + if (isNumber) parts[i] = parseInt(parts[i]); } return true; } diff --git a/www/plugins/es/js/controllers/common-controllers.js b/www/plugins/es/js/controllers/common-controllers.js index e010969c59721dedb3d5caddc56dad9dcea33fb0..a1020d6cadcb1c8cd3da3a88100c1866e0a6ef9b 100644 --- a/www/plugins/es/js/controllers/common-controllers.js +++ b/www/plugins/es/js/controllers/common-controllers.js @@ -395,9 +395,8 @@ function ESSocialsEditController($scope, $focus, $filter, UIUtils, SocialUtils) $focus('socialUrl'); }; - $scope.reorderSocialNetwork = function(social, fromIndex, toIndex) { - if (!social || fromIndex == toIndex) return; // no changes + if (!social || fromIndex === toIndex) return; // no changes $scope.formData.socials.splice(fromIndex, 1); $scope.formData.socials.splice(toIndex, 0, social); }; @@ -416,7 +415,6 @@ function ESSocialsViewController($scope) { }); }; - $scope.filterFn = function(social) { return !social.recipient || social.valid; }; @@ -532,17 +530,17 @@ function ESPositionEditController($scope, csConfig, esGeo, ModalUtils) { }); }; - $scope.onCityChanged = function() { - if ($scope.loading) return; - if ($scope.formPosition.enable) { - if ($scope.formData.geoPoint) { - // Invalidate the position - $scope.formData.geoPoint.lat = undefined; - $scope.formData.geoPoint.lon = undefined; - } - return $scope.tryToLocalize(); + $scope.onCityChanged = function() { + if ($scope.loading) return; + if ($scope.formPosition.enable) { + if ($scope.formData.geoPoint) { + // Invalidate the position + $scope.formData.geoPoint.lat = undefined; + $scope.formData.geoPoint.lon = undefined; } - }; + return $scope.tryToLocalize(); + } + }; $scope.onUseGeopointChanged = function() { if ($scope.loading) return; @@ -623,7 +621,7 @@ function ESPositionEditController($scope, csConfig, esGeo, ModalUtils) { $scope.searchModalOpened = false; $scope.updateGeoPoint(res); }) - .catch(function() { + .catch(function(err) { console.error(err); $scope.searchModalOpened = false; }); @@ -737,7 +735,6 @@ function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig, // The default country used for address localisation var defaultCountry = csConfig.plugins && csConfig.plugins.es && csConfig.plugins.es.defaultCountry; - //$scope.smallscreen = angular.isDefined($scope.smallscreen) ? $scope.smallscreen : UIUtils.screen.isSmall(); var loadingPosition = false; var minLength = 3; @@ -800,7 +797,7 @@ function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig, } _.forEach($scope.locations||[], function(item, index) { - item.selected = (index == $scope.selectLocationIndex); + item.selected = (index === $scope.selectLocationIndex); }); // TODO: scroll to item ? @@ -828,7 +825,7 @@ function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig, // Execute the given query return esGeo.point.searchByAddress(text) .then(function(res) { - if ($scope.requestId != requestId) return; // Skip apply if not same request: + if ($scope.requestId !== requestId) return; // Skip apply if not same request: loadingPosition = false; $scope.locations = res||[]; diff --git a/www/plugins/es/js/controllers/like-controllers.js b/www/plugins/es/js/controllers/like-controllers.js index b67a1f358bb8c8c88df5eb13d83aaacafe841ea7..f2ff5154b3bb1fbb101abde60cdf8dd0575f683a 100644 --- a/www/plugins/es/js/controllers/like-controllers.js +++ b/www/plugins/es/js/controllers/like-controllers.js @@ -297,7 +297,6 @@ function ESLikesController($scope, $q, $timeout, $translate, $ionicPopup, UIUtil options.kind = 'ABUSE'; return $scope.toggleLike(event, options) .then(function() { - console.log('BEFORE display toast'); UIUtils.toast.show('COMMON.REPORT_ABUSE.CONFIRM.SENT'); }); }; diff --git a/www/plugins/es/js/controllers/profile-controllers.js b/www/plugins/es/js/controllers/profile-controllers.js index c2d4f92013db2a71951199e6793edec4ed0f18ed..3eacd820f8441327d04ce7438f6d09eeb01618a1 100644 --- a/www/plugins/es/js/controllers/profile-controllers.js +++ b/www/plugins/es/js/controllers/profile-controllers.js @@ -79,7 +79,7 @@ function ESViewEditProfileController($scope, $q, $timeout, $state, $focus, $tran }) .then($scope.load) .catch(function(err){ - if (err == 'CANCELLED') { + if (err === 'CANCELLED') { UIUtils.loading.hide(10); $scope.cancel(); return; @@ -191,6 +191,7 @@ function ESViewEditProfileController($scope, $q, $timeout, $state, $focus, $tran } if (!hasWaitDebounce) { + console.debug('[ES] [profile] Waiting debounce end, before saving...'); $scope.saving = true; return $timeout(function() { return $scope.save(silent, true); diff --git a/www/plugins/es/templates/common/edit_socials.html b/www/plugins/es/templates/common/edit_socials.html index 128e17f6aabed4a626d97d1634272b02e9c08f11..bed22c7da2143a2b41f1c87d8915f45a99b9efb7 100644 --- a/www/plugins/es/templates/common/edit_socials.html +++ b/www/plugins/es/templates/common/edit_socials.html @@ -21,7 +21,7 @@ ng-repeat="social in formData.socials | filter:filterFn track by social.url" id="social-{{social.url|formatSlug}}"> <i class="icon ion-social-{{social.type}}" - ng-class="{'ion-bookmark': social.type == 'other', 'ion-link': social.type == 'web', 'ion-email': social.type == 'email', 'ion-iphone': social.type == 'phone'}"></i> + ng-class="{'ion-bookmark': social.type === 'other', 'ion-link': social.type === 'web', 'ion-email': social.type === 'email', 'ion-iphone': social.type === 'phone'}"></i> <p ng-if="social.type && social.type != 'web'"> {{social.type}} <i class="ion-locked" ng-if="social.recipient"></i>