'use strict'; angular.module('myApp.settings', ['ngRoute']) .config(['$routeProvider', function($routeProvider) { $routeProvider.when('/settings', { templateUrl: '/views/settings/settings.html', controller: 'SettingsController' }); }]) .controller('SettingsController', function ($scope, $http, Notification) { $scope.getconfigData = function() { $http({ method: 'GET', url: '/config/all' }). success(function (data, status, headers, config) { for(var i=0; i -1) { $scope.config.Exchanges[i].EnabledPairsSplit.splice($scope.config.Exchanges[i].EnabledPairsSplit.indexOf(currency),1); //I feel there's a better way to do this, but for right now, whatever $scope.config.Exchanges[i].EnabledPairs = $scope.config.Exchanges[i].EnabledPairs.replace(currency,""); $scope.config.Exchanges[i].EnabledPairs = $scope.config.Exchanges[i].EnabledPairs.replace(",,",""); $scope.config.Exchanges[i].EnabledPairs = $scope.config.Exchanges[i].EnabledPairs.replace(/,\s*$/, ""); } else { $scope.config.Exchanges[i].EnabledPairsSplit.push(currency); $scope.config.Exchanges[i].EnabledPairs = $scope.config.Exchanges[i].EnabledPairs + "," + currency; } } } } $scope.saveAllSettings = function() { $scope.postObject = jQuery.extend(true, {}, $scope.config); //Purge any unnecessary post data delete $scope.postObject.Webserver; for(var i=0; i<$scope.postObject.Exchanges.length;i++) { delete $scope.postObject.Exchanges[i].AvailablePairsSplit; delete $scope.postObject.Exchanges[i].AvailablePairs; delete $scope.postObject.Exchanges[i].BaseCurrencies; delete $scope.postObject.Exchanges[i].EnabledPairsSplit; } //Send to be saved $http({ method: 'POST', url: '/config/all/save', data: $scope.postObject }). success(function (data) { Notification.success('Saved settings'); for(var i=0; i