Creo en nosotros. Wikipedia.
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

1 (function(window){2 3  var _db = null;4  var _name = 'casper';5  var _store = 'StaticMap';6  var _version = 16;7  var _size = 5 * 1024 * 1024;8 9  // Allow other browsers:10  window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;11 12  window.staticMap = {13  'open':function(callback) {14  _db = openDatabase("todo", "1.0", "Todo manager", _size);15 16  var transaction = _db.transaction(function(tx) {17  tx.executeSql("CREATE TABLE IF NOT EXISTS " +18  "todo(ID INTEGER PRIMARY KEY ASC, todo TEXT, added_on DATETIME)", []);19  callback(true);20  });21  22  },23  'get':function(key, callback) {24  _db.transaction(function(tx) {25  tx.executeSql(26  "SELECT * FROM todo",27  [],28  function(tx, rs) {29  for (var i=0; i < rs.rows.length; i++) {30  callback(rs.rows.item(i).todo);31  }32  },33  function(){alert('GET ERROR'); callback(null);}34  );35  });36  },37  38  'set':function(key, value, callback) {39  _db.transaction(function(tx){40  tx.executeSql("INSERT INTO todo(todo, added_on) VALUES (?,?)",41  [value, new Date()],42  function(){callback(true);},43  function(){callback(false);}44  );45  });46  },47  'unset':function(key, callback) {48  var request = _db.transaction([_store], "readwrite").objectStore(_store).delete(key);49  request.onsuccess = function(event) {50  callback(false);51  };52  }53  }54 55 }(this))
Enlace
El enlace para compartir es: