Skip to content

Commit

Permalink
fixup: [spec] npm run build
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed May 23, 2022
1 parent 55b3301 commit 575a576
Showing 1 changed file with 111 additions and 1 deletion.
112 changes: 111 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@
e.preventDefault();
e.stopPropagation();
menu.togglePinEntry(this.entry.id);
this.$pinLink.textContent = menu._pinnedIds[this.entry.id] ? 'Unpin' : 'Pin';
});
this.$refsLink = document.createElement('a');
Expand All @@ -922,6 +923,7 @@
sdoBox.deactivate();
this.active = true;
this.entry = entry;
this.$pinLink.textContent = menu._pinnedIds[entry.id] ? 'Unpin' : 'Pin';
this.$outer.classList.add('active');
this.top = el.offsetTop - this.$outer.offsetHeight;
this.left = el.offsetLeft - 10;
Expand Down Expand Up @@ -1117,6 +1119,114 @@
referencePane.init();
});
// preserve state during navigation
function getTocPath(li) {
let path = [];
let pointer = li;
while (true) {
let parent = pointer.parentElement;
if (parent == null) {
return null;
}
let index = [].indexOf.call(parent.children, pointer);
if (index == -1) {
return null;
}
path.unshift(index);
pointer = parent.parentElement;
if (pointer == null) {
return null;
}
if (pointer.id === 'menu-toc') {
break;
}
if (pointer.tagName !== 'LI') {
return null;
}
}
return path;
}
function activateTocPath(path) {
try {
let pointer = document.getElementById('menu-toc');
for (let index of path) {
pointer = pointer.querySelector('ol').children[index];
}
pointer.classList.add('active');
} catch (e) {
// pass
}
}
function getActiveTocPaths() {
return [...menu.$menu.querySelectorAll('.active')].map(getTocPath).filter(p => p != null);
}
function loadStateFromSessionStorage() {
if (!window.sessionStorage || typeof menu === 'undefined' || window.navigating) {
return;
}
if (sessionStorage.referencePaneState != null) {
let state = JSON.parse(sessionStorage.referencePaneState);
if (state != null) {
if (state.type === 'ref') {
let entry = menu.search.biblio.byId[state.id];
if (entry != null) {
referencePane.showReferencesFor(entry);
}
} else if (state.type === 'sdo') {
let sdos = sdoMap[state.id];
if (sdos != null) {
referencePane.$headerText.innerHTML = state.html;
referencePane.showSDOsBody(sdos, state.id);
}
}
delete sessionStorage.referencePaneState;
}
}
if (sessionStorage.activeTocPaths != null) {
document
.getElementById('menu-toc')
.querySelectorAll('.active')
.forEach(e => {
e.classList.remove('active');
});
let active = JSON.parse(sessionStorage.activeTocPaths);
active.forEach(activateTocPath);
delete sessionStorage.activeTocPaths;
}
if (sessionStorage.searchValue != null) {
let value = JSON.parse(sessionStorage.searchValue);
menu.search.$searchBox.value = value;
menu.search.search(value);
delete sessionStorage.searchValue;
}
if (sessionStorage.tocScroll != null) {
let tocScroll = JSON.parse(sessionStorage.tocScroll);
menu.$toc.scrollTop = tocScroll;
delete sessionStorage.tocScroll;
}
}
document.addEventListener('DOMContentLoaded', loadStateFromSessionStorage);
window.addEventListener('pageshow', loadStateFromSessionStorage);
window.addEventListener('beforeunload', () => {
if (!window.sessionStorage || typeof menu === 'undefined') {
return;
}
sessionStorage.referencePaneState = JSON.stringify(referencePane.state || null);
sessionStorage.activeTocPaths = JSON.stringify(getActiveTocPaths());
sessionStorage.searchValue = JSON.stringify(menu.search.$searchBox.value);
sessionStorage.tocScroll = JSON.stringify(menu.$toc.scrollTop);
});
'use strict';
let decimalBullet = Array.from({ length: 100 }, (a, i) => '' + (i + 1));
let alphaBullet = Array.from({ length: 26 }, (a, i) => String.fromCharCode('a'.charCodeAt(0) + i));
Expand Down Expand Up @@ -2414,7 +2524,7 @@
</ul></div><div id="menu-toggle"><svg xmlns="http://www.w3.org/2000/svg" style="width:100%; height:100%; stroke:currentColor" viewBox="0 0 120 120">
<title>Menu</title>
<path stroke-width="10" stroke-linecap="round" d="M30,60 h60 M30,30 m0,5 h60 M30,90 m0,-5 h60"></path>
</svg></div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-demo-clause" title="This is an emu-clause"><span class="secnum">1</span> This is an emu-clause</a></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage -1 Draft / April 8, 2022</h1><h1 class="title">Proposal Title Goes Here</h1>
</svg></div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-demo-clause" title="This is an emu-clause"><span class="secnum">1</span> This is an emu-clause</a></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage -1 Draft / May 23, 2022</h1><h1 class="title">Proposal Title Goes Here</h1>

<emu-clause id="sec-demo-clause">
<h1><span class="secnum">1</span> This is an emu-clause</h1>
Expand Down

0 comments on commit 575a576

Please sign in to comment.