2014-03-26 09:18:42 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2014-03-28 14:08:14 -04:00
|
|
|
angular.module('copay.home').controller('HomeController',
|
2014-04-17 13:25:36 -03:00
|
|
|
function($scope, $rootScope, $location, Socket, controllerUtils) {
|
2014-03-26 09:18:42 -03:00
|
|
|
$scope.title = 'Home';
|
2014-03-26 18:07:28 -03:00
|
|
|
$scope.oneAtATime = true;
|
2014-04-16 18:01:37 -03:00
|
|
|
$scope.addrBalance = {};
|
2014-03-26 18:07:28 -03:00
|
|
|
|
2014-04-18 13:20:35 -03:00
|
|
|
var w = $rootScope.wallet;
|
2014-04-17 13:25:36 -03:00
|
|
|
|
2014-04-18 13:20:35 -03:00
|
|
|
var _updateBalance = function () {
|
|
|
|
|
w.getBalance(function (balance, balanceByAddr) {
|
|
|
|
|
$scope.balanceByAddr = balanceByAddr;
|
|
|
|
|
$scope.addrs = Object.keys(balanceByAddr);
|
|
|
|
|
$scope.selectedAddr = $scope.addrs[0];
|
|
|
|
|
$scope.$digest();
|
|
|
|
|
});
|
2014-04-17 13:25:36 -03:00
|
|
|
var socket = Socket($scope);
|
2014-04-18 13:20:35 -03:00
|
|
|
controllerUtils.handleTransactionByAddress($scope, _updateBalance);
|
|
|
|
|
};
|
2014-04-14 16:48:12 -03:00
|
|
|
|
|
|
|
|
$scope.newAddr = function() {
|
2014-04-18 13:20:35 -03:00
|
|
|
var a = w.generateAddress().toString();
|
|
|
|
|
_updateBalance();
|
2014-04-14 16:48:12 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.selectAddr = function(addr) {
|
|
|
|
|
$scope.selectedAddr = addr;
|
|
|
|
|
};
|
2014-04-18 13:20:35 -03:00
|
|
|
|
|
|
|
|
_updateBalance();
|
2014-03-26 09:18:42 -03:00
|
|
|
});
|