Wallet/src/js/init.js

109 lines
3.2 KiB
JavaScript
Raw Normal View History

2014-03-14 17:38:27 -03:00
'use strict';
2014-04-30 12:25:33 -03:00
2014-03-14 17:38:27 -03:00
angular.element(document).ready(function() {
2015-01-03 13:59:18 -03:00
2015-04-13 10:37:42 -03:00
// Run copayApp after device is ready.
var startAngular = function() {
angular.bootstrap(document, ['copayApp']);
2015-04-13 10:37:42 -03:00
};
var handleBitcoinURI = function(url) {
if (!url) return;
if (url.indexOf('glidera') != -1) {
url = '#/uri-glidera' + url.replace('bitcoin://glidera', '');
Feat/coinbase integration (#4012) * Oauth2 and first view * Connect with Coinbase using mobile * Buy and Sell through Coinbase * Fix buy * Receive and send bitcoin to Coinbase account * Receive bitcoin from Coinbase to Copay * Complete user and account information. Connection errors * Improves error handler * Removes console.log * Coinbase background color. Send to Coinbase form validation * Fix send from different wallet * Send and receive using Coinbase * Pagination activity * Fix Buy and Sell * One option in the sidebar to Buy and Sell * Native balance on Coinbase homepage * Rename receive and send * Auto-close window after authenticate * Reorder * Get payment methods * Fix when token expired * Fix token expired * Integration: sell and send to Coinbase * Store pending transaction before sell * Sell flow completed * Removing files * Fix sell * Fix sell * Fix sell * Sell completed * Buy bitcoin through coinbase * Buy auto * Currency set to USD * Select payment methods. Limits * Removes payment methods from preferences * Fix signs. Tx ordered by updated. Minor fixes * Removes console.log * Improving ux-language things * Fix selectedpaymentmethod if not verified * Set error if tx not found * Price sensitivity. Minor fixes * Adds coinbase api key to gitignore * Coinbase production ready * Fix sell in usd * Bug fixes * New Sensitivity step * Refresh token with a simple click * Refresh token * Refactor * Fix auto reconnect if token expired Signed-off-by: Gustavo Maximiliano Cortez <cmgustavo83@gmail.com> * Fix calls if token expired
2016-04-13 14:08:03 -03:00
} else if (url.indexOf('coinbase') != -1) {
url = '#/uri-coinbase' + url.replace('bitcoin://coinbase', '');
2015-12-09 12:16:15 -03:00
} else {
url = '#/uri-payment/' + url;
}
setTimeout(function() {
window.location = url;
}, 1000);
};
/* Cordova specific Init */
2014-11-25 15:09:36 -03:00
if (window.cordova !== undefined) {
2014-11-25 15:09:36 -03:00
document.addEventListener('deviceready', function() {
var secondBackButtonPress = 'false';
2015-12-10 09:59:56 -03:00
var intval = setInterval(function() {
secondBackButtonPress = 'false';
}, 5000);
document.addEventListener('pause', function() {
2014-12-12 19:17:50 -03:00
if (!window.ignoreMobilePause) {
2015-11-05 18:54:19 -03:00
setTimeout(function() {
2015-12-10 15:55:08 -03:00
window.location = '#/cordova/pause///';
2015-11-05 18:54:19 -03:00
}, 100);
2014-12-12 15:07:48 -03:00
}
}, false);
2015-04-13 14:58:07 -03:00
document.addEventListener('resume', function() {
if (!window.ignoreMobilePause) {
2015-11-05 18:54:19 -03:00
setTimeout(function() {
2015-12-10 15:55:08 -03:00
window.location = '#/cordova/resume///';
2015-11-05 18:54:19 -03:00
}, 100);
}
setTimeout(function() {
var loc = window.location;
Feat/coinbase integration (#4012) * Oauth2 and first view * Connect with Coinbase using mobile * Buy and Sell through Coinbase * Fix buy * Receive and send bitcoin to Coinbase account * Receive bitcoin from Coinbase to Copay * Complete user and account information. Connection errors * Improves error handler * Removes console.log * Coinbase background color. Send to Coinbase form validation * Fix send from different wallet * Send and receive using Coinbase * Pagination activity * Fix Buy and Sell * One option in the sidebar to Buy and Sell * Native balance on Coinbase homepage * Rename receive and send * Auto-close window after authenticate * Reorder * Get payment methods * Fix when token expired * Fix token expired * Integration: sell and send to Coinbase * Store pending transaction before sell * Sell flow completed * Removing files * Fix sell * Fix sell * Fix sell * Sell completed * Buy bitcoin through coinbase * Buy auto * Currency set to USD * Select payment methods. Limits * Removes payment methods from preferences * Fix signs. Tx ordered by updated. Minor fixes * Removes console.log * Improving ux-language things * Fix selectedpaymentmethod if not verified * Set error if tx not found * Price sensitivity. Minor fixes * Adds coinbase api key to gitignore * Coinbase production ready * Fix sell in usd * Bug fixes * New Sensitivity step * Refresh token with a simple click * Refresh token * Refactor * Fix auto reconnect if token expired Signed-off-by: Gustavo Maximiliano Cortez <cmgustavo83@gmail.com> * Fix calls if token expired
2016-04-13 14:08:03 -03:00
var ignoreMobilePause = loc.toString().match(/(buy|sell|buycoinbase|sellcoinbase)/) ? true : false;
window.ignoreMobilePause = ignoreMobilePause;
}, 100);
}, false);
2015-04-20 12:29:42 -03:00
// Back button event
2015-12-09 17:26:16 -03:00
2015-04-20 12:29:42 -03:00
document.addEventListener('backbutton', function() {
2015-12-10 09:59:56 -03:00
2015-04-20 12:48:01 -03:00
var loc = window.location;
2015-12-10 15:55:08 -03:00
var fromDisclaimer = loc.toString().match(/disclaimer/) ? 'true' : '';
var fromHome = loc.toString().match(/index\.html#\/$/) ? 'true' : '';
2015-09-30 14:14:15 -03:00
if (!window.ignoreMobilePause) {
2015-12-10 15:55:08 -03:00
window.location = '#/cordova/backbutton/' + fromHome + '/' + fromDisclaimer + '/' + secondBackButtonPress;
if (secondBackButtonPress == 'true') {
2015-12-10 09:59:56 -03:00
clearInterval(intval);
} else {
secondBackButtonPress = 'true';
2015-12-09 17:26:16 -03:00
}
2015-04-20 12:29:42 -03:00
}
2015-09-30 14:14:15 -03:00
setTimeout(function() {
window.ignoreMobilePause = false;
}, 100);
2015-04-20 12:29:42 -03:00
}, false);
2015-03-06 12:00:10 -03:00
document.addEventListener('menubutton', function() {
window.location = '#/preferences';
}, false);
setTimeout(function() {
navigator.splashscreen.hide();
}, 1000);
window.plugins.webintent.getUri(handleBitcoinURI);
window.plugins.webintent.onNewIntent(handleBitcoinURI);
window.handleOpenURL = handleBitcoinURI;
2015-10-07 16:17:19 -03:00
window.plugins.touchid.isAvailable(
2015-12-09 12:16:15 -03:00
function(msg) {
window.touchidAvailable = true;
}, // success handler: TouchID available
function(msg) {
window.touchidAvailable = false;
} // error handler: no TouchID available
2015-10-07 16:17:19 -03:00
);
2015-04-13 10:37:42 -03:00
startAngular();
}, false);
2014-11-25 15:09:36 -03:00
} else {
try {
window.handleOpenURL = handleBitcoinURI;
window.plugins.webintent.getUri(handleBitcoinURI);
window.plugins.webintent.onNewIntent(handleBitcoinURI);
} catch (e) {}
2015-04-13 10:37:42 -03:00
startAngular();
2014-11-25 15:09:36 -03:00
}
2014-03-14 17:38:27 -03:00
});