2014-05-13 10:19:37 -07:00
|
|
|
'use strict';
|
|
|
|
|
2014-09-03 07:33:45 -07:00
|
|
|
angular.module('copayApp.controllers').controller('SettingsController', function($scope, $rootScope, $window, $location, controllerUtils) {
|
2014-08-04 07:27:46 -07:00
|
|
|
|
2014-08-11 13:26:48 -07:00
|
|
|
controllerUtils.redirIfLogged();
|
|
|
|
$scope.title = 'Settings';
|
2014-09-05 12:56:47 -07:00
|
|
|
$scope.defaultLanguage = config.defaultLanguage || 'en';
|
2014-09-10 11:56:33 -07:00
|
|
|
$scope.insightLivenet = config.network.livenet.url;
|
|
|
|
$scope.insightTestnet = config.network.testnet.url;
|
2014-09-05 12:56:47 -07:00
|
|
|
|
|
|
|
$scope.availableLanguages = [{
|
|
|
|
name: 'English',
|
|
|
|
isoCode: 'en',
|
|
|
|
}, {
|
|
|
|
name: 'Spanish',
|
|
|
|
isoCode: 'es',
|
|
|
|
}];
|
|
|
|
|
|
|
|
for (var ii in $scope.availableLanguages) {
|
|
|
|
if ($scope.defaultLanguage === $scope.availableLanguages[ii].isoCode) {
|
|
|
|
$scope.selectedLanguage = $scope.availableLanguages[ii];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-06-16 08:44:18 -07:00
|
|
|
|
2014-08-11 13:26:48 -07:00
|
|
|
$scope.save = function() {
|
2014-09-03 09:11:32 -07:00
|
|
|
var insightSettings = {
|
2014-09-10 11:56:33 -07:00
|
|
|
livenet: {
|
|
|
|
url: $scope.insightLivenet,
|
|
|
|
},
|
|
|
|
testnet: {
|
|
|
|
url: $scope.insightTestnet,
|
|
|
|
},
|
2014-09-03 09:11:32 -07:00
|
|
|
}
|
|
|
|
|
2014-08-11 13:26:48 -07:00
|
|
|
localStorage.setItem('config', JSON.stringify({
|
2014-09-03 09:28:14 -07:00
|
|
|
network: insightSettings,
|
2014-09-08 16:26:58 -07:00
|
|
|
version: copay.version,
|
2014-09-05 12:56:47 -07:00
|
|
|
defaultLanguage: $scope.selectedLanguage.isoCode
|
2014-08-11 13:26:48 -07:00
|
|
|
}));
|
2014-06-16 08:44:18 -07:00
|
|
|
|
2014-08-11 13:26:48 -07:00
|
|
|
// Go home reloading the application
|
|
|
|
var hashIndex = window.location.href.indexOf('#!/');
|
|
|
|
window.location = window.location.href.substr(0, hashIndex);
|
|
|
|
};
|
|
|
|
});
|