app . templates . offlinePage = ( docs ) => ` \
< h1 class = "_lined-heading" > Offline Documentation < / h 1 >
< div class = "_docs-tools" >
< label >
< input type = "checkbox" name = "autoUpdate" value = "1" $ {
app . settings . get ( "manualUpdate" ) ? "" : "checked"
} > Install updates automatically
< / l a b e l >
< div class = "_docs-links" >
< button type = "button" class = "_btn-link" data - action - all = "install" > Install all < / b u t t o n > < b u t t o n t y p e = " b u t t o n " c l a s s = " _ b t n - l i n k " d a t a - a c t i o n - a l l = " u p d a t e " > < s t r o n g > U p d a t e a l l < / s t r o n g > < / b u t t o n > < b u t t o n t y p e = " b u t t o n " c l a s s = " _ b t n - l i n k " d a t a - a c t i o n - a l l = " u n i n s t a l l " > U n i n s t a l l a l l < / b u t t o n >
< / d i v >
< / d i v >
< div class = "_table" >
< table class = "_docs" >
< tr >
< th > Documentation < / t h >
< th class = "_docs-size" > Size < / t h >
< th > Status < / t h >
< th > Action < / t h >
< / t r >
$ { docs }
< / t a b l e >
< / d i v >
< p class = "_note" > < strong > Note : < / s t r o n g > y o u r b r o w s e r m a y d e l e t e D e v D o c s ' s o f f l i n e d a t a i f y o u r c o m p u t e r i s r u n n i n g l o w o n d i s k s p a c e a n d y o u h a v e n ' t u s e d t h e a p p i n a w h i l e . L o a d t h i s p a g e b e f o r e g o i n g o f f l i n e t o m a k e s u r e t h e d a t a i s s t i l l t h e r e .
< h2 class = "_block-heading" > Questions & Answers < / h 2 >
< dl >
< dt > How does this work ?
< dd > Each page is cached as a key - value pair in < a href = "https://devdocs.io/dom/indexeddb_api" > IndexedDB < / a > ( d o w n l o a d e d f r o m a s i n g l e f i l e ) . < b r >
The app also uses < a href = "https://devdocs.io/dom/service_worker_api/using_service_workers" > Service Workers < /a> and <a href="https:/ / devdocs . io / dom / web _storage _api " > localStorage < / a > t o c a c h e t h e a s s e t s a n d i n d e x f i l e s .
< dt > Can I close the tab / browser ?
< dd > $ { canICloseTheTab ( ) }
< dt > What if I don ' t update a documentation ?
< dd > You 'll see outdated content and some pages will be missing or broken, because the rest of the app (including data for the search and sidebar) uses a different caching mechanism that' s updated automatically .
< dt > I found a bug , where do I report it ?
< dd > In the < a href = "https://github.com/freeCodeCamp/devdocs/issues" > issue tracker < / a > . T h a n k s !
< dt > How do I uninstall / reset the app ?
< dd > Click < a href = "#" data - behavior = "reset" > here < / a > .
< dt > Why aren ' t all documentations listed above ?
< dd > You have to < a href = "/settings" > enable < / a > t h e m f i r s t .
< / d l > \
` ;
var canICloseTheTab = function ( ) {
if ( app . ServiceWorker . isEnabled ( ) ) {
return ' Yes! Even offline, you can open a new tab, go to <a href="//devdocs.io">devdocs.io</a>, and everything will work as if you were online (provided you installed all the documentations you want to use beforehand). ' ;
} else {
let reason = "aren't available in your browser (or are disabled)" ;
if ( app . config . env !== "production" ) {
reason =
"are disabled in your development instance of DevDocs (enable them by setting the <code>ENABLE_SERVICE_WORKER</code> environment variable to <code>true</code>)" ;
}
return ` No. Service Workers ${ reason } , so loading <a href="//devdocs.io">devdocs.io</a> offline won't work.<br>
The current tab will continue to function even when you go offline ( provided you installed all the documentations beforehand ) . ` ;
}
} ;
app . templates . offlineDoc = function ( doc , status ) {
const outdated = doc . isOutdated ( status ) ;
let html = ` \
< tr data - slug = "${doc.slug}" $ { outdated ? ' class="_highlight"' : "" } >
< td class = "_docs-name _icon-${doc.icon}" > $ { doc . fullName } < / t d >
< td class = "_docs-size" > $ {
Math . ceil ( doc . db _size / 100000 ) / 10
} & nbsp ; < small > MB < / s m a l l > < / t d > \
` ;
html += ! ( status && status . installed )
? ` \
< td > - < / t d >
< td > < button type = "button" class = "_btn-link" data - action = "install" > Install < / b u t t o n > < / t d > \
`
: outdated
? ` \
< td > < strong > Outdated < / s t r o n g > < / t d >
< td > < button type = "button" class = "_btn-link _bold" data - action = "update" > Update < / b u t t o n > - < b u t t o n t y p e = " b u t t o n " c l a s s = " _ b t n - l i n k " d a t a - a c t i o n = " u n i n s t a l l " > U n i n s t a l l < / b u t t o n > < / t d > \
`
: ` \
< td > Up & # 8209 ; to & # 8209 ; date < / t d >
< td > < button type = "button" class = "_btn-link" data - action = "uninstall" > Uninstall < / b u t t o n > < / t d > \
` ;
return html + "</tr>" ;
} ;