Skip to content

Commit

Permalink
Deploying to gh-pages from @ f66abac 馃殌
Browse files Browse the repository at this point in the history
  • Loading branch information
justingrant committed Jun 21, 2023
1 parent cf5aa73 commit 17d0309
Showing 1 changed file with 106 additions and 38 deletions.
144 changes: 106 additions & 38 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -452,25 +452,68 @@
};
function findActiveClause(root, path) {
let clauses = getChildClauses(root);
path = path || [];
for (let $clause of clauses) {
let rect = $clause.getBoundingClientRect();
let visibleClauses = getVisibleClauses(root, path);
let midpoint = Math.floor(window.innerHeight / 2);
for (let [$clause, path] of visibleClauses) {
let { top: clauseTop, bottom: clauseBottom } = $clause.getBoundingClientRect();
let isFullyVisibleAboveTheFold =
clauseTop > 0 && clauseTop < midpoint && clauseBottom < window.innerHeight;
if (isFullyVisibleAboveTheFold) {
return path;
}
}
visibleClauses.sort(([, pathA], [, pathB]) => pathB.length - pathA.length);
for (let [$clause, path] of visibleClauses) {
let { top: clauseTop, bottom: clauseBottom } = $clause.getBoundingClientRect();
let $header = $clause.querySelector('h1');
let clauseStyles = getComputedStyle($clause);
let marginTop = Math.max(
parseInt(getComputedStyle($clause)['margin-top']),
0,
parseInt(clauseStyles['margin-top']),
parseInt(getComputedStyle($header)['margin-top'])
);
if (rect.top - marginTop <= 1 && rect.bottom > 0) {
return findActiveClause($clause, path.concat($clause)) || path;
let marginBottom = Math.max(0, parseInt(clauseStyles['margin-bottom']));
let crossesMidpoint =
clauseTop - marginTop <= midpoint && clauseBottom + marginBottom >= midpoint;
if (crossesMidpoint) {
return path;
}
}
return path;
}
function getVisibleClauses(root, path) {
let childClauses = getChildClauses(root);
path = path || [];
let result = [];
let seenVisibleClause = false;
for (let $clause of childClauses) {
let { top: clauseTop, bottom: clauseBottom } = $clause.getBoundingClientRect();
let isPartiallyVisible =
(clauseTop > 0 && clauseTop < window.innerHeight) ||
(clauseBottom > 0 && clauseBottom < window.innerHeight) ||
(clauseTop < 0 && clauseBottom > window.innerHeight);
if (isPartiallyVisible) {
seenVisibleClause = true;
let innerPath = path.concat($clause);
result.push([$clause, innerPath]);
result.push(...getVisibleClauses($clause, innerPath));
} else if (seenVisibleClause) {
break;
}
}
return result;
}
function* getChildClauses(root) {
for (let el of root.children) {
switch (el.nodeName) {
Expand Down Expand Up @@ -1162,12 +1205,40 @@
return [...menu.$menu.querySelectorAll('.active')].map(getTocPath).filter(p => p != null);
}
function loadStateFromSessionStorage() {
if (!window.sessionStorage || typeof menu === 'undefined' || window.navigating) {
function initTOCExpansion(visibleItemLimit) {
// Initialize to a reasonable amount of TOC expansion:
// * Expand any full-breadth nesting level up to visibleItemLimit.
// * Expand any *single-item* level while under visibleItemLimit (even if that pushes over it).
// Limit to initialization by bailing out if any parent item is already expanded.
const tocItems = Array.from(document.querySelectorAll('#menu-toc li'));
if (tocItems.some(li => li.classList.contains('active') && li.querySelector('li'))) {
return;
}
const selfAndSiblings = maybe => Array.from(maybe?.parentNode.children ?? []);
let currentLevelItems = selfAndSiblings(tocItems[0]);
let availableCount = visibleItemLimit - currentLevelItems.length;
while (availableCount > 0 && currentLevelItems.length) {
const nextLevelItems = currentLevelItems.flatMap(li => selfAndSiblings(li.querySelector('li')));
availableCount -= nextLevelItems.length;
if (availableCount > 0 || currentLevelItems.length === 1) {
// Expand parent items of the next level down (i.e., current-level items with children).
for (const ol of new Set(nextLevelItems.map(li => li.parentNode))) {
ol.closest('li').classList.add('active');
}
}
currentLevelItems = nextLevelItems;
}
}
function initState() {
if (typeof menu === 'undefined' || window.navigating) {
return;
}
if (sessionStorage.referencePaneState != null) {
let state = JSON.parse(sessionStorage.referencePaneState);
const storage = typeof sessionStorage !== 'undefined' ? sessionStorage : Object.create(null);
if (storage.referencePaneState != null) {
let state = JSON.parse(storage.referencePaneState);
if (state != null) {
if (state.type === 'ref') {
let entry = menu.search.biblio.byId[state.id];
Expand All @@ -1181,39 +1252,36 @@
referencePane.showSDOsBody(sdos, state.id);
}
}
delete sessionStorage.referencePaneState;
delete storage.referencePaneState;
}
}
if (sessionStorage.activeTocPaths != null) {
document
.getElementById('menu-toc')
.querySelectorAll('.active')
.forEach(e => {
e.classList.remove('active');
});
let active = JSON.parse(sessionStorage.activeTocPaths);
if (storage.activeTocPaths != null) {
document.querySelectorAll('#menu-toc li.active').forEach(li => li.classList.remove('active'));
let active = JSON.parse(storage.activeTocPaths);
active.forEach(activateTocPath);
delete sessionStorage.activeTocPaths;
delete storage.activeTocPaths;
} else {
initTOCExpansion(20);
}
if (sessionStorage.searchValue != null) {
let value = JSON.parse(sessionStorage.searchValue);
if (storage.searchValue != null) {
let value = JSON.parse(storage.searchValue);
menu.search.$searchBox.value = value;
menu.search.search(value);
delete sessionStorage.searchValue;
delete storage.searchValue;
}
if (sessionStorage.tocScroll != null) {
let tocScroll = JSON.parse(sessionStorage.tocScroll);
if (storage.tocScroll != null) {
let tocScroll = JSON.parse(storage.tocScroll);
menu.$toc.scrollTop = tocScroll;
delete sessionStorage.tocScroll;
delete storage.tocScroll;
}
}
document.addEventListener('DOMContentLoaded', loadStateFromSessionStorage);
document.addEventListener('DOMContentLoaded', initState);
window.addEventListener('pageshow', loadStateFromSessionStorage);
window.addEventListener('pageshow', initState);
window.addEventListener('beforeunload', () => {
if (!window.sessionStorage || typeof menu === 'undefined') {
Expand Down Expand Up @@ -2633,8 +2701,8 @@
<h1>Time Zone Canonicalization proposal</h1>
<p>This proposal aims to:</p>
<ul>
<li>Improve consistency across ECMAScript engines with regard to time zone identifiers, so that programs will behave more similarly across engines</li>
<li>Make ECMAScript programs more resilient to changes in time zone identifiers, like 2022's change of <code>Europe/Kiev</code> to <code>Europe/Kyiv</code></li>
<li>Improve consistency across ECMAScript engines with regard to <emu-xref href="#sec-time-zone-identifiers"><a href="https://tc39.es/ecma262/#sec-time-zone-identifiers">time zone identifiers</a></emu-xref>, so that programs will behave more similarly across engines</li>
<li>Make ECMAScript programs more resilient to changes in <emu-xref href="#sec-time-zone-identifiers"><a href="https://tc39.es/ecma262/#sec-time-zone-identifiers">time zone identifiers</a></emu-xref>, like 2022's change of <code>Europe/Kiev</code> to <code>Europe/Kyiv</code></li>
</ul>
<p>This specification consists of two parts:</p>
Expand Down Expand Up @@ -2665,10 +2733,10 @@ <h1><span class="secnum">1</span> Amendments to the ECMAScript庐 2024 Language S
<emu-clause id="sec-systemtimezoneidentifier" oldids="sec-defaulttimezone" type="implementation-defined abstract operation" aoid="SystemTimeZoneIdentifier"><span id="sec-defaulttimezone"></span>
<h1><span class="secnum">1.1</span> SystemTimeZoneIdentifier ( )</h1>
<p>The <emu-xref href="#implementation-defined"><a href="https://tc39.es/ecma262/#implementation-defined">implementation-defined</a></emu-xref> abstract operation SystemTimeZoneIdentifier takes no arguments and returns a String.
It returns a String representing the <emu-xref href="#host-environment"><a href="https://tc39.es/ecma262/#host-environment">host environment</a></emu-xref>'s current time zone, which is either a String representing a UTC offset for which <emu-xref aoid="IsTimeZoneOffsetString"><a href="https://tc39.es/ecma262/#sec-istimezoneoffsetstring">IsTimeZoneOffsetString</a></emu-xref> returns <emu-val>true</emu-val>, or a primary time zone identifier.
It returns a String representing the <emu-xref href="#host-environment"><a href="https://tc39.es/ecma262/#host-environment">host environment</a></emu-xref>'s current time zone, which is either a String representing a UTC offset for which <emu-xref aoid="IsTimeZoneOffsetString"><a href="https://tc39.es/ecma262/#sec-istimezoneoffsetstring">IsTimeZoneOffsetString</a></emu-xref> returns <emu-val>true</emu-val>, or a <emu-xref href="#sec-time-zone-identifiers"><a href="https://tc39.es/ecma262/#sec-time-zone-identifiers">primary time zone identifier</a></emu-xref>.
It performs the following steps when called:</p>
<emu-alg><ol><li>If the implementation only supports the UTC time zone, return <emu-val>"UTC"</emu-val>.</li><li>Let <var>systemTimeZoneString</var> be the String representing the <emu-xref href="#host-environment"><a href="https://tc39.es/ecma262/#host-environment">host environment</a></emu-xref>'s current time zone, either a primary time zone identifier or an offset time zone identifier.</li><li><ins>If <emu-xref aoid="IsTimeZoneOffsetString"><a href="https://tc39.es/ecma262/#sec-istimezoneoffsetstring">IsTimeZoneOffsetString</a></emu-xref>(<var>systemTimeZoneString</var>) is <emu-val>true</emu-val>, return <emu-xref aoid="CanonicalizeTimeZoneOffsetString"><a href="https://tc39.es/proposal-temporal/#sec-temporal-canonicalizetimezoneoffsetstring">CanonicalizeTimeZoneOffsetString</a></emu-xref>(<var>systemTimeZoneString</var>)</ins>.</li><li>Return <var>systemTimeZoneString</var>.</li></ol></emu-alg>
<emu-alg><ol><li>If the implementation only supports the UTC time zone, return <emu-val>"UTC"</emu-val>.</li><li>Let <var>systemTimeZoneString</var> be the String representing the <emu-xref href="#host-environment"><a href="https://tc39.es/ecma262/#host-environment">host environment</a></emu-xref>'s current time zone, either a <emu-xref href="#sec-time-zone-identifiers"><a href="https://tc39.es/ecma262/#sec-time-zone-identifiers">primary time zone identifier</a></emu-xref> or an <emu-xref href="#sec-time-zone-identifiers"><a href="https://tc39.es/ecma262/#sec-time-zone-identifiers">offset time zone</a></emu-xref> identifier.</li><li><ins>If <emu-xref aoid="IsTimeZoneOffsetString"><a href="https://tc39.es/ecma262/#sec-istimezoneoffsetstring">IsTimeZoneOffsetString</a></emu-xref>(<var>systemTimeZoneString</var>) is <emu-val>true</emu-val>, return <emu-xref aoid="CanonicalizeTimeZoneOffsetString"><a href="https://tc39.es/proposal-temporal/#sec-temporal-canonicalizetimezoneoffsetstring">CanonicalizeTimeZoneOffsetString</a></emu-xref>(<var>systemTimeZoneString</var>)</ins>.</li><li>Return <var>systemTimeZoneString</var>.</li></ol></emu-alg>
<p>[...]</p>
</emu-clause>
Expand Down Expand Up @@ -2745,15 +2813,15 @@ <h1><span class="secnum">2.1</span> Time Zone Identifiers</h1>
The IANA Time Zone Database is typically updated between five and ten times per year.
These updates may add new Zone or Link names, may change Zones to Links, and may change the UTC offsets and transitions associated with any Zone.
ECMAScript implementations are recommended to include updates to the IANA Time Zone Database as soon as possible.
Such prompt action ensures that ECMAScript programs can accurately perform time-zone-sensitive calculations and can use newly-added available named time zone identifiers supplied by external input or the <emu-xref href="#host-environment"><a href="https://tc39.es/ecma262/#host-environment">host environment</a></emu-xref>.
Such prompt action ensures that ECMAScript programs can accurately perform time-zone-sensitive calculations and can use newly-added <emu-xref href="#sec-time-zone-identifiers"><a href="https://tc39.es/ecma262/#sec-time-zone-identifiers">available named time zone identifiers</a></emu-xref> supplied by external input or the <emu-xref href="#host-environment"><a href="https://tc39.es/ecma262/#host-environment">host environment</a></emu-xref>.
</p>
<ins class="block">
<p>
Although the IANA Time Zone Database maintainers strive for stability, in rare cases identifiers will be renamed.
For example, the IANA Time Zone Database's 2022b release added "<emu-val>Europe/Kyiv</emu-val>" as a new Zone and demoted "<emu-val>Europe/Kiev</emu-val>" to be a Link to the new Zone.
To reduce disruption from these renaming changes, ECMAScript implementations are encouraged to initially add the new name as a non-primary time zone identifier that resolves to the old primary identifier.
Then, after a waiting period, implementations are recommended to promote the new Zone to a primary time zone identifier while simultaneously demoting the deprecated name to non-primary.
To reduce disruption from these renaming changes, ECMAScript implementations are encouraged to initially add the new name as a <emu-xref href="#sec-time-zone-identifiers"><a href="https://tc39.es/ecma262/#sec-time-zone-identifiers">non-primary time zone identifier</a></emu-xref> that resolves to the old primary identifier.
Then, after a waiting period, implementations are recommended to promote the new Zone to a <emu-xref href="#sec-time-zone-identifiers"><a href="https://tc39.es/ecma262/#sec-time-zone-identifiers">primary time zone identifier</a></emu-xref> while simultaneously demoting the deprecated name to non-primary.
The recommended waiting period is two years after the IANA Time Zone Database release containing the changes.
This is long enough to allow most other systems that ECMAScript programs may interact with to "catch up" with the change so that the new zone is recognized.
Note that this waiting period should only apply to cases where an existing Zone is replaced by a new Zone name.
Expand All @@ -2762,7 +2830,7 @@ <h1><span class="secnum">2.1</span> Time Zone Identifiers</h1>
</ins>
<p>
If implementations revise time zone information during the lifetime of an <emu-xref href="#agent"><a href="https://tc39.es/ecma262/#agent">agent</a></emu-xref>, then which identifiers are supported, the primary time zone identifier associated with any identifier, and the UTC offsets and transitions associated with any Zone, must be consistent with results previously observed by that <emu-xref href="#agent"><a href="https://tc39.es/ecma262/#agent">agent</a></emu-xref>.
If implementations revise time zone information during the lifetime of an <emu-xref href="#agent"><a href="https://tc39.es/ecma262/#agent">agent</a></emu-xref>, then which identifiers are supported, the <emu-xref href="#sec-time-zone-identifiers"><a href="https://tc39.es/ecma262/#sec-time-zone-identifiers">primary time zone identifier</a></emu-xref> associated with any identifier, and the UTC offsets and transitions associated with any Zone, must be consistent with results previously observed by that <emu-xref href="#agent"><a href="https://tc39.es/ecma262/#agent">agent</a></emu-xref>.
Due to the complexity of supporting this requirement, it is recommended that implementations maintain a fully consistent copy of the IANA Time Zone Database for the lifetime of each <emu-xref href="#agent"><a href="https://tc39.es/ecma262/#agent">agent</a></emu-xref>.
</p>
</emu-clause>
Expand Down Expand Up @@ -2799,7 +2867,7 @@ <h2>Copyright Notice</h2>
<p>漏 2023 Justin Grant, Richard Gibson</p>
<h2>Software License</h2>
<p>All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.</p>
<p>All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT <a href="https://ecma-international.org/memento/codeofconduct.htm">https://ecma-international.org/memento/codeofconduct.htm</a> FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.</p>
<p>Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:</p>
Expand Down

0 comments on commit 17d0309

Please sign in to comment.