Skip to content

Instantly share code, notes, and snippets.

@greenido
Created October 5, 2012 12:32
Show Gist options
  • Select an option

  • Save greenido/3839587 to your computer and use it in GitHub Desktop.

Select an option

Save greenido/3839587 to your computer and use it in GitHub Desktop.
function addTodo() {
var todo = document.getElementById("todo");
todoDB.indexedDB.addTodo(todo.value);
todo.value = "";
}
todoDB.indexedDB.addTodo = function(todoText) {
var db = todoDB.indexedDB.db;
var trans = db.transaction(['todo'], "readwrite");
var store = trans.objectStore("todo");
var data = {
"text": todoText,
"timeStamp": new Date().getTime()
};
var request = store.put(data);
request.onsuccess = function(e) {
todoDB.indexedDB.getAllTodoItems();
};
request.onerror = function(e) {
console.log("Error Adding: ", e);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment