33 lines
832 B
JavaScript
33 lines
832 B
JavaScript
'use strict'
|
|
|
|
const IPFS = require('ipfs')
|
|
|
|
|
|
function App() {
|
|
let node
|
|
|
|
create()
|
|
|
|
function create() {
|
|
if ('serviceWorker' in navigator) {
|
|
navigator.serviceWorker.register('/ipfs/fetcher.js')
|
|
.then((registration) => {
|
|
console.log('registered the service worker successfully')
|
|
|
|
// Now that a service worker is registered to intercept URLs, reload the page so
|
|
// this page's URL gets loaded from IPFS by the service worker.
|
|
if (window.location.pathname.startsWith('/ipfs/')) {
|
|
window.location.reload(false)
|
|
}
|
|
})
|
|
.catch((err) => {
|
|
console.log('failed to register the service worker:', err)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = App
|
|
|
|
App()
|