mirror of
https://github.com/moparisthebest/PhoneGap-SQLitePlugin-Android
synced 2024-11-29 03:42:15 -05:00
186 lines
5.5 KiB
HTML
186 lines
5.5 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 src="lib/qunit.js"></script>
|
|
<script src="lib/json2.js"></script>
|
|
<script src="lib/lawnchair.js"></script>
|
|
|
|
<script src="webkit-sqlite.js"></script>
|
|
<script src="lawnchair-spec.js"></script>
|
|
|
|
<!--
|
|
<script type="text/javascript" charset="utf-8" src="main.js"></script>
|
|
-->
|
|
|
|
|
|
<script type="text/javascript" charset="utf-8" >
|
|
|
|
|
|
|
|
// autostart seems to be a little eager
|
|
QUnit.config.autostart = false
|
|
|
|
// kill qunit saves
|
|
try{ sessionStorage.clear(); } catch(e){}
|
|
|
|
var store;
|
|
|
|
function startTests() {
|
|
|
|
// allow restriction of adapter in URL (e.g., ?adapter=ie-userdata)
|
|
var allowed = /adapter=([-\w]+)/.exec(window.location.href),
|
|
adapters = Lawnchair.adapters,
|
|
i;
|
|
|
|
if (allowed) {
|
|
for (i = 0; i < adapters.length; ) {
|
|
if (adapters[i].adapter == allowed[1]) {
|
|
i++;
|
|
} else {
|
|
adapters.splice(i, 1)
|
|
}
|
|
}
|
|
|
|
if (adapters.length == 0) {
|
|
alert("no such adapter: " + allowed[1]);
|
|
}
|
|
|
|
if (!adapters[0].valid()) {
|
|
alert("adapter " + allowed[1] + " is not valid in this environment");
|
|
}
|
|
}
|
|
|
|
// kickup the chair
|
|
store = new Lawnchair({name:'tests'}, function(){
|
|
QUnit.start()
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function start1() {
|
|
|
|
document.addEventListener("deviceready", startTests, false);
|
|
}
|
|
|
|
/**
|
|
|
|
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);
|
|
var db = window.my_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="start1()">
|
|
<h1 id="qunit-header">Lawnchair Spec</h1>
|
|
<h2 id="qunit-banner"></h2>
|
|
<h2 id="qunit-userAgent"></h2>
|
|
<ol id="qunit-tests"></ol>
|
|
</body>
|
|
|
|
|
|
<!--
|
|
<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>
|