Created
September 27, 2015 17:06
-
-
Save Scuilion/d1609aa3bcdf606be163 to your computer and use it in GitHub Desktop.
Because Learning Deprecated Features is Great
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
<html> | |
<head> | |
<script> | |
var standup = {}; | |
standup.webdb = {}; | |
standup.webdb.db = null; | |
standup.webdb.open = function() { | |
var dbSize = 5 * 1024 * 1024; // 5MB | |
standup.webdb.db = openDatabase("Standup", "1", "standup manager", dbSize); | |
} | |
standup.webdb.onError = function(tx, e) { | |
alert("there has been and error: " + e.message); | |
} | |
standup.webdb.onSuccess = function(tx, r) { | |
var loadDailyStatusItems = function(tx, rs) { | |
var rowOutput; | |
var mainDiv = document.getElementById("dailyStatus"); | |
for (var i=0; i < rs.rows.length; i++) { | |
rowOutput += rs.rows[i].ID + ': ' + rs.rows[i].NAME + ': ' + rs.rows[i].added_on + "</br>"; | |
//rowOutput += JSON.stringify(rs.rows[i], null, 2); | |
} | |
mainDiv.innerHTML = rowOutput; | |
} | |
standup.webdb.getAllDailyStatusItems(loadDailyStatusItems); | |
} | |
standup.webdb.getAllDailyStatusItems = function(renderFunc) { | |
var db = standup.webdb.db; | |
db.transaction(function(tx) { | |
tx.executeSql("SELECT * FROM standup", [], renderFunc, | |
standup.webdb.onError); | |
}); | |
} | |
standup.webdb.createTable = function() { | |
var db = standup.webdb.db; | |
db.transaction(function(tx) { | |
tx.executeSql("DROP TABLE standup"); | |
tx.executeSql("CREATE TABLE IF NOT EXISTS " + | |
"standup(ID INTEGER PRIMARY KEY ASC, " + | |
"NAME varchar(20), added_on DATETIME)", []); | |
}); | |
} | |
standup.webdb.addStatus = function(dailyStatus) { | |
var db = standup.webdb.db; | |
db.transaction(function(tx){ | |
var addedOn = new Date(); | |
tx.executeSql("INSERT INTO standup(name, added_on) VALUES(?, ?)", | |
[dailyStatus, addedOn], | |
standup.webdb.onSuccess, | |
standup.webdb.onError); | |
}); | |
} | |
standup.webdb.init = function() { | |
standup.webdb.open(); | |
standup.webdb.createTable(); | |
//standup.webdb.addStatus("something"); | |
//standup.webdb.addStatus("another thing"); | |
} | |
</script> | |
</head> | |
<body onload="standup.webdb.init()"> | |
Here is a title | |
<div id="dailyStatus"/> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment