Skip to content

Commit b34026a

Browse files
committed
npm run build
1 parent 97f33cf commit b34026a

File tree

1 file changed

+143
-19
lines changed

1 file changed

+143
-19
lines changed

index.html

+143-19
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
};
136136
137137
Search.prototype.documentKeydown = function (e) {
138-
if (e.keyCode === 191) {
138+
if (e.key === '/') {
139139
e.preventDefault();
140140
e.stopPropagation();
141141
this.triggerSearch();
@@ -190,7 +190,7 @@
190190
relevance += 2048;
191191
}
192192
193-
relevance += Math.max(0, 255 - result.entry.key.length);
193+
relevance += Math.max(0, 255 - result.key.length);
194194
195195
return relevance;
196196
}
@@ -214,20 +214,21 @@
214214
if (/^[\d.]*$/.test(searchString)) {
215215
results = this.biblio.clauses
216216
.filter(clause => clause.number.substring(0, searchString.length) === searchString)
217-
.map(clause => ({ entry: clause }));
217+
.map(clause => ({ key: getKey(clause), entry: clause }));
218218
} else {
219219
results = [];
220220
221221
for (let i = 0; i < this.biblio.entries.length; i++) {
222222
let entry = this.biblio.entries[i];
223-
if (!entry.key) {
223+
let key = getKey(entry);
224+
if (!key) {
224225
// biblio entries without a key aren't searchable
225226
continue;
226227
}
227228
228-
let match = fuzzysearch(searchString, entry.key);
229+
let match = fuzzysearch(searchString, key);
229230
if (match) {
230-
results.push({ entry, match });
231+
results.push({ key, entry, match });
231232
}
232233
}
233234
@@ -276,26 +277,27 @@
276277
let html = '<ul>';
277278
278279
results.forEach(result => {
280+
let key = result.key;
279281
let entry = result.entry;
280282
let id = entry.id;
281283
let cssClass = '';
282284
let text = '';
283285
284286
if (entry.type === 'clause') {
285287
let number = entry.number ? entry.number + ' ' : '';
286-
text = number + entry.key;
288+
text = number + key;
287289
cssClass = 'clause';
288290
id = entry.id;
289291
} else if (entry.type === 'production') {
290-
text = entry.key;
292+
text = key;
291293
cssClass = 'prod';
292294
id = entry.id;
293295
} else if (entry.type === 'op') {
294-
text = entry.key;
296+
text = key;
295297
cssClass = 'op';
296298
id = entry.id || entry.refId;
297299
} else if (entry.type === 'term') {
298-
text = entry.key;
300+
text = key;
299301
cssClass = 'term';
300302
id = entry.id || entry.refId;
301303
}
@@ -315,6 +317,31 @@
315317
}
316318
};
317319
320+
function getKey(item) {
321+
if (item.key) {
322+
return item.key;
323+
}
324+
switch (item.type) {
325+
case 'clause':
326+
return item.title || item.titleHTML;
327+
case 'production':
328+
return item.name;
329+
case 'op':
330+
return item.aoid;
331+
case 'term':
332+
return item.term;
333+
case 'table':
334+
case 'figure':
335+
case 'example':
336+
case 'note':
337+
return item.caption;
338+
case 'step':
339+
return item.id;
340+
default:
341+
throw new Error("Can't get key for " + item.type);
342+
}
343+
}
344+
318345
function Menu() {
319346
this.$toggle = document.getElementById('menu-toggle');
320347
this.$menu = document.getElementById('menu');
@@ -507,7 +534,7 @@
507534
// prettier-ignore
508535
this.$pinList.innerHTML += `<li><a href="${makeLinkToId(entry.id)}">${prefix}${entry.titleHTML}</a></li>`;
509536
} else {
510-
this.$pinList.innerHTML += `<li><a href="${makeLinkToId(entry.id)}">${entry.key}</a></li>`;
537+
this.$pinList.innerHTML += `<li><a href="${makeLinkToId(entry.id)}">${getKey(entry)}</a></li>`;
511538
}
512539
513540
if (Object.keys(this._pinnedIds).length === 0) {
@@ -782,7 +809,7 @@
782809
this.$headerRefId.textContent = '#' + entry.id;
783810
this.$headerRefId.setAttribute('href', makeLinkToId(entry.id));
784811
this.$headerRefId.style.display = 'inline';
785-
entry.referencingIds
812+
(entry.referencingIds || [])
786813
.map(id => {
787814
let cid = menu.search.biblio.refParentClause[id];
788815
let clause = menu.search.biblio.byId[cid];
@@ -913,7 +940,7 @@
913940
},
914941
915942
updateReferences() {
916-
this.$refsLink.textContent = `References (${this.entry.referencingIds.length})`;
943+
this.$refsLink.textContent = `References (${(this.entry.referencingIds || []).length})`;
917944
},
918945
919946
activateIfMouseOver(e) {
@@ -1034,7 +1061,10 @@
10341061
if (name === 'textarea' || name === 'input' || name === 'select' || target.isContentEditable) {
10351062
return;
10361063
}
1037-
if (e.key === 'm' && !e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey && usesMultipage) {
1064+
if (e.altKey || e.ctrlKey || e.metaKey) {
1065+
return;
1066+
}
1067+
if (e.key === 'm' && usesMultipage) {
10381068
let pathParts = location.pathname.split('/');
10391069
let hash = location.hash;
10401070
if (pathParts[pathParts.length - 2] === 'multipage') {
@@ -1051,6 +1081,10 @@
10511081
} else {
10521082
location = 'multipage/' + hash;
10531083
}
1084+
} else if (e.key === 'u') {
1085+
document.documentElement.classList.toggle('show-ao-annotations');
1086+
} else if (e.key === '?') {
1087+
document.getElementById('shortcuts-help').classList.toggle('active');
10541088
}
10551089
}
10561090
@@ -1066,8 +1100,11 @@
10661100
document.addEventListener(
10671101
'keydown',
10681102
debounce(e => {
1069-
if (e.code === 'Escape' && Toolbox.active) {
1070-
Toolbox.deactivate();
1103+
if (e.code === 'Escape') {
1104+
if (Toolbox.active) {
1105+
Toolbox.deactivate();
1106+
}
1107+
document.getElementById('shortcuts-help').classList.remove('active');
10711108
}
10721109
})
10731110
);
@@ -1112,7 +1149,7 @@
11121149
});
11131150
11141151
let sdoMap = JSON.parse(`{}`);
1115-
let biblio = JSON.parse(`{"refsByClause":{"sec-demo-clause":["_ref_0"]},"entries":[{"type":"clause","id":"sec-demo-clause","aoid":null,"titleHTML":"This is an emu-clause","number":"1","referencingIds":[],"key":"This is an emu-clause"},{"type":"clause","id":"sec-copyright-and-software-license","aoid":null,"titleHTML":"Copyright &amp; Software License","number":"A","referencingIds":[],"key":"Copyright & Software License"}]}`);
1152+
let biblio = JSON.parse(`{"refsByClause":{},"entries":[{"type":"clause","id":"sec-demo-clause","titleHTML":"This is an emu-clause","number":"1"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright &amp; Software License","number":"A"}]}`);
11161153
;let usesMultipage = false</script><style>body {
11171154
display: flex;
11181155
font-size: 18px;
@@ -1150,6 +1187,43 @@
11501187
color: #239dee;
11511188
}
11521189
1190+
a.e-user-code,
1191+
span.e-user-code {
1192+
white-space: nowrap;
1193+
}
1194+
1195+
a.e-user-code::before,
1196+
span.e-user-code::before {
1197+
display: none;
1198+
color: brown;
1199+
background-color: white;
1200+
border: 2pt solid brown;
1201+
padding: 0.3ex;
1202+
margin: 0 0.25em 0 0;
1203+
line-height: 1;
1204+
vertical-align: text-top;
1205+
text-transform: uppercase;
1206+
font-family: 'Comic Code', sans-serif;
1207+
font-weight: 900;
1208+
font-size: x-small;
1209+
}
1210+
1211+
a.e-user-code:hover::before,
1212+
span.e-user-code:hover::before {
1213+
background-color: brown;
1214+
color: white;
1215+
}
1216+
1217+
html.show-ao-annotations a.e-user-code::before,
1218+
html.show-ao-annotations span.e-user-code::before {
1219+
display: inline-block;
1220+
}
1221+
1222+
a.e-user-code::before,
1223+
span.e-user-code::before {
1224+
content: 'UC';
1225+
}
1226+
11531227
code {
11541228
font-weight: bold;
11551229
font-family: Consolas, Monaco, monospace;
@@ -2290,12 +2364,62 @@
22902364
.clause-attributes-tag a {
22912365
color: #884400;
22922366
}
2293-
</style></head><body><div id="menu-toggle">☰</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>
2367+
2368+
/* Shortcuts help dialog */
2369+
2370+
#shortcuts-help {
2371+
position: fixed;
2372+
left: 5%;
2373+
margin: 0 auto;
2374+
right: 5%;
2375+
z-index: 10;
2376+
top: 10%;
2377+
top: calc(5vw + 5vh);
2378+
padding: 30px 90px;
2379+
max-width: 500px;
2380+
outline: solid 10000px rgba(255, 255, 255, 0.6);
2381+
border-radius: 5px;
2382+
border-width: 1px 1px 0 1px;
2383+
background-color: #ddd;
2384+
display: none;
2385+
}
2386+
2387+
#shortcuts-help.active {
2388+
display: block;
2389+
}
2390+
2391+
#shortcuts-help ul {
2392+
padding: 0;
2393+
}
2394+
2395+
#shortcuts-help li {
2396+
display: flex;
2397+
justify-content: space-between;
2398+
}
2399+
2400+
#shortcuts-help code {
2401+
padding: 3px 10px;
2402+
border-radius: 3px;
2403+
border-width: 1px 1px 0 1px;
2404+
border-color: #bbb;
2405+
background-color: #eee;
2406+
box-shadow: inset 0 -1px 0 #ccc;
2407+
}
2408+
</style></head><body><div id="shortcuts-help">
2409+
<ul>
2410+
<li><span>Toggle shortcuts help</span><code>?</code></li>
2411+
<li><span>Toggle "can call user code" annotations</span><code>u</code></li>
2412+
2413+
<li><span>Jump to search box</span><code>/</code></li>
2414+
</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">
2415+
<title>Menu</title>
2416+
<path stroke-width="10" stroke-linecap="round" d="M30,60 h60 M30,30 m0,5 h60 M30,90 m0,-5 h60"></path>
2417+
</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>
22942418

22952419
<emu-clause id="sec-demo-clause">
22962420
<h1><span class="secnum">1</span> This is an emu-clause</h1>
22972421
<p>This is an algorithm:</p>
2298-
<emu-alg><ol><li>Let <var>proposal</var> be <emu-val>undefined</emu-val>.</li><li>If IsAccepted(<var>proposal</var>), then<ol><li>Let <var>stage</var> be <emu-val>0</emu-val><sub>ℤ</sub>.</li></ol></li><li>Else,<ol><li>Let <var>stage</var> be <emu-val>-1</emu-val><sub>ℤ</sub>.</li></ol></li><li>Return ?&nbsp;<emu-xref aoid="ToString" id="_ref_0"><a href="https://tc39.es/ecma262/#sec-tostring">ToString</a></emu-xref>(<var>proposal</var>).</li></ol></emu-alg>
2422+
<emu-alg><ol><li>Let <var>proposal</var> be <emu-val>undefined</emu-val>.</li><li>If IsAccepted(<var>proposal</var>), then<ol><li>Let <var>stage</var> be <emu-val>0</emu-val><sub>ℤ</sub>.</li></ol></li><li>Else,<ol><li>Let <var>stage</var> be <emu-val>-1</emu-val><sub>ℤ</sub>.</li></ol></li><li>Return ?&nbsp;<emu-xref aoid="ToString"><a href="https://tc39.es/ecma262/#sec-tostring">ToString</a></emu-xref>(<var>proposal</var>).</li></ol></emu-alg>
22992423
</emu-clause><emu-annex id="sec-copyright-and-software-license">
23002424
<h1><span class="secnum">A</span> Copyright &amp; Software License</h1>
23012425

0 commit comments

Comments
 (0)