From 86596274105d1653f113f8242d24d938d1ed1ff3 Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Wed, 17 Jan 2018 10:33:22 +0100 Subject: [PATCH] fix jshint --- www/js/controllers/network-controllers.js | 3 +- www/js/platform.js | 7 ++-- www/js/services/bma-services.js | 47 +++++++++++------------ 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/www/js/controllers/network-controllers.js b/www/js/controllers/network-controllers.js index 6f6c2e831..a381b0965 100644 --- a/www/js/controllers/network-controllers.js +++ b/www/js/controllers/network-controllers.js @@ -296,6 +296,7 @@ function NetworkLookupController($scope, $state, $location, $ionicPopover, $win }; $scope.showWs2pPopover = function($event, peer) { + $event.stopPropagation(); return $translate('NETWORK.VIEW.PRIVATE_ACCESS') .then(function(privateAccessMessage) { @@ -320,8 +321,6 @@ function NetworkLookupController($scope, $state, $location, $ionicPopover, $win } }); }); - - $event.stopPropagation(); }; diff --git a/www/js/platform.js b/www/js/platform.js index d9da34804..2271ad05d 100644 --- a/www/js/platform.js +++ b/www/js/platform.js @@ -167,7 +167,6 @@ angular.module('cesium.platform', ['ngIdle', 'cesium.config', 'cesium.services'] if (latestRelease) { return csHttp.get(latestRelease.host, latestRelease.protocol == 'https:' ? 443 : latestRelease.port, "/" + latestRelease.pathname)() .then(function (json) { - //console.debug(json); if (json && json.name && json.tag_name && json.html_url) { return { version: json.name, @@ -178,7 +177,7 @@ angular.module('cesium.platform', ['ngIdle', 'cesium.config', 'cesium.services'] }) .catch(function(err) { // silent (just log it) - console.error('[platform] Failed to get latest version', err); + console.error('[platform] Failed to get Cesium latest version', err); }) ; } @@ -349,11 +348,11 @@ angular.module('cesium.platform', ['ngIdle', 'cesium.config', 'cesium.services'] csPlatform.version.latest() .then(function(release) { if (release && release.isNewer) { - console.info('[app] New release detected: {0}'.format(release.version)); + console.info('[app] New release detected [{0}]'.format(release.version)); $rootScope.newRelease = release; } else { - console.info('[app] Already use latest release {0}'.format(csConfig.version)); + console.info('[app] Current version [{0}] is the latest release'.format(csConfig.version)); } }); diff --git a/www/js/services/bma-services.js b/www/js/services/bma-services.js index 733d215f2..72f037637 100644 --- a/www/js/services/bma-services.js +++ b/www/js/services/bma-services.js @@ -66,6 +66,14 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. that.started = false; that.init = init; + // Allow to force SSL connection with port different from 443 + that.forceUseSsl = (csConfig.httpsMode === 'true' || csConfig.httpsMode === true || csConfig.httpsMode === 'force') || + ($window.location && $window.location.protocol === 'https:') ? true : false; + if (that.forceUseSsl) { + console.debug('[BMA] Enable SSL (forced by config or detected in URL)'); + } + + if (host) { init(host, port, useSsl, useCache); } @@ -76,18 +84,12 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. that.alive = false; that.cache = _emptyCache(); - // Allow to force SSL connection with port different from 443 - var forceUseSsl = (csConfig.httpsMode === 'true' || csConfig.httpsMode === true || csConfig.httpsMode === 'force') || - ($window.location && $window.location.protocol === 'https:') ? true : false; - if (forceUseSsl) { - console.debug('[BMA] Enable SSL (forced by config or detected in URL)'); - } // Use settings as default, if exists if (csSettings.data && csSettings.data.node) { host = host || csSettings.data.node.host; port = port || csSettings.data.node.port; - useSsl = angular.isDefined(useSsl) ? useSsl : (port == 443 || csSettings.data.node.useSsl || forceUseSsl); + useSsl = angular.isDefined(useSsl) ? useSsl : (port == 443 || csSettings.data.node.useSsl || that.forceUseSsl); useCache = angular.isDefined(useCache) ? useCache : true; } @@ -96,7 +98,7 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. } that.host = host; that.port = port || 80; - that.useSsl = angular.isDefined(useSsl) ? useSsl : (that.port == 443 || forceUseSsl); + that.useSsl = angular.isDefined(useSsl) ? useSsl : (that.port == 443 || that.forceUseSsl); that.useCache = angular.isDefined(useCache) ? useCache : false; that.server = csHttp.getServer(host, port); that.url = csHttp.getUrl(host, port, ''/*path*/, useSsl); @@ -822,22 +824,19 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. }); }; - // raw get latest release - var latestRelease = csSettings.data.duniterLatestReleaseUrl && csHttp.uri.parse(csSettings.data.duniterLatestReleaseUrl); - if (latestRelease) { - var useSsl = latestRelease.protocol == 'https:'; - exports.raw.getLatestRelease = csHttp.getWithCache(latestRelease.host, - latestRelease.port, - "/" + latestRelease.pathname, - useSsl, + // Define get latest release (or fake function is no URL defined) + var duniterLatestReleaseUrl = csSettings.data.duniterLatestReleaseUrl && csHttp.uri.parse(csSettings.data.duniterLatestReleaseUrl); + exports.raw.getLatestRelease = duniterLatestReleaseUrl ? + csHttp.getWithCache(duniterLatestReleaseUrl.host, + duniterLatestReleaseUrl.port, + "/" + duniterLatestReleaseUrl.pathname, + /*useSsl*/ (duniterLatestReleaseUrl.port == 443 || duniterLatestReleaseUrl.protocol == 'https:' || that.forceUseSsl), csHttp.cache.LONG - ); - } - else { - exports.raw.getLatestRelease = function() { + ) : + // No URL define: use a fake function + function() { return $q.when(); - } - } + }; exports.version.latest = function() { return exports.raw.getLatestRelease() @@ -858,9 +857,9 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. }) .catch(function(err) { // silent (just log it) - console.error('[platform] Failed to get latest version', err); + console.error('[BMA] Failed to get Duniter latest version', err); }); - } + }; exports.websocket = { block: ws('/ws/block'), -- GitLab