Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pin the biblio #33

Merged
merged 1 commit into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,25 @@ Please ensure the following:
## Create your proposal repo

Follow these steps:
1. Click the green ["use this template"](https://github.com/tc39/template-for-proposals/generate) button in the repo header. (Note: Do not fork this repo in GitHub's web interface, as that will later prevent transfer into the TC39 organization)
1. Go to your repo settings “Options” page, under “GitHub Pages”, and set the source to the **main branch** under the root (and click Save, if it does not autosave this setting)
1. Click the green ["use this template"](https://github.com/tc39/template-for-proposals/generate) button in the repo header. (Note: Do not fork this repo in GitHub's web interface, as that will later prevent transfer into the TC39 organization)
1. Update the biblio to the latest version: `npm install --save-dev --save-exact @tc39/ecma262-biblio@latest`.
1. Go to your repo settings “Options” page, under “GitHub Pages”, and set the source to the **main branch** under the root (and click Save, if it does not autosave this setting)
1. check "Enforce HTTPS"
1. On "Options", under "Features", Ensure "Issues" is checked, and disable "Wiki", and "Projects" (unless you intend to use Projects)
1. Under "Merge button", check "automatically delete head branches"
<!--
1. Avoid merge conflicts with build process output files by running:
1. Avoid merge conflicts with build process output files by running:
```sh
git config --local --add merge.output.driver true
git config --local --add merge.output.driver true
```
1. Add a post-rewrite git hook to auto-rebuild the output on every commit:
1. Add a post-rewrite git hook to auto-rebuild the output on every commit:
```sh
cp hooks/post-rewrite .git/hooks/post-rewrite
chmod +x .git/hooks/post-rewrite
```
-->
3. ["How to write a good explainer"][explainer] explains how to make a good first impression.
3. ["How to write a good explainer"][explainer] explains how to make a good first impression.

> Each TC39 proposal should have a `README.md` file which explains the purpose
> of the proposal and its shape at a high level.
Expand Down
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"license": "MIT",
"devDependencies": {
"@tc39/ecma262-biblio": "^2.0.2288",
"@tc39/ecma262-biblio": "2.0.2322",
"ecmarkup": "^12.0.2"
}
}