2015-03-06 12:00:10 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2015-05-12 14:56:24 -03:00
|
|
|
var unsupported, isaosp;
|
2015-03-06 12:00:10 -03:00
|
|
|
|
|
|
|
|
if (window && window.navigator) {
|
|
|
|
|
var rxaosp = window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);
|
2015-05-12 14:56:24 -03:00
|
|
|
isaosp = (rxaosp && rxaosp[1] < 537);
|
2015-03-06 12:00:10 -03:00
|
|
|
if (!window.cordova && isaosp)
|
|
|
|
|
unsupported = true;
|
2015-04-20 18:48:17 -03:00
|
|
|
if (unsupported) {
|
|
|
|
|
window.location = '#/unsupported';
|
|
|
|
|
}
|
2015-03-06 12:00:10 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Setting up route
|
|
|
|
|
angular
|
|
|
|
|
.module('copayApp')
|
2015-09-04 12:02:55 +03:00
|
|
|
.config(function(historicLogProvider, $provide, $logProvider, $stateProvider, $urlRouterProvider, $compileProvider) {
|
2015-03-06 12:00:10 -03:00
|
|
|
$urlRouterProvider.otherwise('/');
|
|
|
|
|
|
2015-04-25 12:37:04 -03:00
|
|
|
$logProvider.debugEnabled(true);
|
2016-06-02 11:09:40 -03:00
|
|
|
$provide.decorator('$log', ['$delegate', 'platformInfo',
|
|
|
|
|
function($delegate, platformInfo) {
|
2015-04-25 12:37:04 -03:00
|
|
|
var historicLog = historicLogProvider.$get();
|
|
|
|
|
|
|
|
|
|
['debug', 'info', 'warn', 'error', 'log'].forEach(function(level) {
|
2016-06-02 11:09:40 -03:00
|
|
|
if (platformInfo.isDevel && level == 'error') return;
|
2015-11-05 19:46:32 -03:00
|
|
|
|
2015-04-25 12:37:04 -03:00
|
|
|
var orig = $delegate[level];
|
|
|
|
|
$delegate[level] = function() {
|
2015-07-13 13:21:47 -03:00
|
|
|
if (level == 'error')
|
2015-05-28 14:55:48 -03:00
|
|
|
console.log(arguments);
|
|
|
|
|
|
2016-04-29 12:14:09 -03:00
|
|
|
var args = Array.prototype.slice.call(arguments);
|
|
|
|
|
|
2015-04-25 14:42:17 -03:00
|
|
|
args = args.map(function(v) {
|
2015-04-25 20:53:31 -03:00
|
|
|
try {
|
|
|
|
|
if (typeof v == 'undefined') v = 'undefined';
|
2015-04-30 13:03:30 -03:00
|
|
|
if (!v) v = 'null';
|
2015-04-25 20:53:31 -03:00
|
|
|
if (typeof v == 'object') {
|
2015-04-27 02:07:26 -03:00
|
|
|
if (v.message)
|
|
|
|
|
v = v.message;
|
|
|
|
|
else
|
|
|
|
|
v = JSON.stringify(v);
|
2015-04-25 20:53:31 -03:00
|
|
|
}
|
2015-07-13 13:21:47 -03:00
|
|
|
// Trim output in mobile
|
2015-10-02 11:27:17 -03:00
|
|
|
if (window.cordova) {
|
2015-07-13 13:21:47 -03:00
|
|
|
v = v.toString();
|
2016-04-29 12:14:09 -03:00
|
|
|
if (v.length > 3000) {
|
|
|
|
|
v = v.substr(0, 2997) + '...';
|
2015-07-13 13:21:47 -03:00
|
|
|
}
|
|
|
|
|
}
|
2015-04-25 20:53:31 -03:00
|
|
|
} catch (e) {
|
|
|
|
|
console.log('Error at log decorator:', e);
|
|
|
|
|
v = 'undefined';
|
2015-04-25 14:42:17 -03:00
|
|
|
}
|
2015-04-25 12:37:04 -03:00
|
|
|
return v;
|
|
|
|
|
});
|
2016-04-29 12:14:09 -03:00
|
|
|
|
2015-04-26 20:13:02 -03:00
|
|
|
try {
|
|
|
|
|
if (window.cordova)
|
|
|
|
|
console.log(args.join(' '));
|
2016-04-29 12:14:09 -03:00
|
|
|
|
2015-04-26 20:13:02 -03:00
|
|
|
historicLog.add(level, args.join(' '));
|
2015-05-04 12:23:43 -03:00
|
|
|
orig.apply(null, args);
|
2015-04-26 20:13:02 -03:00
|
|
|
} catch (e) {
|
2015-06-19 15:00:27 -03:00
|
|
|
console.log('ERROR (at log decorator):', e, args[0]);
|
2015-04-26 20:13:02 -03:00
|
|
|
}
|
2015-04-25 12:37:04 -03:00
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
return $delegate;
|
|
|
|
|
}
|
|
|
|
|
]);
|
|
|
|
|
|
2015-09-04 12:02:55 +03:00
|
|
|
// whitelist 'chrome-extension:' for chromeApp to work with image URLs processed by Angular
|
|
|
|
|
// link: http://stackoverflow.com/questions/15606751/angular-changes-urls-to-unsafe-in-extension-page?lq=1
|
|
|
|
|
$compileProvider.imgSrcSanitizationWhitelist(/^\s*((https?|ftp|file|blob|chrome-extension):|data:image\/)/);
|
|
|
|
|
|
2015-10-02 11:27:17 -03:00
|
|
|
$stateProvider
|
2015-07-29 18:15:37 -03:00
|
|
|
.state('translators', {
|
|
|
|
|
url: '/translators',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/translators.html'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-06-11 11:59:48 -03:00
|
|
|
.state('disclaimer', {
|
|
|
|
|
url: '/disclaimer',
|
|
|
|
|
needProfile: false,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/disclaimer.html',
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-03-06 12:00:10 -03:00
|
|
|
.state('walletHome', {
|
|
|
|
|
url: '/',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
2015-05-07 18:35:54 -03:00
|
|
|
templateUrl: 'views/walletHome.html',
|
2015-03-06 12:00:10 -03:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.state('unsupported', {
|
|
|
|
|
url: '/unsupported',
|
|
|
|
|
needProfile: false,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/unsupported.html'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-05-15 20:09:45 -03:00
|
|
|
.state('payment', {
|
2015-05-15 20:19:01 -03:00
|
|
|
url: '/uri-payment/:data',
|
2015-03-06 12:00:10 -03:00
|
|
|
templateUrl: 'views/paymentUri.html',
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/paymentUri.html',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
needProfile: true
|
|
|
|
|
})
|
|
|
|
|
.state('selectWalletForPayment', {
|
|
|
|
|
url: '/selectWalletForPayment',
|
|
|
|
|
controller: 'walletForPaymentController',
|
|
|
|
|
needProfile: true
|
|
|
|
|
})
|
|
|
|
|
.state('join', {
|
|
|
|
|
url: '/join',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/join.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.state('import', {
|
|
|
|
|
url: '/import',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/import.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.state('importLegacy', {
|
|
|
|
|
url: '/importLegacy',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/importLegacy.html',
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
.state('create', {
|
|
|
|
|
url: '/create',
|
|
|
|
|
templateUrl: 'views/create.html',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/create.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.state('copayers', {
|
|
|
|
|
url: '/copayers',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/copayers.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.state('preferences', {
|
|
|
|
|
url: '/preferences',
|
|
|
|
|
templateUrl: 'views/preferences.html',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
2015-05-07 18:35:54 -03:00
|
|
|
templateUrl: 'views/preferences.html',
|
2015-03-06 12:00:10 -03:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-04-22 15:19:08 -03:00
|
|
|
.state('preferencesLanguage', {
|
|
|
|
|
url: '/preferencesLanguage',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesLanguage.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-03-06 12:00:10 -03:00
|
|
|
.state('preferencesUnit', {
|
|
|
|
|
url: '/preferencesUnit',
|
|
|
|
|
templateUrl: 'views/preferencesUnit.html',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesUnit.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-06-19 17:22:12 -03:00
|
|
|
.state('preferencesFee', {
|
|
|
|
|
url: '/preferencesFee',
|
|
|
|
|
templateUrl: 'views/preferencesFee.html',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesFee.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-09-09 14:15:08 -03:00
|
|
|
.state('uriglidera', {
|
|
|
|
|
url: '/uri-glidera?code',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/glideraUri.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-08-31 18:12:04 -03:00
|
|
|
.state('glidera', {
|
|
|
|
|
url: '/glidera',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/glidera.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.state('buyGlidera', {
|
|
|
|
|
url: '/buy',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/buyGlidera.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.state('sellGlidera', {
|
|
|
|
|
url: '/sell',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/sellGlidera.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-11-23 12:17:04 -03:00
|
|
|
.state('preferencesGlidera', {
|
|
|
|
|
url: '/preferencesGlidera',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesGlidera.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2016-04-13 14:08:03 -03:00
|
|
|
.state('coinbase', {
|
|
|
|
|
url: '/coinbase',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/coinbase.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.state('preferencesCoinbase', {
|
|
|
|
|
url: '/preferencesCoinbase',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesCoinbase.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.state('uricoinbase', {
|
|
|
|
|
url: '/uri-coinbase?code',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/coinbaseUri.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.state('buyCoinbase', {
|
|
|
|
|
url: '/buycoinbase',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/buyCoinbase.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.state('sellCoinbase', {
|
|
|
|
|
url: '/sellcoinbase',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/sellCoinbase.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.state('buyandsell', {
|
|
|
|
|
url: '/buyandsell',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/buyAndSell.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-11-23 12:17:04 -03:00
|
|
|
.state('preferencesAdvanced', {
|
|
|
|
|
url: '/preferencesAdvanced',
|
|
|
|
|
templateUrl: 'views/preferencesAdvanced.html',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesAdvanced.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.state('preferencesColor', {
|
|
|
|
|
url: '/preferencesColor',
|
|
|
|
|
templateUrl: 'views/preferencesColor.html',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesColor.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.state('preferencesAltCurrency', {
|
2015-11-16 17:43:54 -03:00
|
|
|
url: '/preferencesAltCurrency',
|
|
|
|
|
templateUrl: 'views/preferencesAltCurrency.html',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesAltCurrency.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-05-14 10:39:22 -03:00
|
|
|
.state('preferencesAlias', {
|
|
|
|
|
url: '/preferencesAlias',
|
|
|
|
|
templateUrl: 'views/preferencesAlias.html',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesAlias.html'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-05-14 17:21:19 -03:00
|
|
|
.state('preferencesEmail', {
|
|
|
|
|
url: '/preferencesEmail',
|
|
|
|
|
templateUrl: 'views/preferencesEmail.html',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesEmail.html'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-03-06 12:00:10 -03:00
|
|
|
.state('preferencesBwsUrl', {
|
|
|
|
|
url: '/preferencesBwsUrl',
|
|
|
|
|
templateUrl: 'views/preferencesBwsUrl.html',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesBwsUrl.html'
|
|
|
|
|
},
|
2015-05-08 16:54:32 -03:00
|
|
|
|
2015-03-06 12:00:10 -03:00
|
|
|
}
|
|
|
|
|
})
|
2015-12-02 15:34:34 -03:00
|
|
|
.state('preferencesHistory', {
|
|
|
|
|
url: '/preferencesHistory',
|
|
|
|
|
templateUrl: 'views/preferencesHistory.html',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesHistory.html'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-11-16 17:43:54 -03:00
|
|
|
.state('deleteWords', {
|
|
|
|
|
url: '/deleteWords',
|
|
|
|
|
templateUrl: 'views/preferencesDeleteWords.html',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesDeleteWords.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-03-06 12:00:10 -03:00
|
|
|
.state('delete', {
|
|
|
|
|
url: '/delete',
|
|
|
|
|
templateUrl: 'views/preferencesDeleteWallet.html',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesDeleteWallet.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-09-12 10:44:01 -03:00
|
|
|
.state('information', {
|
|
|
|
|
url: '/information',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesInformation.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-11-23 12:17:04 -03:00
|
|
|
.state('about', {
|
2015-11-16 17:43:54 -03:00
|
|
|
url: '/about',
|
|
|
|
|
templateUrl: 'views/preferencesAbout.html',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesAbout.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-04-25 12:37:04 -03:00
|
|
|
.state('logs', {
|
|
|
|
|
url: '/logs',
|
|
|
|
|
templateUrl: 'views/preferencesLogs.html',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesLogs.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-08-08 09:30:50 -03:00
|
|
|
.state('export', {
|
|
|
|
|
url: '/export',
|
|
|
|
|
templateUrl: 'views/export.html',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/export.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-10-02 11:27:17 -03:00
|
|
|
.state('paperWallet', {
|
|
|
|
|
url: '/paperWallet',
|
|
|
|
|
templateUrl: 'views/paperWallet.html',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/paperWallet.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-03-06 12:00:10 -03:00
|
|
|
.state('backup', {
|
|
|
|
|
url: '/backup',
|
|
|
|
|
templateUrl: 'views/backup.html',
|
|
|
|
|
walletShouldBeComplete: true,
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/backup.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-11-09 15:20:15 -03:00
|
|
|
.state('preferencesGlobal', {
|
|
|
|
|
url: '/preferencesGlobal',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/preferencesGlobal.html',
|
|
|
|
|
},
|
|
|
|
|
}
|
2015-03-06 12:00:10 -03:00
|
|
|
})
|
2015-11-25 10:04:43 -03:00
|
|
|
.state('termOfUse', {
|
|
|
|
|
url: '/termOfUse',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/termOfUse.html',
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-03-06 12:00:10 -03:00
|
|
|
.state('warning', {
|
|
|
|
|
url: '/warning',
|
|
|
|
|
controller: 'warningController',
|
|
|
|
|
templateUrl: 'views/warning.html',
|
|
|
|
|
needProfile: false
|
|
|
|
|
})
|
2015-11-23 12:17:04 -03:00
|
|
|
.state('add', {
|
2015-11-16 17:43:54 -03:00
|
|
|
url: '/add',
|
|
|
|
|
needProfile: true,
|
|
|
|
|
views: {
|
|
|
|
|
'main': {
|
|
|
|
|
templateUrl: 'views/add.html'
|
|
|
|
|
},
|
|
|
|
|
}
|
2016-05-23 12:16:27 -03:00
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.run(function($rootScope, $state, $log, $timeout, $ionicPlatform, uriHandler, platformInfo, profileService, uxLanguage, animationService, go, gettextCatalog) {
|
2015-12-10 09:59:56 -03:00
|
|
|
|
2016-05-23 12:16:27 -03:00
|
|
|
$ionicPlatform.ready(function() {
|
|
|
|
|
if (window.cordova !== undefined) {
|
2015-12-10 15:55:08 -03:00
|
|
|
|
2016-05-23 12:16:27 -03:00
|
|
|
$ionicPlatform.registerBackButtonAction(function(event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
}, 100);
|
2015-12-10 15:55:08 -03:00
|
|
|
|
2016-05-23 12:16:27 -03:00
|
|
|
var secondBackButtonPress = 'false';
|
|
|
|
|
var intval = setInterval(function() {
|
|
|
|
|
secondBackButtonPress = 'false';
|
|
|
|
|
}, 5000);
|
|
|
|
|
|
|
|
|
|
$ionicPlatform.on('pause', function() {
|
|
|
|
|
// Nothing to do
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$ionicPlatform.on('resume', function() {
|
|
|
|
|
if (!window.ignoreMobilePause) {
|
|
|
|
|
$rootScope.$emit('Local/Resume');
|
|
|
|
|
}
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
var loc = window.location;
|
|
|
|
|
var ignoreMobilePause = loc.toString().match(/(buy|sell|buycoinbase|sellcoinbase)/) ? true : false;
|
|
|
|
|
window.ignoreMobilePause = ignoreMobilePause;
|
|
|
|
|
}, 100);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$ionicPlatform.on('backbutton', function(event) {
|
|
|
|
|
|
|
|
|
|
var loc = window.location;
|
|
|
|
|
var fromDisclaimer = loc.toString().match(/disclaimer/) ? 'true' : '';
|
|
|
|
|
var fromHome = loc.toString().match(/index\.html#\/$/) ? 'true' : '';
|
|
|
|
|
|
|
|
|
|
if (fromDisclaimer == 'true')
|
|
|
|
|
navigator.app.exitApp();
|
|
|
|
|
|
|
|
|
|
if (platformInfo.isMobile && fromHome == 'true' && !$rootScope.modalOpened) {
|
|
|
|
|
if (secondBackButtonPress == 'true') {
|
|
|
|
|
navigator.app.exitApp();
|
|
|
|
|
} else {
|
|
|
|
|
window.plugins.toast.showShortBottom(gettextCatalog.getString('Press again to exit'));
|
2015-03-06 12:00:10 -03:00
|
|
|
}
|
2016-05-23 12:16:27 -03:00
|
|
|
} else {
|
|
|
|
|
$rootScope.$emit('closeModal');
|
2015-03-06 12:00:10 -03:00
|
|
|
}
|
2016-05-23 12:16:27 -03:00
|
|
|
|
|
|
|
|
if (secondBackButtonPress == 'true') {
|
|
|
|
|
clearInterval(intval);
|
|
|
|
|
} else {
|
|
|
|
|
secondBackButtonPress = 'true';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$timeout(function() {
|
|
|
|
|
$rootScope.$emit('Local/SetTab', 'walletHome', true);
|
|
|
|
|
}, 100);
|
|
|
|
|
go.walletHome();
|
|
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
window.ignoreMobilePause = false;
|
|
|
|
|
}, 100);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$ionicPlatform.on('menubutton', function() {
|
|
|
|
|
window.location = '#/preferences';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
navigator.splashscreen.hide();
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
});
|
2015-04-25 12:37:04 -03:00
|
|
|
|
2015-08-27 12:07:13 -03:00
|
|
|
uxLanguage.init();
|
2015-03-06 12:00:10 -03:00
|
|
|
|
|
|
|
|
// Register URI handler, not for mobileApp
|
2016-05-23 12:16:27 -03:00
|
|
|
if (!platformInfo.isMobile) {
|
2015-03-06 12:00:10 -03:00
|
|
|
uriHandler.register();
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-31 14:55:08 -03:00
|
|
|
if (platformInfo.isNW) {
|
2015-05-28 10:52:33 -03:00
|
|
|
var gui = require('nw.gui');
|
|
|
|
|
var win = gui.Window.get();
|
2015-07-13 13:21:47 -03:00
|
|
|
var nativeMenuBar = new gui.Menu({
|
|
|
|
|
type: "menubar"
|
|
|
|
|
});
|
2015-05-28 12:14:04 -03:00
|
|
|
try {
|
|
|
|
|
nativeMenuBar.createMacBuiltin("Copay");
|
2015-07-13 13:21:47 -03:00
|
|
|
} catch (e) {
|
2015-05-28 12:14:04 -03:00
|
|
|
$log.debug('This is not OSX');
|
|
|
|
|
}
|
2015-05-28 10:52:33 -03:00
|
|
|
win.menu = nativeMenuBar;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-11 12:53:29 -03:00
|
|
|
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
|
2016-04-13 17:46:25 +02:00
|
|
|
$log.debug('Route change from:', fromState.name || '-', ' to:', toState.name);
|
2015-05-04 19:23:18 -03:00
|
|
|
|
2015-03-06 12:00:10 -03:00
|
|
|
if (!profileService.profile && toState.needProfile) {
|
|
|
|
|
|
2015-04-24 16:39:12 -03:00
|
|
|
// Give us time to open / create the profile
|
2015-04-25 12:37:04 -03:00
|
|
|
event.preventDefault();
|
2015-03-06 12:00:10 -03:00
|
|
|
// Try to open local profile
|
|
|
|
|
profileService.loadAndBindProfile(function(err) {
|
|
|
|
|
if (err) {
|
2015-10-28 16:19:16 -03:00
|
|
|
if (err.message && err.message.match('NOPROFILE')) {
|
2015-03-06 12:00:10 -03:00
|
|
|
$log.debug('No profile... redirecting');
|
2015-06-11 11:59:48 -03:00
|
|
|
$state.transitionTo('disclaimer');
|
2015-11-23 12:17:04 -03:00
|
|
|
} else if (err.message && err.message.match('NONAGREEDDISCLAIMER')) {
|
|
|
|
|
$log.debug('Display disclaimer... redirecting');
|
|
|
|
|
$state.transitionTo('disclaimer');
|
2015-03-06 12:00:10 -03:00
|
|
|
} else {
|
|
|
|
|
throw new Error(err); // TODO
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2015-04-25 12:37:04 -03:00
|
|
|
$log.debug('Profile loaded ... Starting UX.');
|
2015-05-04 12:23:43 -03:00
|
|
|
$state.transitionTo(toState.name || toState, toParams);
|
2015-03-06 12:00:10 -03:00
|
|
|
}
|
|
|
|
|
});
|
2016-03-09 11:53:47 -03:00
|
|
|
} else {
|
|
|
|
|
if (profileService.focusedClient && !profileService.focusedClient.isComplete() && toState.walletShouldBeComplete) {
|
2015-05-04 12:23:43 -03:00
|
|
|
|
2016-03-09 11:53:47 -03:00
|
|
|
$state.transitionTo('copayers');
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
}
|
2015-11-16 17:43:54 -03:00
|
|
|
}
|
2015-05-08 18:28:50 -03:00
|
|
|
|
2015-10-01 02:13:33 -03:00
|
|
|
if (!animationService.transitionAnimated(fromState, toState)) {
|
2015-05-08 18:28:50 -03:00
|
|
|
event.preventDefault();
|
|
|
|
|
// Time for the backpane to render
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
$state.transitionTo(toState);
|
|
|
|
|
}, 50);
|
2015-05-07 18:35:54 -03:00
|
|
|
}
|
2015-03-06 12:00:10 -03:00
|
|
|
});
|
2015-10-28 16:19:16 -03:00
|
|
|
});
|