Enable extension to sync files using chrome.storage.sync

pull/1/head
d11e9 9 years ago
parent e44ceb831c
commit 2206248143
  1. 32
      assets/js/app.js
  2. 11
      background.js
  3. 1
      index.html
  4. 14
      manifest.json

@ -51,6 +51,36 @@
}
// ----------------- storage --------------------
function syncStorage() {
var obj = {}
function check(key){
chrome.storage.sync.get( key, function(resp){
console.log("comparing to cloud", resp)
if (obj[key] !== resp[key] && confirm("Overwrite '" + fileNameFromKey(key) + "' from cloud storage?")) {
console.log("Overwriting", key )
localStorage.setItem( key, resp[key] );
updateFiles();
}
})
}
for (var y in window.localStorage) {
console.log("checking", y)
obj[y] = window.localStorage.getItem(y);
if (y.indexOf(SOL_CACHE_FILE_PREFIX) !== 0) continue;
check(y)
}
}
window.syncStorage = syncStorage;
if (chrome && chrome.storage && chrome.storage.sync) syncStorage()
// ----------------- editor ----------------------
@ -801,4 +831,6 @@
return funABI;
};
syncStorage()
});

@ -1,5 +1,10 @@
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.create({'url': chrome.extension.getURL('index.html')}, function(tab) {
// tab opened
});
chrome.storage.sync.set({"chrome-app-sync": true});
chrome.tabs.create({'url': chrome.extension.getURL('index.html')}, function(tab) {
// tab opened
});
});

@ -33,6 +33,7 @@
<link rel="stylesheet" href="assets/css/universal-dapp.css">
<link rel="stylesheet" href="assets/css/browser-solidity.css">
<link rel="stylesheet" href="assets/css/font-awesome.min.css">
<link rel="icon" type="x-icon" href="icon.png">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<script src="https://ethereum.github.io/solc-bin/bin/list.js"></script>

@ -5,24 +5,28 @@
"description": "Realtime compiler and runtime",
"devtools_page": "devtools.html",
"update_url": "https://chriseth.github.io/browser-solidity/",
"version": "1.0",
"version": "1.1",
"manifest_version": 2,
"background": {
"scripts": ["background.js"],
"persistent": true
},
"icons": {
"32": "icon.png"
},
"browser_action": {
"default_icon": "icon.png"
},
"permissions": [
"storage",
"tabs",
"activeTab",
"https://ajax.googleapis.com/",
"webRequest",
"webRequestBlocking",
"\u003Call_urls>",
"storage"
"webRequest",
"webRequestBlocking",
"\u003Call_urls>"
]
}

Loading…
Cancel
Save