Disable offline page when IndexedDB isn't available

This commit is contained in:
Thibaut 2015-01-01 17:22:35 -05:00
parent ba09a14ec0
commit 0b56ef1c02
4 changed files with 16 additions and 9 deletions

View file

@ -109,16 +109,14 @@ class app.DB
versions: (docs, fn) ->
@db (db) ->
result = {}
unless db
result[doc.slug] = false for doc in docs
fn(result)
fn(false)
return
txn = db.transaction ['docs'], 'readonly'
txn.oncomplete = -> fn(result)
store = txn.objectStore('docs')
result = {}
docs.forEach (doc) ->
req = store.get(doc.slug)

View file

@ -37,6 +37,7 @@ class app.collections.Docs extends app.Collection
getDownloadStatuses: (callback) ->
app.db.versions @models, (statuses) ->
for key, value of statuses
statuses[key] = downloaded: !!value, version: value
if statuses
for key, value of statuses
statuses[key] = downloaded: !!value, version: value
callback(statuses)

View file

@ -22,6 +22,11 @@ app.templates.bootError = ->
""" Check your Internet connection and try <a href="javascript:location.reload()">reloading</a>.<br>
If you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """
app.templates.offlineError = ->
error """ Your browser is unsupported, sorry. """,
""" DevDocs uses IndexedDB to cache complete documentations for offline access.<br>
Unfortunately your browser either doesn't support IndexedDB, or its implementation is buggy. """
app.templates.unsupportedBrowser = """
<div class="_fail">
<h1 class="_fail-title">Your browser is unsupported, sorry.</h1>

View file

@ -11,9 +11,12 @@ class app.views.OfflinePage extends app.View
render: ->
app.docs.getDownloadStatuses (statuses) =>
html = ''
html += @renderDoc(doc, statuses[doc.slug]) for doc in app.docs.all()
@html @tmpl('offlinePage', html)
if statuses is false
@html @tmpl('offlineError')
else
html = ''
html += @renderDoc(doc, statuses[doc.slug]) for doc in app.docs.all()
@html @tmpl('offlinePage', html)
return
return