MCPcopy
hub / github.com/ampproject/amphtml / constructor

Method constructor

examples/pwa/pwa.js:15–54  ·  view source on GitHub ↗
(win, useStreaming)

Source from the content-addressed store, hash-verified

13
14class 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) {

Callers

nothing calls this directly

Calls 7

navigateToMethod · 0.95
isShellUrlFunction · 0.85
logFunction · 0.70
parseQueryStringFunction · 0.70
getElementByIdMethod · 0.45
addEventListenerMethod · 0.45

Tested by

no test coverage detected