· 8 years ago · Nov 24, 2017, 03:54 PM
1WorkerScript.onMessage = function findNotes(msg)
2{
3 var db = openDatabaseSync("CoordinoteDB", "1.0", "Coordinotedb", 1000000);
4
5 db.transaction
6 (
7 function(tx)
8 {
9 // Create the database if it doesn't already exist
10 tx.executeSql('CREATE TABLE IF NOT EXISTS Coordinotes(caption TEXT, note TEXT, date INTEGER, tags INTEGER, lat REAL, lon REAL)');
11
12 // Add (another) greeting row
13 //tx.executeSql('INSERT INTO Coordinotes VALUES(?, ?, ?, ?, ?, ?)', [ 'caption', 'note', 'imgpath', '111284', '22', '25.2', '23.1' ]);
14
15 // Show all added rows
16 var rs = tx.executeSql('SELECT * FROM Coordinotes');
17
18 for(var i = 0; i < rs.rows.length; i++)
19 {
20 //r += rs.rows.item(i).comment + ", " + rs.rows.item(i).imgpath + "\n"
21 msg.model.append
22 (
23 {
24 "comment": rs.rows.item(i).comment, "imgpath": rs.rows.item(i).imgpath,
25 "datum":rs.rows.item(i).date, "tags":rs.rows.item(i).tags,
26 "lat":rs.rows.item(i).lat,"lon":rs.rows.item(i).lon
27
28 }
29 )
30 msg.model.sync();
31
32 }
33
34 }
35 )
36
37}