Initial commit: Klammertext source distribution
Curated source subset assembled by klammertext-dev's doc/make_dist.sh: the Klammermachine (mac), the Standard Klammer Set (sks), the commands (com), editor plugins and install guides (doc), a test subset (tst), and lib/bin placeholders. Builds with 'make -C com'. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
51
sks/document/js/level.js
Normal file
51
sks/document/js/level.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/* Open up the table of contents to a specified level in the hierarchy: */
|
||||
|
||||
/*
|
||||
function show_all() {
|
||||
let level_buttons = K.getv(".depthchoice");
|
||||
level_buttons[level_buttons.length-1].click();
|
||||
}
|
||||
|
||||
function show_highlighted(node) {
|
||||
//let carets = K.getv(".caret");
|
||||
let node_caret = node.parentNode.previousElementSibling;
|
||||
console.log(node_caret);
|
||||
}
|
||||
*/
|
||||
|
||||
window.addEventListener("load", function (event) {
|
||||
|
||||
K.map(".depthchoice", function (depthchoice) {
|
||||
depthchoice.addEventListener("click", function (event) {
|
||||
//save_position();
|
||||
let max_depth = K.text(event.srcElement);
|
||||
K.map(".caret", function (e) {
|
||||
let level = K.attr(e, "data-level");
|
||||
let open = K.has_class(e, "caret-down");
|
||||
if (level < max_depth) {
|
||||
if (!open) {
|
||||
e.click();
|
||||
}
|
||||
} else {
|
||||
if (open) {
|
||||
e.click();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
//restore_position();
|
||||
});
|
||||
});
|
||||
|
||||
K.get("html").addEventListener("keypress", function (event) {
|
||||
const max_depth = K.getv(".depthchoice").length;
|
||||
const zero = 48; // Hah!
|
||||
let depth = 1;
|
||||
for (depth = 1; depth <= max_depth; depth += 1) {
|
||||
if (event.which === zero + depth) {
|
||||
K.get('.depthchoice[data-depth="' + depth + '"]').click();
|
||||
}
|
||||
}
|
||||
});
|
||||
highlight_headers_in_toc();
|
||||
});
|
||||
Reference in New Issue
Block a user