Showing the changes to assets/javascripts (2 of 2 files). Show all
Unified · Split
| @@ -60,7 +60,9 @@ class app.DB · 59 unmodified lines | |||
| 60 | return | 60 | return |
| 61 | 61 | ||
| 62 | txn = db.transaction ['docs', doc.slug], 'readwrite' | 62 | txn = db.transaction ['docs', doc.slug], 'readwrite' |
| 63 | txn.oncomplete = -> if txn.error then onError() else onSuccess() | 63 | txn.oncomplete = -> |
| 64 | if txn.error then onError() else onSuccess() | ||
| 65 | return | ||
| 64 | 66 | ||
| 65 | store = txn.objectStore(doc.slug) | 67 | store = txn.objectStore(doc.slug) |
| 66 | store.clear() | 68 | store.clear() |
| @@ -78,7 +80,9 @@ class app.DB · 11 unmodified lines | |||
| 78 | return | 80 | return |
| 79 | 81 | ||
| 80 | txn = db.transaction ['docs', doc.slug], 'readwrite' | 82 | txn = db.transaction ['docs', doc.slug], 'readwrite' |
| 81 | txn.oncomplete = -> if txn.error then onError() else onSuccess() | 83 | txn.oncomplete = -> |
| 84 | if txn.error then onError() else onSuccess() | ||
| 85 | return | ||
| 82 | 86 | ||
| 83 | store = txn.objectStore(doc.slug) | 87 | store = txn.objectStore(doc.slug) |
| 84 | store.clear() | 88 | store.clear() |
| @@ -154,6 +158,7 @@ class app.DB · 69 unmodified lines | |||
| 154 | 158 | ||
| 155 | reset: -> | 159 | reset: -> |
| 156 | try indexedDB?.deleteDatabase(NAME) catch | 160 | try indexedDB?.deleteDatabase(NAME) catch |
| 161 | return | ||
| 157 | 162 | ||
| 158 | useIndexedDB: -> | 163 | useIndexedDB: -> |
| 159 | !app.isSingleDoc() and !!window.indexedDB | 164 | !app.isSingleDoc() and !!window.indexedDB |
| @@ -54,6 +54,7 @@ class app.models.Doc extends app.Model · 53 unmodified lines | |||
| 54 | @reset data | 54 | @reset data |
| 55 | onSuccess() | 55 | onSuccess() |
| 56 | @_setCache data if options.writeCache | 56 | @_setCache data if options.writeCache |
| 57 | return | ||
| 57 | 58 | ||
| 58 | ajax | 59 | ajax |
| 59 | url: @indexUrl() | 60 | url: @indexUrl() |
| @@ -70,6 +71,7 @@ class app.models.Doc extends app.Model · 10 unmodified lines | |||
| 70 | callback = => | 71 | callback = => |
| 71 | @reset data | 72 | @reset data |
| 72 | onSuccess() | 73 | onSuccess() |
| 74 | return | ||
| 73 | 75 | ||
| 74 | setTimeout callback, 0 | 76 | setTimeout callback, 0 |
| 75 | true | 77 | true |
| @@ -94,10 +96,12 @@ class app.models.Doc extends app.Model · 18 unmodified lines | |||
| 94 | error = => | 96 | error = => |
| 95 | @downloading = null | 97 | @downloading = null |
| 96 | onError() | 98 | onError() |
| 99 | return | ||
| 97 | 100 | ||
| 98 | success = (data) => | 101 | success = (data) => |
| 99 | @downloading = null | 102 | @downloading = null |
| 100 | app.db.store @, data, onSuccess, error | 103 | app.db.store @, data, onSuccess, error |
| 104 | return | ||
| 101 | 105 | ||
| 102 | ajax | 106 | ajax |
| 103 | url: @dbUrl() | 107 | url: @dbUrl() |
| @@ -112,13 +116,17 @@ class app.models.Doc extends app.Model · 8 unmodified lines | |||
| 112 | success = => | 116 | success = => |
| 113 | @downloading = null | 117 | @downloading = null |
| 114 | onSuccess() | 118 | onSuccess() |
| 119 | return | ||
| 115 | 120 | ||
| 116 | error = => | 121 | error = => |
| 117 | @downloading = null | 122 | @downloading = null |
| 118 | onError() | 123 | onError() |
| 124 | return | ||
| 119 | 125 | ||
| 120 | app.db.unstore @, success, error | 126 | app.db.unstore @, success, error |
| 127 | return | ||
| 121 | 128 | ||
| 122 | getDownloadStatus: (callback) -> | 129 | getDownloadStatus: (callback) -> |
| 123 | app.db.version @, (value) -> | 130 | app.db.version @, (value) -> |
| 124 | callback downloaded: !!value, version: value | 131 | callback downloaded: !!value, version: value |
| 132 | return | ||