/******************************************************************************
* JS Extension for the W3C Spec Style Sheet *
* *
* This code handles: *
* - some fixup to improve the table of contents *
* - the obsolete warning on outdated specs *
******************************************************************************/
(function() {
"use strict";
try {
var details = document.querySelector("div.head details");
details.addEventListener("toggle", function toggle() {
window.localStorage.setItem("tr-metadata", details.open);
}, false);
details.open = !localStorage.getItem("tr-metadata") || localStorage.getItem("tr-metadata") === 'true';
} catch (e) {}; // ignore errors for this interaction
const tocToggleId = 'toc-toggle';
const tocJumpId = 'toc-jump';
const tocCollapseId = 'toc-collapse';
const tocExpandId = 'toc-expand';
const tocThemeToggle = 'toc-theme-toggle';
var ESCAPEKEY = 27;
// Internationalization support for sidebar/jump text
var lang = document.documentElement.lang || 'en';
var i18n = {
en: {
collapseSidebar: 'Collapse Sidebar',
expandSidebar: 'Pop Out Sidebar',
jumpToToc: 'Jump to Table of Contents',
},
cs: {
collapseSidebar: 'Skrýt postranní panel',
expandSidebar: 'Zobrazit postranní panel',
jumpToToc: 'Přejít na obsah',
},
de: {
collapseSidebar: 'Seitenleiste einklappen',
expandSidebar: 'Seitenleiste ausklappen',
jumpToToc: 'Zum Inhaltsverzeichnis springen',
},
es: {
collapseSidebar: 'Colapsar barra lateral',
expandSidebar: 'Mostrar barra lateral',
jumpToToc: 'Ir al índice',
},
ja: {
collapseSidebar: 'サイドバーを折りたたむ',
expandSidebar: 'サイドバーを表示',
jumpToToc: '目次へジャンプ',
},
ko: {
collapseSidebar: '사이드바 접기',
expandSidebar: '사이드바 펼치기',
jumpToToc: '목차로 이동',
},
nl: {
collapseSidebar: 'Zijbalk samenvouwen',
expandSidebar: 'Zijbalk uitklappen',
jumpToToc: 'Naar inhoudsopgave',
},
zh: {
collapseSidebar: '收起侧边栏',
expandSidebar: '展开侧边栏',
jumpToToc: '跳转到目录',
}
};
var t = i18n[lang] || i18n['en'];
var collapseSidebarText = '← '
+ `${t.collapseSidebar}`;
var expandSidebarText = '→ '
+ `${t.expandSidebar}`;
var tocJumpText = '↑ '
+ `${t.jumpToToc}`;
var sidebarMedia = window.matchMedia('screen and (min-width: 78em)');
var autoToggle = function(e){ toggleSidebar(e.matches) };
if(sidebarMedia.addListener) {
sidebarMedia.addListener(autoToggle);
}
function toggleSidebar(on, skipScroll) {
if (on == undefined) {
on = !document.body.classList.contains('toc-sidebar');
}
if (!skipScroll) {
/* Don't scroll to compensate for the ToC if we're above it already. */
var headY = 0;
var head = document.querySelector('.head');
if (head) {
// terrible approx of "top of ToC"
headY += head.offsetTop + head.offsetHeight;
}
skipScroll = window.scrollY < headY;
}
var toggle = document.getElementById(tocToggleId);
var tocNav = document.getElementById('toc');
if (on) {
var tocHeight = tocNav.offsetHeight;
document.body.classList.add('toc-sidebar');
document.body.classList.remove('toc-inline');
toggle.innerHTML = collapseSidebarText;
toggle.setAttribute('aria-labelledby', `${tocCollapseId}-text`);
if (!skipScroll) {
window.scrollBy(0, 0 - tocHeight);
}
tocNav.focus();
sidebarMedia.addListener(autoToggle); // auto-collapse when out of room
}
else {
document.body.classList.add('toc-inline');
document.body.classList.remove('toc-sidebar');
toggle.innerHTML = expandSidebarText;
toggle.setAttribute('aria-labelledby', `${tocExpandId}-text`);
if (!skipScroll) {
window.scrollBy(0, tocNav.offsetHeight);
}
if (toggle.matches(':hover')) {
/* Unfocus button when not using keyboard navigation,
because I don't know where else to send the focus. */
toggle.blur();
}
}
}
function createSidebarToggle() {
/* Create the sidebar toggle in JS; it shouldn't exist when JS is off. */
var toggle = document.createElement('a');
/* This should probably be a button, but appearance isn't standards-track.*/
toggle.id = tocToggleId;
toggle.class = 'toc-toggle';
toggle.href = '#toc';
toggle.innerHTML = collapseSidebarText;
toggle.setAttribute('aria-labelledby', `${tocCollapseId}-text`);
sidebarMedia.addListener(autoToggle);
var toggler = function(e) {
e.preventDefault();
sidebarMedia.removeListener(autoToggle); // persist explicit off states
toggleSidebar();
return false;
}
toggle.addEventListener('click', toggler, false);
/* Get