mirror of
https://github.com/moparisthebest/PhoneGap-SQLitePlugin-Android
synced 2024-11-26 02:22:15 -05:00
112 lines
3.7 KiB
HTML
112 lines
3.7 KiB
HTML
<!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>PhoneGap</title>
|
|
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
|
<script type="text/javascript" charset="utf-8" src="cordova-1.5.0.js"></script>
|
|
<script type="text/javascript" charset="utf-8" src="SQLitePlugin.js"></script>
|
|
<script type="text/javascript" charset="utf-8" src="main.js"></script>
|
|
|
|
|
|
<script type="text/javascript" charset="utf-8" >
|
|
|
|
function init1test() {
|
|
//alert("alert 0");
|
|
}
|
|
|
|
// Wait for PhoneGap to load
|
|
//
|
|
document.addEventListener("deviceready", onDeviceReady, false);
|
|
|
|
// PhoneGap is ready
|
|
//
|
|
function onDeviceReady() {
|
|
var db = window.sqlitePlugin.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
|
|
|
|
db.transaction(function(tx) {
|
|
|
|
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)');
|
|
|
|
|
|
return 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");
|
|
|
|
tx.executeSql("select count(id) as cnt from test_table;", [], function(tx, res) {
|
|
console.log("rows.length: " + res.rows.length + " -- should be 1");
|
|
return console.log("rows[0].cnt: " + res.rows.item(0).cnt + " -- should be 1");
|
|
});
|
|
|
|
}, function(e) {
|
|
return console.log("ERROR: " + e.message);
|
|
});
|
|
});
|
|
|
|
|
|
}
|
|
|
|
// Populate the database
|
|
//
|
|
function populateDB(tx) {
|
|
alert("a 3");
|
|
tx.executeSql('DROP TABLE IF EXISTS DEMO');
|
|
alert("a 4");
|
|
tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
|
|
alert("a 5");
|
|
tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
|
|
alert("a 6");
|
|
tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
|
|
alert("a 7");
|
|
|
|
|
|
|
|
}
|
|
|
|
// Transaction error callback
|
|
//
|
|
function errorCB(tx, err) {
|
|
alert("Error processing SQL: "+err);
|
|
}
|
|
|
|
// Transaction success callback
|
|
//
|
|
function successCB() {
|
|
alert("success!");
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</head>
|
|
<body onload="init1test();" id="stage" class="theme">
|
|
<h1>Welcome to PhoneGap!</h1>
|
|
<h2>this file is located at assets/www/index.html</h2>
|
|
<div id="info">
|
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
|
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
|
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
|
</div>
|
|
<dl id="accel-data">
|
|
<dt>X:</dt><dd id="x"> </dd>
|
|
<dt>Y:</dt><dd id="y"> </dd>
|
|
<dt>Z:</dt><dd id="z"> </dd>
|
|
</dl>
|
|
<a href="#" class="btn large" onclick="toggleAccel();">Toggle Accelerometer</a>
|
|
<a href="#" class="btn large" onclick="getLocation();">Get Location</a>
|
|
<a href="tel:411" class="btn large">Call 411</a>
|
|
<a href="#" class="btn large" onclick="beep();">Beep</a>
|
|
<a href="#" class="btn large" onclick="vibrate();">Vibrate</a>
|
|
<a href="#" class="btn large" onclick="show_pic();">Get a Picture</a>
|
|
<a href="#" class="btn large" onclick="get_contacts();">Get Phone's Contacts</a>
|
|
<a href="#" class="btn large" onclick="check_network();">Check Network</a>
|
|
<div id="viewport" class="viewport" style="display: none;">
|
|
<img style="width:60px;height:60px" id="test_img" src="" />
|
|
</div>
|
|
</body>
|
|
</html>
|