mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Disable offline page when IndexedDB isn't available
This commit is contained in:
parent
ba09a14ec0
commit
0b56ef1c02
4 changed files with 16 additions and 9 deletions
|
@ -109,16 +109,14 @@ class app.DB
|
||||||
|
|
||||||
versions: (docs, fn) ->
|
versions: (docs, fn) ->
|
||||||
@db (db) ->
|
@db (db) ->
|
||||||
result = {}
|
|
||||||
|
|
||||||
unless db
|
unless db
|
||||||
result[doc.slug] = false for doc in docs
|
fn(false)
|
||||||
fn(result)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
txn = db.transaction ['docs'], 'readonly'
|
txn = db.transaction ['docs'], 'readonly'
|
||||||
txn.oncomplete = -> fn(result)
|
txn.oncomplete = -> fn(result)
|
||||||
store = txn.objectStore('docs')
|
store = txn.objectStore('docs')
|
||||||
|
result = {}
|
||||||
|
|
||||||
docs.forEach (doc) ->
|
docs.forEach (doc) ->
|
||||||
req = store.get(doc.slug)
|
req = store.get(doc.slug)
|
||||||
|
|
|
@ -37,6 +37,7 @@ class app.collections.Docs extends app.Collection
|
||||||
|
|
||||||
getDownloadStatuses: (callback) ->
|
getDownloadStatuses: (callback) ->
|
||||||
app.db.versions @models, (statuses) ->
|
app.db.versions @models, (statuses) ->
|
||||||
for key, value of statuses
|
if statuses
|
||||||
statuses[key] = downloaded: !!value, version: value
|
for key, value of statuses
|
||||||
|
statuses[key] = downloaded: !!value, version: value
|
||||||
callback(statuses)
|
callback(statuses)
|
||||||
|
|
|
@ -22,6 +22,11 @@ app.templates.bootError = ->
|
||||||
""" Check your Internet connection and try <a href="javascript:location.reload()">reloading</a>.<br>
|
""" 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. """
|
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 = """
|
app.templates.unsupportedBrowser = """
|
||||||
<div class="_fail">
|
<div class="_fail">
|
||||||
<h1 class="_fail-title">Your browser is unsupported, sorry.</h1>
|
<h1 class="_fail-title">Your browser is unsupported, sorry.</h1>
|
||||||
|
|
|
@ -11,9 +11,12 @@ class app.views.OfflinePage extends app.View
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
app.docs.getDownloadStatuses (statuses) =>
|
app.docs.getDownloadStatuses (statuses) =>
|
||||||
html = ''
|
if statuses is false
|
||||||
html += @renderDoc(doc, statuses[doc.slug]) for doc in app.docs.all()
|
@html @tmpl('offlineError')
|
||||||
@html @tmpl('offlinePage', html)
|
else
|
||||||
|
html = ''
|
||||||
|
html += @renderDoc(doc, statuses[doc.slug]) for doc in app.docs.all()
|
||||||
|
@html @tmpl('offlinePage', html)
|
||||||
return
|
return
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue