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() {
|
2015-04-17 12:23:40 -03:00
|
|
|
angular.bootstrap(document, ['copayApp']);
|
2015-04-13 10:37:42 -03:00
|
|
|
};
|
2015-06-26 05:42:39 -03:00
|
|
|
|
|
|
|
|
var handleBitcoinURI = function(url) {
|
|
|
|
|
if (!url) return;
|
2015-09-09 14:15:08 -03:00
|
|
|
if (url.indexOf('glidera') != -1) {
|
|
|
|
|
url = '#/uri-glidera' + url.replace('bitcoin://glidera', '');
|
2015-12-09 12:16:15 -03:00
|
|
|
} else {
|
2015-09-09 14:15:08 -03:00
|
|
|
url = '#/uri-payment/' + url;
|
|
|
|
|
}
|
2015-06-26 05:42:39 -03:00
|
|
|
setTimeout(function() {
|
2015-09-09 14:15:08 -03:00
|
|
|
window.location = url;
|
2015-06-26 05:42:39 -03:00
|
|
|
}, 1000);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2014-12-07 12:40:59 -03:00
|
|
|
/* Cordova specific Init */
|
2014-11-25 15:09:36 -03:00
|
|
|
if (window.cordova !== undefined) {
|
2014-12-07 12:40:59 -03:00
|
|
|
|
2014-11-25 15:09:36 -03:00
|
|
|
document.addEventListener('deviceready', function() {
|
2015-12-10 09:59:56 -03:00
|
|
|
|
2015-12-10 11:24:42 -03:00
|
|
|
var secondBackButtonPress = 'false';
|
2015-12-10 09:59:56 -03:00
|
|
|
var intval = setInterval(function() {
|
2015-12-10 11:24:42 -03:00
|
|
|
secondBackButtonPress = 'false';
|
|
|
|
|
}, 5000);
|
2014-12-07 12:40:59 -03:00
|
|
|
|
|
|
|
|
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() {
|
|
|
|
|
window.location = '#/cordova/pause/';
|
|
|
|
|
}, 100);
|
2014-12-12 15:07:48 -03:00
|
|
|
}
|
2015-01-07 11:32:44 -03:00
|
|
|
}, false);
|
2015-04-13 14:58:07 -03:00
|
|
|
|
2015-01-29 16:03:14 -02:00
|
|
|
document.addEventListener('resume', function() {
|
2015-04-17 12:23:40 -03:00
|
|
|
if (!window.ignoreMobilePause) {
|
2015-11-05 18:54:19 -03:00
|
|
|
setTimeout(function() {
|
|
|
|
|
window.location = '#/cordova/resume/';
|
|
|
|
|
}, 100);
|
2015-04-17 12:23:40 -03:00
|
|
|
}
|
2015-01-29 16:03:14 -02:00
|
|
|
setTimeout(function() {
|
|
|
|
|
window.ignoreMobilePause = false;
|
2015-02-06 10:52:54 -03:00
|
|
|
}, 100);
|
2015-01-29 16:03:14 -02:00
|
|
|
}, false);
|
2015-01-07 11:32:44 -03:00
|
|
|
|
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
|
|
|
|
|
|
|
|
var loc = window.location;
|
|
|
|
|
var exit = loc.toString().match(/disclaimer/) ? 'true' : '';
|
|
|
|
|
if (exit != 'true')
|
|
|
|
|
var exit = loc.toString().match(/index\.html#\/$/) ? 'true' : '';
|
|
|
|
|
if (!window.ignoreMobilePause) {
|
2015-12-10 11:24:42 -03:00
|
|
|
window.location = '#/cordova/backbutton/' + exit + '/' + secondBackButtonPress;
|
|
|
|
|
if (secondBackButtonPress == 'true') {
|
2015-12-10 09:59:56 -03:00
|
|
|
clearInterval(intval);
|
|
|
|
|
} else {
|
2015-12-10 11:24:42 -03:00
|
|
|
secondBackButtonPress = 'true';
|
2015-12-09 17:26:16 -03:00
|
|
|
}
|
2015-04-20 12:29:42 -03:00
|
|
|
}
|
2015-12-10 09:59:56 -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);
|
|
|
|
|
|
2014-12-07 12:40:59 -03:00
|
|
|
setTimeout(function() {
|
|
|
|
|
navigator.splashscreen.hide();
|
|
|
|
|
}, 2000);
|
2014-11-26 12:36:51 -03:00
|
|
|
|
|
|
|
|
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();
|
2014-11-26 12:36:51 -03:00
|
|
|
}, false);
|
2014-11-25 15:09:36 -03:00
|
|
|
} else {
|
2015-06-26 05:42:39 -03:00
|
|
|
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
|
|
|
});
|