[ Launch: indexedDB testt ] 6472300 by enjalot
-
-
Save enjalot/6472300 to your computer and use it in GitHub Desktop.
indexedDB testt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"indexedDB testt","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/PSJH9hL.png"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var db; | |
window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB; | |
window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.msIDBTransaction; | |
window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange; | |
if (!window.indexedDB) { alert("Sorry!Your browser doesn't support IndexedDB"); } | |
function go() { | |
console.log("go") | |
var objectStore = database.transaction("notes").objectStore("notes"); | |
objectStore.openCursor().onsuccess = function(event) { | |
var cursor = event.target.result; | |
console.log("CURSOR", cursor) | |
}; | |
} | |
init(); | |
function init(){ | |
var request = window.indexedDB.open("notepad",1); | |
request.onerror = function(event) { | |
console.log(event.target.errorCode); | |
}; | |
request.onsuccess = function(event) { | |
database=request.result; | |
go(); | |
}; | |
request.onupgradeneeded = function(event) { | |
console.log("UPGRADE") | |
var db = event.target.result; | |
var objectStore = db.createObjectStore("notes", { keyPath: "id",autoIncrement:true}); | |
}; | |
} | |
function addNote(note){ | |
var transaction = database.transaction(["notes"], "readwrite"); | |
var objectStore = transaction.objectStore("notes"); | |
var request=objectStore.put(note); | |
request.onsuccess = function(event) { | |
document.getElementById("flag").value="0"; | |
window.location.href="index.html"; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment