Skip to content

Instantly share code, notes, and snippets.

@hpstuff
Last active August 29, 2015 14:05
Show Gist options
  • Save hpstuff/cb55233e7097cab0efdd to your computer and use it in GitHub Desktop.
Save hpstuff/cb55233e7097cab0efdd to your computer and use it in GitHub Desktop.
Icomoon local data save
var dbrequest = indexedDB.open("IDBWrapper-storage", 1);
var db;
dbrequest.onsuccess = function(e) {
db = e.target.result;
};
function getData(){
var trans = db.transaction(["storage"], "readwrite");
var store = trans.objectStore("storage");
var request = store.get('icomoon');
request.onsuccess = function(event){
console.log("Result", request.result);
var blob = new Blob([JSON.stringify(request.result)]);
window.location.href = window.URL.createObjectURL(blob);
};
}
function loadData(data){
var trans = db.transaction(["storage"], "readwrite");
var store = trans.objectStore("storage");
var request = store.put(JSON.parse(data));
request.onsuccess = function(event){
console.log("Result", request.result);
};
request.onerror = function(){
console.log(event);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment