PhoneGap-SQLitePlugin-Android/Android/assets/www/index.html

66 lines
1.9 KiB
HTML
Raw Normal View History

2012-05-05 11:06:30 -04:00
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>SQLitePlugin test</title>
<link rel="stylesheet" href="lib/qunit-1.5.0.css" />
2012-05-05 11:06:30 -04:00
<script type="text/javascript" charset="utf-8" src="phonegap-1.1.0.js"></script>
<script type="text/javascript" charset="utf-8" src="SQLitePlugin.js"></script>
<script type="text/javascript" charset="utf-8" src="lib/qunit-1.5.0.js"></script>
2012-05-05 11:06:30 -04:00
<script>
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
test( "hello test", function() {
ok( 1 == "1", "Passed!" );
});
test( "db transaction test", function() {
2012-05-05 11:06:30 -04:00
var db = window.sqlitePlugin.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
ok(!!db, "db object");
stop(1);
2012-05-05 11:06:30 -04:00
db.transaction(function(tx) {
start(1);
ok(!!tx, "tx object");
2012-05-05 11:06:30 -04:00
tx.executeSql('DROP TABLE IF EXISTS test_table');
tx.executeSql('CREATE TABLE IF NOT EXISTS test_table (id integer primary key, data text, data_num integer)');
tx.executeSql("INSERT INTO test_table (data, data_num) VALUES (?,?)", ["test", 100], function(tx, res) {
console.log("insertId: " + res.insertId + " -- probably 1");
console.log("rowsAffected: " + res.rowsAffected + " -- should be 1");
db.transaction(function(tx) {
tx.executeSql("select count(id) as cnt from test_table;", [], function(tx, res) {
console.log("res.rows.length: " + res.rows.length + " -- should be 1");
console.log("res.rows.item(0).cnt: " + res.rows.item(0).cnt + " -- should be 1");
});
});
}, function(e) {
console.log("ERROR: " + e.message);
});
});
});
2012-05-05 11:06:30 -04:00
}
</script>
</head>
<body>
<div id="qunit"></div>
2012-05-05 11:06:30 -04:00
</body>
</html>