blob: fa1327d60fcb0d7ea236b655a2ce26008028f75f (
plain)
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
|
/* API collapsing */
document.addEventListener('DOMContentLoaded', (event) => {
document.querySelectorAll("dl.cpp").forEach(cppListing => {
const dt = cppListing.querySelector("dt");
let shouldBeExpanded = false;
if(dt.id == document.location.hash.substring(1))
shouldBeExpanded = true;
cppListing.classList.add(shouldBeExpanded ? "expanded" : "unexpanded");
const button = document.createElement("span");
button.classList.add("lv-api-expansion-button");
button.addEventListener("click", () => {
cppListing.classList.toggle("unexpanded");
cppListing.classList.toggle("expanded");
});
dt.insertBefore(button, dt.firstChild);
});
fetch('https://lvgl.io/home-banner.txt') // Replace with your URL
.then(response => {
// Check if the request was successful
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
// Read the response as text
return response.text();
})
.then(data => {
const section = document.querySelector('.wy-nav-content-wrap');
//Add a div
const newDiv = document.createElement('div');
newDiv.style="background-image: linear-gradient(45deg, black, #5e5e5e); color: white; border-bottom: 4px solid #e10010; padding-inline:3em"
section.insertBefore(newDiv, section.firstChild);
//Add a p to the div
const newP = document.createElement('p');
newP.style="padding-block:12px; margin-block:0px;align-content: center;align-items: center;"
newP.innerHTML = data
newDiv.insertBefore(newP, newDiv.firstChild);
const children = newDiv.querySelectorAll('*');
// Iterate over each child
children.forEach(child => {
// Check if the child has an id
if (child.id) {
// Prepend 'docs-' to the id
child.id = 'docs-' + child.id;
}
})
}) .catch(error => {
console.error('Fetch error: ' + error.message);
});
})
|