Multiple fixes for chrome app
This commit is contained in:
parent
40910c3b34
commit
834c57a51a
12 changed files with 88 additions and 10 deletions
|
|
@ -13,3 +13,4 @@ popup.html
|
|||
lib/angular/angular-csp.css
|
||||
lib/angular/angular.min.js.map
|
||||
lib/angular-route/angular-route.min.js.map
|
||||
lib/angular-touch/angular-touch.min.js.map
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
color: #B7C2CD;
|
||||
}
|
||||
|
||||
|
||||
#qr-canvas { display: none; }
|
||||
#qrcode-scanner-video {
|
||||
display: block;
|
||||
|
|
@ -60,6 +61,7 @@ body, html{
|
|||
height:100%;
|
||||
width:100%;
|
||||
color: #2C3E50;
|
||||
-webkit-user-select: text;
|
||||
}
|
||||
|
||||
header {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
<link rel="shortcut icon" href="img/favicon.ico">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="loading" class="loadingpage">
|
||||
<img src="img/ajax-loader.gif" alt="Loading...">
|
||||
</div>
|
||||
|
|
|
|||
12
init.js
12
init.js
|
|
@ -20,6 +20,18 @@ function init() {
|
|||
ld.visibility = "hidden";
|
||||
} else if (ns6 || ie4) {
|
||||
ld.display = "none";
|
||||
} else {
|
||||
console.log('Warning!! is a chrome app!');
|
||||
console.log('ns4', ns4);
|
||||
console.log('ns6', ns6);
|
||||
console.log('ie4', ie4);
|
||||
|
||||
ld = document.loading;
|
||||
|
||||
ld = document.getElementById("loading").style;
|
||||
|
||||
ld.visibility = "hidden";
|
||||
ld.display = "none";
|
||||
}
|
||||
}
|
||||
init();
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
chrome.app.runtime.onLaunched.addListener(function() {
|
||||
chrome.app.window.create('index.html', {
|
||||
'bounds': {
|
||||
'width': 1024,
|
||||
'height': 768
|
||||
'width': 1200,
|
||||
'height': 800
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
54
js/app.js
54
js/app.js
|
|
@ -4,19 +4,67 @@ var copay = require('copay');
|
|||
var _ = require('lodash');
|
||||
var config = defaultConfig;
|
||||
|
||||
var isChromeApp = window.chrome && chrome.runtime && chrome.runtime.id;
|
||||
|
||||
var localStorage;
|
||||
if (window.chrome && chrome.runtime && chrome.runtime.id) {
|
||||
console.log('Is a chrome app!');
|
||||
if (isChromeApp) {
|
||||
var storage = chrome.storage.local;
|
||||
|
||||
var myAccess = 'myAccess';
|
||||
|
||||
var obj = {};
|
||||
|
||||
obj[myAccess] = Math.floor((Math.random() * 1000) + 1);;
|
||||
|
||||
storage.get(myAccess, function(result) {
|
||||
console.log('Last access 1', JSON.stringify(myAccess), JSON.stringify(result));
|
||||
});
|
||||
|
||||
storage.set(obj);
|
||||
|
||||
storage.get(myAccess, function(result) {
|
||||
console.log('Last access 2', JSON.stringify(myAccess), JSON.stringify(result));
|
||||
});
|
||||
|
||||
|
||||
|
||||
console.log('Is a chrome app!...app.js');
|
||||
console.log('chrome.storage', chrome.storage);
|
||||
chrome.storage.local.set({
|
||||
'MiNombre': 'Matias'
|
||||
}, function(done) {
|
||||
console.log('Saving to local storage', done);
|
||||
});
|
||||
localStorage = chrome.storage.local;
|
||||
|
||||
|
||||
|
||||
console.log('localStorage', localStorage);
|
||||
} else {
|
||||
console.log('Is web!');
|
||||
localStorage = window.localStorage;
|
||||
}
|
||||
|
||||
console.log('access to localStorage');
|
||||
|
||||
var localConfig;
|
||||
if (localStorage) {
|
||||
localConfig = JSON.parse(localStorage.getItem('config'));
|
||||
|
||||
if (isChromeApp) {
|
||||
var result;
|
||||
localStorage.getItem('config', function(data) {
|
||||
result = data;
|
||||
});
|
||||
|
||||
console.log('retrieving data from local storage', result);
|
||||
localConfig = JSON.parse(result);
|
||||
} else {
|
||||
localConfig = JSON.parse(localStorage.getItem('config'));
|
||||
console.log('localStorage', localConfig);
|
||||
}
|
||||
} else {
|
||||
|
||||
console.log('localStorage is null ');
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ angular.module('copayApp.controllers').controller('SettingsController', function
|
|||
|
||||
var isChromeApp = window.chrome && chrome.runtime && chrome.runtime.id;
|
||||
if (isChromeApp) {
|
||||
console.log('Is a chrome app!');
|
||||
console.log('Is a chrome app!...settings.js');
|
||||
localStorage = chrome.storage.local;
|
||||
} else {
|
||||
console.log('Is web!');
|
||||
|
|
@ -92,6 +92,7 @@ angular.module('copayApp.controllers').controller('SettingsController', function
|
|||
plugins[$scope.selectedStorage.pluginName] = true;
|
||||
copay.logger.setLevel($scope.selectedLogLevel.name);
|
||||
|
||||
|
||||
localstorageService.setItem('config', JSON.stringify({
|
||||
network: insightSettings,
|
||||
version: copay.version,
|
||||
|
|
@ -107,6 +108,7 @@ angular.module('copayApp.controllers').controller('SettingsController', function
|
|||
}), function() {
|
||||
applicationService.restart();
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ angular.module('copayApp.controllers').controller('UnsupportedController',
|
|||
|
||||
var localStorage;
|
||||
if (window.chrome && chrome.runtime && chrome.runtime.id) {
|
||||
console.log('Is a chrome app!');
|
||||
console.log('Is a chrome app!..unssoported.js');
|
||||
localStorage = chrome.storage.local;
|
||||
} else {
|
||||
console.log('Is web!');
|
||||
|
|
|
|||
|
|
@ -76,6 +76,15 @@ Compatibility._decrypt = function(base64, passphrase) {
|
|||
Compatibility._read = function(k, passphrase, cb) {
|
||||
preconditions.checkArgument(cb);
|
||||
|
||||
var localStorage;
|
||||
if (window.chrome && chrome.runtime && chrome.runtime.id) {
|
||||
console.log('Is a chrome app!..Compatibility.js');
|
||||
localStorage = chrome.storage.local;
|
||||
} else {
|
||||
console.log('Is web!');
|
||||
localStorage = window.localStorage;
|
||||
}
|
||||
|
||||
var ret = localStorage.getItem(k);
|
||||
if (!ret) return cb(null);
|
||||
var ret = self._decrypt(ret, passphrase);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ var isChromeApp = window.chrome && chrome.runtime && chrome.runtime.id;
|
|||
function LocalStorage() {
|
||||
this.type = 'DB';
|
||||
|
||||
|
||||
if (isChromeApp) {
|
||||
localStorage = chrome.storage.local;
|
||||
window.localStorage = chrome.storage.local;
|
||||
|
|
|
|||
|
|
@ -119,12 +119,14 @@ angular
|
|||
}
|
||||
$rootScope.$on('$routeChangeStart', function(event, next, current) {
|
||||
|
||||
|
||||
var localStorage;
|
||||
if (window.chrome && chrome.runtime && chrome.runtime.id) {
|
||||
console.log('Is a chrome app!');
|
||||
console.log('Is a chrome app!...routes.js');
|
||||
console.log('chrome.storage', chrome.storage);
|
||||
console.log('chrome.storage.local', chrome.storage.local);
|
||||
localStorage = chrome.storage.local;
|
||||
|
||||
console.log('chrome.storage', chrome.storage);
|
||||
console.log('localStorage', localStorage);
|
||||
} else {
|
||||
console.log('Is web!');
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ factory('notification', ['$timeout',
|
|||
|
||||
var localStorage;
|
||||
if (window.chrome && chrome.runtime && chrome.runtime.id) {
|
||||
console.log('Is a chrome app!');
|
||||
console.log('Is a chrome app!...notification.js');
|
||||
localStorage = chrome.storage.local;
|
||||
} else {
|
||||
console.log('Is web!');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue