| author | paulson <lp15@cam.ac.uk> |
| Thu, 06 Nov 2025 10:55:39 +0000 | |
| changeset 83520 | 6f656fc94319 |
| parent 83390 | 05abe5a82410 |
| permissions | -rw-r--r-- |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
1 |
(function () {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
2 |
const vscode = acquireVsCodeApi(); |
| 83386 | 3 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
4 |
window.addEventListener("message", event => {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
5 |
const message = event.data; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
6 |
if (message.command === "update" && Array.isArray(message.sections)) {
|
| 83389 | 7 |
update(message.sections); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
8 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
9 |
}); |
| 83386 | 10 |
|
| 83389 | 11 |
function update(sections) {
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
12 |
const container = document.getElementById("documentation-container");
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
13 |
if (!container) return; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
14 |
container.innerHTML = ""; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
15 |
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
16 |
vscode.setState({ sections: sections });
|
| 83386 | 17 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
18 |
const list = document.createElement("ul");
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
19 |
list.classList.add("doc-list");
|
| 83386 | 20 |
|
| 83389 | 21 |
let selected_entry = null; |
| 83386 | 22 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
23 |
sections.forEach(section => {
|
| 83389 | 24 |
const section_item = document.createElement("li");
|
25 |
section_item.classList.add("doc-section");
|
|
| 83386 | 26 |
|
| 83389 | 27 |
const title_element = document.createElement("span");
|
28 |
title_element.textContent = section.title; |
|
29 |
title_element.classList.add("section-title");
|
|
| 83386 | 30 |
|
| 83389 | 31 |
const sub_list = document.createElement("ul");
|
32 |
sub_list.classList.add("doc-sublist");
|
|
33 |
sub_list.style.display = section.important ? "block" : "none"; |
|
| 83386 | 34 |
|
| 83389 | 35 |
title_element.addEventListener("click", () => {
|
36 |
sub_list.style.display = sub_list.style.display === "none" ? "block" : "none"; |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
37 |
}); |
| 83386 | 38 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
39 |
section.entries.forEach(entry => {
|
| 83389 | 40 |
const entry_item = document.createElement("li");
|
41 |
entry_item.classList.add("doc-entry");
|
|
| 83386 | 42 |
|
| 83389 | 43 |
const entry_link = document.createElement("a");
|
44 |
entry_link.innerHTML = entry.print_html; |
|
45 |
entry_link.href = "#"; |
|
46 |
entry_link.classList.add("doc-link");
|
|
| 83386 | 47 |
|
| 83389 | 48 |
entry_link.addEventListener("click", event => {
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
49 |
event.preventDefault(); |
| 83386 | 50 |
|
| 83389 | 51 |
if (selected_entry && selected_entry !== entry_item) {
|
52 |
selected_entry.classList.remove("selected");
|
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
53 |
} |
| 83386 | 54 |
|
| 83389 | 55 |
if (selected_entry === entry_item) {
|
56 |
selected_entry.classList.remove("selected");
|
|
57 |
selected_entry = null; |
|
58 |
} |
|
59 |
else {
|
|
60 |
selected_entry = entry_item; |
|
61 |
entry_item.classList.add("selected");
|
|
|
83388
8d90bd0e4f39
more accurate Doc_Entry: print_html like Isabelle/jEdit, proper platform_path;
wenzelm
parents:
83386
diff
changeset
|
62 |
open_document(entry.platform_path); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
63 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
64 |
}); |
| 83386 | 65 |
|
| 83389 | 66 |
entry_item.appendChild(entry_link); |
67 |
sub_list.appendChild(entry_item); |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
68 |
}); |
| 83386 | 69 |
|
| 83389 | 70 |
section_item.appendChild(title_element); |
71 |
section_item.appendChild(sub_list); |
|
72 |
list.appendChild(section_item); |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
73 |
}); |
| 83386 | 74 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
75 |
container.appendChild(list); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
76 |
} |
| 83386 | 77 |
|
|
83388
8d90bd0e4f39
more accurate Doc_Entry: print_html like Isabelle/jEdit, proper platform_path;
wenzelm
parents:
83386
diff
changeset
|
78 |
function open_document(platform_path) {
|
|
8d90bd0e4f39
more accurate Doc_Entry: print_html like Isabelle/jEdit, proper platform_path;
wenzelm
parents:
83386
diff
changeset
|
79 |
vscode.postMessage({ command: "open_document", platform_path: platform_path });
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
80 |
} |
| 83386 | 81 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
82 |
window.onload = function () {
|
| 83390 | 83 |
const state = vscode.getState(); |
84 |
if (state && state.sections) {
|
|
85 |
update(state.sections); |
|
86 |
} |
|
87 |
}; |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
88 |
})(); |