2014-04-07 20:54:38 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
//Setting up route
|
|
|
|
angular
|
2014-08-12 12:26:15 -07:00
|
|
|
.module('copayApp')
|
|
|
|
.config(function($routeProvider) {
|
2014-04-07 20:54:38 -07:00
|
|
|
|
2014-08-12 12:26:15 -07:00
|
|
|
$routeProvider
|
|
|
|
.when('/', {
|
|
|
|
templateUrl: 'views/home.html',
|
|
|
|
validate: false
|
|
|
|
})
|
|
|
|
.when('/open', {
|
|
|
|
templateUrl: 'views/open.html',
|
|
|
|
validate: false
|
|
|
|
})
|
|
|
|
.when('/join', {
|
|
|
|
templateUrl: 'views/join.html',
|
|
|
|
validate: false
|
|
|
|
})
|
|
|
|
.when('/import', {
|
|
|
|
templateUrl: 'views/import.html',
|
|
|
|
validate: false
|
|
|
|
})
|
|
|
|
.when('/setup', {
|
|
|
|
templateUrl: 'views/setup.html',
|
|
|
|
validate: false
|
|
|
|
})
|
|
|
|
.when('/copayers', {
|
|
|
|
templateUrl: 'views/copayers.html',
|
|
|
|
validate: true
|
|
|
|
})
|
|
|
|
.when('/receive', {
|
|
|
|
templateUrl: 'views/addresses.html',
|
|
|
|
validate: true
|
|
|
|
})
|
|
|
|
.when('/history', {
|
|
|
|
templateUrl: 'views/transactions.html',
|
|
|
|
validate: true
|
|
|
|
})
|
|
|
|
.when('/send', {
|
|
|
|
templateUrl: 'views/send.html',
|
|
|
|
validate: true
|
|
|
|
})
|
|
|
|
.when('/backup', {
|
|
|
|
templateUrl: 'views/backup.html',
|
|
|
|
validate: true
|
|
|
|
})
|
|
|
|
.when('/settings', {
|
|
|
|
templateUrl: 'views/settings.html',
|
|
|
|
validate: false
|
|
|
|
})
|
|
|
|
.when('/unsupported', {
|
|
|
|
templateUrl: 'views/unsupported.html'
|
|
|
|
})
|
|
|
|
.when('/uri-payment/:data', {
|
|
|
|
templateUrl: 'views/uri-payment.html'
|
|
|
|
})
|
|
|
|
.when('/warning', {
|
|
|
|
templateUrl: 'views/warning.html',
|
|
|
|
validate: true
|
|
|
|
})
|
|
|
|
.otherwise({
|
|
|
|
templateUrl: 'views/errors/404.html',
|
|
|
|
title: 'Error'
|
2014-04-07 20:54:38 -07:00
|
|
|
});
|
2014-08-12 12:26:15 -07:00
|
|
|
});
|
2014-04-07 20:54:38 -07:00
|
|
|
|
|
|
|
//Setting HTML5 Location Mode
|
|
|
|
angular
|
2014-08-12 12:26:15 -07:00
|
|
|
.module('copayApp')
|
|
|
|
.config(function($locationProvider, $idleProvider) {
|
|
|
|
$locationProvider
|
|
|
|
.html5Mode(false)
|
|
|
|
.hashPrefix('!');
|
|
|
|
// IDLE timeout
|
2014-08-14 15:46:42 -07:00
|
|
|
$idleProvider.idleDuration(config.wallet.idleDurationMin * 60); // in seconds
|
|
|
|
$idleProvider.warningDuration(20); // in seconds
|
2014-08-12 12:26:15 -07:00
|
|
|
})
|
|
|
|
.run(function($rootScope, $location, $idle) {
|
|
|
|
$idle.watch();
|
|
|
|
$rootScope.$on('$routeChangeStart', function(event, next, current) {
|
|
|
|
if (!util.supports.data) {
|
|
|
|
$location.path('unsupported');
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Locked?
|
|
|
|
if ($rootScope.showLockWarning) {
|
|
|
|
if ($rootScope.tmp) {
|
|
|
|
if ($location.path() !== '/warning') {
|
|
|
|
$location.path('/warning');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
delete $rootScope['showLockWarning'];
|
|
|
|
}
|
2014-08-07 14:57:19 -07:00
|
|
|
}
|
2014-08-12 12:26:15 -07:00
|
|
|
return;
|
2014-04-18 11:22:02 -07:00
|
|
|
}
|
2014-08-12 12:26:15 -07:00
|
|
|
|
|
|
|
if ((!$rootScope.wallet || !$rootScope.wallet.id) && next.validate) {
|
|
|
|
$idle.unwatch();
|
|
|
|
$location.path('/');
|
|
|
|
}
|
|
|
|
|
|
|
|
// In creation?
|
|
|
|
if ($rootScope.wallet && !$rootScope.wallet.isReady()) {
|
|
|
|
$location.path('/copayers');
|
|
|
|
}
|
|
|
|
}
|
2014-04-07 20:54:38 -07:00
|
|
|
});
|
2014-08-12 12:26:15 -07:00
|
|
|
})
|
|
|
|
.config(function($compileProvider) {
|
|
|
|
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|tel|chrome-extension|resource):/);
|
|
|
|
});
|