|
@@ -54,22 +54,35 @@ depth_first_walk (node, func, node_type)
|
|
|
depth_first_walk (child, func, node_type);
|
|
|
}
|
|
|
|
|
|
+/** Return the hash part of HREF without the '#' prefix. HREF must be
|
|
|
+ a string. If there is no hash part in HREF then return the empty
|
|
|
+ string. */
|
|
|
+export function
|
|
|
+href_hash (href)
|
|
|
+{
|
|
|
+ if (typeof href !== "string")
|
|
|
+ throw new TypeError (href + " is not a string");
|
|
|
+
|
|
|
+ return href.replace (/.*#/, "");
|
|
|
+}
|
|
|
+
|
|
|
/** Retrieve PREV, NEXT, and UP links and Return a object containing
|
|
|
references to those links. */
|
|
|
-export var navigation_links = (function () {
|
|
|
- /* Dictionary associating an 'accesskey' property to its navigation id. */
|
|
|
- let dict = { n: "next", p: "prev", u: "up" };
|
|
|
+export function
|
|
|
+navigation_links (content)
|
|
|
+{
|
|
|
+ let links = Array.from (content.querySelectorAll ("footer a"));
|
|
|
+
|
|
|
+ /* links have the form MAIN_FILE.html#FRAME-ID. For convenience
|
|
|
+ we only store FRAME-ID. */
|
|
|
+ return links.reduce ((acc, link) => {
|
|
|
+ let nav_id = navigation_links.dict[link.getAttribute ("accesskey")];
|
|
|
+ if (nav_id)
|
|
|
+ acc[nav_id] = href_hash (link.getAttribute ("href"));
|
|
|
+ return acc;
|
|
|
+ }, {});
|
|
|
+}
|
|
|
|
|
|
- return function (content) {
|
|
|
- let links = Array.from (content.querySelectorAll ("footer a"));
|
|
|
+/* Dictionary associating an 'accesskey' property to its navigation id. */
|
|
|
+navigation_links.dict = { n: "next", p: "prev", u: "up" };
|
|
|
|
|
|
- /* links have the form MAIN_FILE.html#FRAME-ID. For convenience
|
|
|
- we only store FRAME-ID. */
|
|
|
- return links.reduce ((acc, link) => {
|
|
|
- let nav_id = dict[link.getAttribute ("accesskey")];
|
|
|
- if (nav_id)
|
|
|
- acc[nav_id] = link.getAttribute ("href").replace (/.*#/, "");
|
|
|
- return acc;
|
|
|
- }, {});
|
|
|
- };
|
|
|
-} ());
|