(win, useStreaming)
| 13 | |
| 14 | class Shell { |
| 15 | constructor(win, useStreaming) { |
| 16 | /** @private @const {!Window} */ |
| 17 | this.win = win; |
| 18 | |
| 19 | /** @private @const {boolean} */ |
| 20 | this.useStreaming_ = useStreaming; |
| 21 | |
| 22 | /** @private @const {!AmpViewer} */ |
| 23 | this.ampViewer_ = new AmpViewer( |
| 24 | win, |
| 25 | win.document.getElementById('doc-container') |
| 26 | ); |
| 27 | |
| 28 | /** @private {string} */ |
| 29 | this.currentPage_ = win.location.pathname; |
| 30 | |
| 31 | this.sidebarCloseButton_ = document.querySelector('#sidebarClose'); |
| 32 | |
| 33 | win.addEventListener('popstate', this.handlePopState_.bind(this)); |
| 34 | win.document.documentElement.addEventListener( |
| 35 | 'click', |
| 36 | this.handleNavigate_.bind(this) |
| 37 | ); |
| 38 | |
| 39 | log('Shell created'); |
| 40 | |
| 41 | if (this.currentPage_ && !isShellUrl(this.currentPage_)) { |
| 42 | this.navigateTo(this.currentPage_); |
| 43 | } else if (this.win.location.hash) { |
| 44 | const hashParams = parseQueryString(this.win.location.hash); |
| 45 | const href = hashParams['href']; |
| 46 | if (href) { |
| 47 | this.currentPage_ = href; |
| 48 | this.navigateTo(href); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | // Install service worker |
| 53 | this.registerServiceWorker_(); |
| 54 | } |
| 55 | |
| 56 | registerServiceWorker_() { |
| 57 | if ('serviceWorker' in navigator) { |
nothing calls this directly
no test coverage detected