Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html xmlns="http://www.w3.org/1999/xhtml" lang="es" manifest="cache.manifest">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>HTML5 Offline Storage Experiment - Notes panel</title>
- <link href="websql.css" rel="stylesheet" type="text/css" />
- <script type="text/javascript" src="storage.js"></script>
- <script>
- var html5rocks = {};
- html5rocks.webdb = {};
- html5rocks.webdb.db = null;
- html5rocks.webdb.open = function() {
- var dbSize = 5 * 1024 * 1024; // 5MB
- html5rocks.webdb.db = openDatabase("Todo", "1.0", "Todo manager", dbSize);
- }
- html5rocks.webdb.createTable = function() {
- var db = html5rocks.webdb.db;
- db.transaction(function(tx) {
- tx.executeSql("CREATE TABLE IF NOT EXISTS todo(ID INTEGER PRIMARY KEY ASC, todo TEXT, added_on DATETIME)", []);
- });
- }
- html5rocks.webdb.addTodo = function(todoText) {
- var db = html5rocks.webdb.db;
- db.transaction(function(tx){
- var addedOn = new Date();
- tx.executeSql("INSERT INTO todo(todo, added_on) VALUES (?,?)",
- [todoText, addedOn],
- html5rocks.webdb.onSuccess,
- html5rocks.webdb.onError);
- });
- }
- html5rocks.webdb.onError = function(tx, e) {
- alert("There has been an error: " + e.message);
- }
- html5rocks.webdb.onSuccess = function(tx, r) {
- alert ("success");
- }
- try {
- if (window.openDatabase) {
- var dbSize = 1024 * 1024; // 5MB
- html5rocks.webdb.db = openDatabase("Todo", "1.0", "Todo manager", dbSize);
- db = html5rocks.webdb.db;
- if (!db)
- alert("Failed to open the database on disk. This is probably because the version was bad or there is not enough space left in this domain's quota");
- } else
- alert("Couldn't open the database. Please try with a WebKit nightly with this feature enabled");
- } catch(err) {
- db = null;
- alert("Couldn't open the database. Please try with a WebKit nightly with this feature enabled");
- }
- html5rocks.webdb.open();
- html5rocks.webdb.createTable();
- </script>
- </head>
- <body>
- <header>
- Asi sÃ! :-) -- !! --
- </header>
- <h2>HTML5 App Cache Events</h2>
- <button id="installButton">Check for Updates</button>
- <div id="info"></div>
- <div id="status"><p id="state"></p></div>
- <form name="note_form" id="notes_form" action="#">
- </form>
- <ul id="todoItems"></ul>
- <input type="text" id="todo" name="todo" placeholder="What do you need to do?" style="width: 200px;" />
- <input type="submit" value="Add Todo Item" onclick="html5rocks.webdb.addTodo(); return false;"/>
- <div id="notes"></div>
- <div id="todo"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement