-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanki-backand-video-templage.html
More file actions
76 lines (63 loc) · 2.38 KB
/
Copy pathanki-backand-video-templage.html
File metadata and controls
76 lines (63 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{{FrontSide}}
<hr id=answer>
<div id="media-container"></div>
<script>
function ttt() {
const rawJson = `{{Back}}`; // Use backand field for variants JSON
let mediaItems = [];
try {
mediaItems = JSON.parse(rawJson);
} catch (err) {
console.error("Ошибка парсинга JSON:", err, rawJson);
return;
}
const container = document.getElementById("media-container");
mediaItems.forEach((item, index) => {
const wrapper = document.createElement("div");
wrapper.style.marginBottom = "1em";
// Description (if present)
const desc = document.createElement("div");
desc.textContent = item.desc || "";
desc.style.fontWeight = "bold";
// Video
const video = document.createElement("video");
video.src = item.file;
video.controls = true;
video.style.width = "100%";
video.addEventListener("loadedmetadata", () => {
video.currentTime = item.start || 0;
});
// Definitions container (initially hidden)
const defContainer = document.createElement("div");
defContainer.id = `definitions-${index}`;
defContainer.style.display = "none";
defContainer.style.marginTop = "0.5em";
// Definitions list
if (item.definitions && Array.isArray(item.definitions)) {
const ul = document.createElement("ul");
item.definitions.forEach(def => {
const li = document.createElement("li");
li.textContent = def;
ul.appendChild(li);
});
defContainer.appendChild(ul);
} else {
defContainer.textContent = "No definitions available";
}
// Toggle button
const toggleBtn = document.createElement("button");
toggleBtn.textContent = "Show Definitions";
toggleBtn.style.marginTop = "0.5em";
toggleBtn.onclick = () => {
defContainer.style.display = defContainer.style.display === "none" ? "block" : "none";
toggleBtn.textContent = defContainer.style.display === "none" ? "Show Definitions" : "Hide Definitions";
};
wrapper.appendChild(desc);
wrapper.appendChild(video);
wrapper.appendChild(toggleBtn);
wrapper.appendChild(defContainer);
container.appendChild(wrapper);
});
}
ttt();
</script>