diff --git a/src/js/controllers/copayers.js b/src/js/controllers/copayers.js index cc4a97c69..ab8e5e47a 100644 --- a/src/js/controllers/copayers.js +++ b/src/js/controllers/copayers.js @@ -1,10 +1,10 @@ 'use strict'; angular.module('copayApp.controllers').controller('copayersController', - function($scope, $log, $timeout, $stateParams, $state, $rootScope, $ionicHistory, $window, lodash, profileService, walletService, popupService, platformInfo, gettextCatalog, ongoingProcess) { + function($scope, $log, $timeout, $stateParams, $state, $rootScope, $ionicHistory, appConfigService, lodash, profileService, walletService, popupService, platformInfo, gettextCatalog, ongoingProcess) { - var appName = $window.appConfig.userVisibleName; - var appUrl = $window.appConfig.url; + var appName = appConfigService.userVisibleName; + var appUrl = appConfigService.url; $scope.isCordova = platformInfo.isCordova; $scope.$on("$ionicView.beforeEnter", function(event, data) { diff --git a/src/js/controllers/create.js b/src/js/controllers/create.js index ed567bf0d..a8f96c27b 100644 --- a/src/js/controllers/create.js +++ b/src/js/controllers/create.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('createController', - function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, storageService, popupService, $window) { + function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, storageService, popupService, appConfigService) { var isChromeApp = platformInfo.isChromeApp; var isCordova = platformInfo.isCordova; @@ -80,7 +80,7 @@ angular.module('copayApp.controllers').controller('createController', */ - if ($window.appConfig.name == 'copay') { + if (appConfigService.name == 'copay') { if (n > 1 && isChromeApp) { seedOptions.push({ id: 'ledger', diff --git a/src/js/controllers/export.js b/src/js/controllers/export.js index bec190995..2203d2df7 100644 --- a/src/js/controllers/export.js +++ b/src/js/controllers/export.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('exportController', - function($scope, $timeout, $log, $ionicHistory, $ionicScrollDelegate, backupService, walletService, storageService, profileService, platformInfo, gettextCatalog, $state, $stateParams, popupService, $window) { + function($scope, $timeout, $log, $ionicHistory, $ionicScrollDelegate, backupService, walletService, storageService, profileService, platformInfo, gettextCatalog, $state, $stateParams, popupService, appConfigService) { var wallet = profileService.getWallet($stateParams.walletId); $scope.showAdvChange = function() { @@ -191,7 +191,7 @@ angular.module('copayApp.controllers').controller('exportController', if ($scope.formData.noSignEnabled) name = name + '(No Private Key)'; - var subject = $window.appConfig.nameCase + ' Wallet Backup: ' + name; + var subject = appConfigService.nameCase + ' Wallet Backup: ' + name; var body = 'Here is the encrypted backup of the wallet ' + name + ': \n\n' + ew + '\n\n To import this backup, copy all text between {...}, including the symbols {}'; window.plugins.socialsharing.shareViaEmail( body, diff --git a/src/js/controllers/headController.js b/src/js/controllers/headController.js index a33c2d8be..d65318799 100644 --- a/src/js/controllers/headController.js +++ b/src/js/controllers/headController.js @@ -1,7 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('headController', - function($scope, $window, $log) { - $scope.appConfig = $window.appConfig; - $log.info('Running head controller:' + $window.appConfig.nameCase) - }); +angular.module('copayApp.controllers').controller('headController', function($scope, appConfigService, $log) { + $scope.appConfig = appConfigService; + $log.info('Running head controller:' + appConfigService.nameCase) +}); diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index 9c8ae8873..e40858bed 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('importController', - function($scope, $timeout, $log, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog, $window) { + function($scope, $timeout, $log, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog, appConfigService) { var isChromeApp = platformInfo.isChromeApp; var isDevel = platformInfo.isDevel; @@ -17,7 +17,7 @@ angular.module('copayApp.controllers').controller('importController', $scope.formData.derivationPath = derivationPathHelper.default; $scope.formData.account = 1; $scope.importErr = false; - $scope.showHardwareWallet = $window.appConfig.name == 'copay'; + $scope.showHardwareWallet = appConfigService.name == 'copay'; if ($stateParams.code) $scope.processWalletInfo($stateParams.code); diff --git a/src/js/controllers/join.js b/src/js/controllers/join.js index 8dbf6cffb..6c9d4a58a 100644 --- a/src/js/controllers/join.js +++ b/src/js/controllers/join.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('joinController', - function($scope, $rootScope, $timeout, $state, $ionicHistory, $ionicScrollDelegate, profileService, configService, storageService, applicationService, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService, $window) { + function($scope, $rootScope, $timeout, $state, $ionicHistory, $ionicScrollDelegate, profileService, configService, storageService, applicationService, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService, appConfigService) { var isChromeApp = platformInfo.isChromeApp; var isDevel = platformInfo.isDevel; @@ -63,7 +63,7 @@ angular.module('copayApp.controllers').controller('joinController', */ - if ($window.appConfig.name == 'copay') { + if (appConfigService.name == 'copay') { if (isChromeApp) { self.seedOptions.push({ id: 'ledger', diff --git a/src/js/controllers/onboarding/terms.js b/src/js/controllers/onboarding/terms.js index 7cab71203..5ef88733a 100644 --- a/src/js/controllers/onboarding/terms.js +++ b/src/js/controllers/onboarding/terms.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('termsController', function($scope, $log, $state, $window, uxLanguage, profileService, externalLinkService, gettextCatalog) { +angular.module('copayApp.controllers').controller('termsController', function($scope, $log, $state, appConfigService, uxLanguage, profileService, externalLinkService, gettextCatalog) { $scope.lang = uxLanguage.currentLanguage; $scope.confirm = function() { @@ -15,7 +15,7 @@ angular.module('copayApp.controllers').controller('termsController', function($s }; $scope.openExternalLink = function() { - var url = $window.appConfig.disclaimerUrl; + var url = appConfigService.disclaimerUrl; var optIn = true; var title = gettextCatalog.getString('View Terms of Service'); var message = gettextCatalog.getString('The official English Terms of Service are available on the BitPay website. Would you like to view them?'); diff --git a/src/js/controllers/preferencesAbout.js b/src/js/controllers/preferencesAbout.js index 4b71e5c7e..91a49a0d4 100644 --- a/src/js/controllers/preferencesAbout.js +++ b/src/js/controllers/preferencesAbout.js @@ -1,14 +1,14 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesAbout', - function($scope, $window, gettextCatalog, externalLinkService) { + function($scope, $window, appConfigService, gettextCatalog, externalLinkService) { - $scope.title = gettextCatalog.getString('About') + ' ' + $window.appConfig.nameCase; + $scope.title = gettextCatalog.getString('About') + ' ' + appConfigService.nameCase; $scope.version = $window.version; $scope.commitHash = $window.commitHash; $scope.openExternalLink = function() { - var url = 'https://github.com/bitpay/' + $window.appConfig.gitHubRepoName + '/tree/' + $window.commitHash + ''; + var url = 'https://github.com/bitpay/' + appConfigService.gitHubRepoName + '/tree/' + $window.commitHash + ''; var optIn = true; var title = gettextCatalog.getString('Open GitHub Project'); var message = gettextCatalog.getString('You can see the latest developments and contribute to this open source app by visiting our project on GitHub.'); diff --git a/src/js/controllers/preferencesBwsUrl.js b/src/js/controllers/preferencesBwsUrl.js index 638219ae4..45752ee01 100644 --- a/src/js/controllers/preferencesBwsUrl.js +++ b/src/js/controllers/preferencesBwsUrl.js @@ -1,14 +1,14 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesBwsUrlController', - function($scope, $log, $stateParams, configService, applicationService, profileService, storageService, $window) { + function($scope, $log, $stateParams, configService, applicationService, profileService, storageService, appConfigService) { $scope.success = null; var wallet = profileService.getWallet($stateParams.walletId); var walletId = wallet.credentials.walletId; var defaults = configService.getDefaults(); var config = configService.getSync(); - $scope.appName = $window.appConfig.nameCase; + $scope.appName = appConfigService.nameCase; $scope.bwsurl = { value: (config.bwsFor && config.bwsFor[walletId]) || defaults.bws.url }; diff --git a/src/js/controllers/preferencesHistory.js b/src/js/controllers/preferencesHistory.js index 06167fb4f..32f4375cc 100644 --- a/src/js/controllers/preferencesHistory.js +++ b/src/js/controllers/preferencesHistory.js @@ -1,11 +1,11 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesHistory', - function($scope, $log, $stateParams, $timeout, $state, $ionicHistory, storageService, platformInfo, profileService, lodash, $window) { + function($scope, $log, $stateParams, $timeout, $state, $ionicHistory, storageService, platformInfo, profileService, lodash, appConfigService) { $scope.wallet = profileService.getWallet($stateParams.walletId); $scope.csvReady = false; $scope.isCordova = platformInfo.isCordova; - $scope.appName = $window.appConfig.nameCase; + $scope.appName = appConfigService.nameCase; $scope.csvHistory = function(cb) { var allTxs = []; diff --git a/src/js/controllers/preferencesNotifications.js b/src/js/controllers/preferencesNotifications.js index f273bc403..219ad82cd 100644 --- a/src/js/controllers/preferencesNotifications.js +++ b/src/js/controllers/preferencesNotifications.js @@ -1,9 +1,9 @@ 'use strict'; -angular.module('copayApp.controllers').controller('preferencesNotificationsController', function($scope, $log, $timeout, $window, lodash, configService, platformInfo, pushNotificationsService, profileService, emailService) { +angular.module('copayApp.controllers').controller('preferencesNotificationsController', function($scope, $log, $timeout, appConfigService, lodash, configService, platformInfo, pushNotificationsService, profileService, emailService) { var updateConfig = function() { var config = configService.getSync(); - $scope.appName = $window.appConfig.nameCase; + $scope.appName = appConfigService.nameCase; $scope.PNEnabledByUser = true; $scope.usePushNotifications = platformInfo.isCordova && !platformInfo.isWP; $scope.isIOSApp = platformInfo.isIOS && platformInfo.isCordova; diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index 5a13ca031..aac2df9bf 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -1,14 +1,14 @@ 'use strict'; angular.module('copayApp.controllers').controller('tabHomeController', - function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window, bitpayCardService, startupService, addressbookService, feedbackService) { + function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, appConfigService, bitpayCardService, startupService, addressbookService, feedbackService) { var wallet; var listeners = []; var notifications = []; $scope.externalServices = {}; $scope.openTxpModal = txpModalService.open; $scope.version = $window.version; - $scope.name = $window.appConfig.nameCase; + $scope.name = appConfigService.nameCase; $scope.homeTip = $stateParams.fromOnboarding; $scope.isCordova = platformInfo.isCordova; $scope.isAndroid = platformInfo.isAndroid; @@ -43,7 +43,7 @@ angular.module('copayApp.controllers').controller('tabHomeController', } else { var feedbackInfo = JSON.parse(info); //Check if current version is greater than saved version - var currentVersion = window.version; + var currentVersion = $scope.version; var savedVersion = feedbackInfo.version; var isVersionUpdated = feedbackService.isVersionUpdated(currentVersion, savedVersion); if (!isVersionUpdated) { @@ -62,7 +62,7 @@ angular.module('copayApp.controllers').controller('tabHomeController', function initFeedBackInfo() { var feedbackInfo = {}; feedbackInfo.time = moment().unix(); - feedbackInfo.version = window.version; + feedbackInfo.version = $scope.version; feedbackInfo.sent = false; storageService.setFeedbackInfo(JSON.stringify(feedbackInfo), function() { $scope.showRateCard.value = false; diff --git a/src/js/controllers/tab-settings.js b/src/js/controllers/tab-settings.js index e59dc12d9..46acf9b05 100644 --- a/src/js/controllers/tab-settings.js +++ b/src/js/controllers/tab-settings.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, $window, $ionicModal, $log, lodash, uxLanguage, platformInfo, profileService, feeService, configService, externalLinkService, bitpayCardService, storageService, glideraService, gettextCatalog) { +angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, appConfigService, $ionicModal, $log, lodash, uxLanguage, platformInfo, profileService, feeService, configService, externalLinkService, bitpayCardService, storageService, glideraService, gettextCatalog) { var updateConfig = function() { var isCordova = platformInfo.isCordova; @@ -10,13 +10,13 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct $scope.usePushNotifications = isCordova && !isWP; $scope.isCordova = isCordova; - $scope.appName = $window.appConfig.nameCase; + $scope.appName = appConfigService.nameCase; $scope.currentLanguageName = uxLanguage.getCurrentLanguageName(); $scope.feeOpts = feeService.feeOpts; $scope.currentFeeLevel = feeService.getCurrentFeeLevel(); - + $scope.wallets = profileService.getWallets(); - + configService.whenAvailable(function(config) { $scope.unitName = config.wallet.settings.unitName; $scope.selectedAlternative = { @@ -33,7 +33,7 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct if (!lodash.isEmpty(data)) { $scope.bitpayCards = true; } - }); + }); } if ($scope.glideraEnabled) { diff --git a/src/js/controllers/termOfUse.js b/src/js/controllers/termOfUse.js index 6bbc2bdf4..ddf17cd99 100644 --- a/src/js/controllers/termOfUse.js +++ b/src/js/controllers/termOfUse.js @@ -1,9 +1,9 @@ 'use strict'; angular.module('copayApp.controllers').controller('termOfUseController', - function($scope, $window, uxLanguage, externalLinkService) { + function($scope, appConfigService, uxLanguage, externalLinkService) { $scope.lang = uxLanguage.currentLanguage; - $scope.disclaimerUrl = $window.appConfig.disclaimerUrl; + $scope.disclaimerUrl = appConfigService.disclaimerUrl; $scope.openExternalLink = function(url, target) { externalLinkService.open(url, target); diff --git a/src/js/routes.js b/src/js/routes.js index 3f76267a9..ba1c14fec 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -1052,7 +1052,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } }); }) - .run(function($rootScope, $state, $location, $log, $timeout, $ionicHistory, $ionicPlatform, $window, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService, scannerService) { + .run(function($rootScope, $state, $location, $log, $timeout, $ionicHistory, $ionicPlatform, $window, appConfigService, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService, scannerService) { uxLanguage.init(); @@ -1171,7 +1171,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr type: "menubar" }); try { - nativeMenuBar.createMacBuiltin($window.appConfig.nameCase); + nativeMenuBar.createMacBuiltin(appConfigService.nameCase); } catch (e) { $log.debug('This is not OSX'); } diff --git a/src/js/services/appConfigService.js b/src/js/services/appConfigService.js new file mode 100644 index 000000000..d5b34c64c --- /dev/null +++ b/src/js/services/appConfigService.js @@ -0,0 +1,5 @@ +'use strict'; + +angular.module('copayApp.services').factory('appConfigService', function($window) { + return $window.appConfig; +}); diff --git a/src/js/services/backupService.js b/src/js/services/backupService.js index 165aa4a2e..2b558511a 100644 --- a/src/js/services/backupService.js +++ b/src/js/services/backupService.js @@ -1,6 +1,6 @@ 'use strict'; angular.module('copayApp.services') - .factory('backupService', function backupServiceFactory($log, $timeout, $stateParams, profileService, sjcl, $window) { + .factory('backupService', function backupServiceFactory($log, $timeout, $stateParams, profileService, sjcl, appConfigService) { var root = {}; @@ -80,7 +80,7 @@ angular.module('copayApp.services') var walletName = (wallet.alias || '') + (wallet.alias ? '-' : '') + wallet.credentials.walletName; if (opts.noSign) walletName = walletName + '-noSign' - var filename = walletName + '-' + $window.appConfig.nameCase + 'backup.aes.json'; + var filename = walletName + '-' + appConfigService.nameCase + 'backup.aes.json'; _download(ew, filename, cb) }; return root; diff --git a/src/js/services/incomingData.js b/src/js/services/incomingData.js index 7600dcb79..a673ccfca 100644 --- a/src/js/services/incomingData.js +++ b/src/js/services/incomingData.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.services').factory('incomingData', function($log, $state, $window, $timeout, bitcore, $rootScope, payproService, scannerService) { +angular.module('copayApp.services').factory('incomingData', function($log, $state, $timeout, bitcore, $rootScope, payproService, scannerService, appConfigService) { var root = {}; @@ -121,17 +121,17 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat } else { goToAmountPage(data); } - } else if (data && data.indexOf($window.appConfig.name + '://glidera') === 0) { + } else if (data && data.indexOf(appConfigService.name + '://glidera') === 0) { return $state.go('uriglidera', { url: data }); - } else if (data && data.indexOf($window.appConfig.name + '://coinbase') === 0) { + } else if (data && data.indexOf(appConfigService.name + '://coinbase') === 0) { return $state.go('uricoinbase', { url: data }); // BitPayCard Authentication - } else if (data && data.indexOf($window.appConfig.name + '://') === 0) { + } else if (data && data.indexOf(appConfigService.name + '://') === 0) { var secret = getParameterByName('secret', data); var email = getParameterByName('email', data); var otp = getParameterByName('otp', data); diff --git a/src/js/services/logHeader.js b/src/js/services/logHeader.js index bbf3da903..f8ba63d81 100644 --- a/src/js/services/logHeader.js +++ b/src/js/services/logHeader.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.services') - .factory('logHeader', function($window, $log, platformInfo) { - $log.info($window.appConfig.nameCase + ' v' + window.version + ' #' + window.commitHash); - $log.info('Client: '+ JSON.stringify(platformInfo) ); + .factory('logHeader', function($window, appConfigService, $log, platformInfo) { + $log.info(appConfigService.nameCase + ' v' + $window.version + ' #' + $window.commitHash); + $log.info('Client: ' + JSON.stringify(platformInfo)); return {}; });