137
function clearMultiLocation(locations) {
140
db.transaction(function (tx) {
141
// Remove all the deleted indexes
142
for (var i=0; i < locations.length; i++) {
143
tx.executeSql('DELETE FROM Locations WHERE id=?;', [locations[i]])
146
// Rebuild locations in order
147
var rs = tx.executeSql('SELECT id FROM Locations ORDER BY id ASC')
149
for (i=0; i < rs.rows.length; i++) {
150
tx.executeSql('UPDATE Locations SET id=? WHERE id=?;',
151
[i, rs.rows.item(i).id])
137
156
function clearDB() { // for dev purposes
139
158
db.transaction(function(tx){
140
159
tx.executeSql('DELETE FROM Locations WHERE 1');
163
function reorder(from, to) {
166
db.transaction(function(tx) {
167
// Track to move put as -1 for now
168
tx.executeSql('UPDATE Locations SET id=? WHERE id=?;',
171
// Shuffle locations inbetween from->to
173
for (var i = from-1; i >= to; i--) {
174
tx.executeSql('UPDATE Locations SET id=? WHERE id=?;',
178
for (var j = from+1; j <= to; j++) {
179
tx.executeSql('UPDATE Locations SET id=? WHERE id=?;',
184
// Switch moving location to its new position
185
tx.executeSql('UPDATE Locations SET id=? WHERE id=?;',