fnp
/
ReadingsJQM.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Some fixes for catalogue loading
[ReadingsJQM.git]
/
js
/
app
/
Catalogue.coffee
diff --git
a/js/app/Catalogue.coffee
b/js/app/Catalogue.coffee
index
c556e5b
..
aeef42d
100644
(file)
--- a/
js/app/Catalogue.coffee
+++ b/
js/app/Catalogue.coffee
@@
-7,23
+7,30
@@
class Readings.Catalogue
this
init: (db) ->
this
init: (db) ->
+ unneded_stmts = (stmt, idx) ->
+ stmt.indexOf("PRAGMA")==0 or
+ stmt.indexOf("BEGIN TRANSACTION")==0 or
+ stmt.indexOf("COMMIT")==0 or
+ /^\s*$/.exec stmt
+
if not db?
db = @db
console.log "initializing DB"
db.changeVersion "", Readings.config.get 'db_version'
if not db?
db = @db
console.log "initializing DB"
db.changeVersion "", Readings.config.get 'db_version'
- $.ajax
"initdb.sql"
+ $.ajax
Readings.config.get('initdburl'),
type: "GET"
dataType: 'text'
success: (sql) =>
sql = sql.split /;\n/
type: "GET"
dataType: 'text'
success: (sql) =>
sql = sql.split /;\n/
- sql =
sql.slice(1,-2)
+ sql =
$.grep sql, unneded_stmts, true
create = (tx) =>
for stmt in sql
create = (tx) =>
for stmt in sql
- console.log stmt
tx.executeSql stmt, [],
(tx,rs) => true,
tx.executeSql stmt, [],
(tx,rs) => true,
- (tx,err) => console.error(err)
+ (tx,err) =>
+ console.error("error for #{stmt}")
+ console.error(err)
db.transaction create
error: =>
db.transaction create
error: =>