1{% extends "!page.html" %}
2
3{% block footer %}
4
5<style>
6  .wy-side-nav-search > div[role="search"] {
7    color: black;
8  }
9</style>
10 <script type="text/javascript">
11    $(document).ready(function() {
12        $(".toggle > *").hide();
13        $(".toggle .header").show();
14        $(".toggle .header").click(function() {
15            $(this).parent().children().not(".header").toggle(400);
16            $(this).parent().children(".header").toggleClass("open");
17        })
18    });
19</script>
20
21<script type="text/javascript">
22function add_version_selector()
23{
24    return fetch("https://raw.githubusercontent.com/lvgl/docs_compiled/gh-pages/versionlist.txt")
25        .then(res => res.text())
26        .then(text => {
27            const versions = text.split("\n").filter(version => version.trim().length > 0);
28            let p = document.getElementById("rtd-search-form").parentElement;
29            p.innerHTML = `
30            <select name="versions" id="versions" onchange="ver_sel()" style="border-radius:5px; margin-bottom:15px">
31            ${versions.map(version => {
32                let versionName = "";
33                if(version == "master") versionName = "master (latest)";
34                else versionName = "v" + ((version.indexOf(".") != -1) ? version : (version + " (latest minor)"));
35                return `<option value="${version}">${versionName}</option>`;
36            })}
37            </select>` + p.innerHTML;
38        });
39}
40
41function ver_sel()
42{
43  var x = document.getElementById("versions").value;
44  window.location.href = window.location.protocol + "//" + window.location.host + "/" + x + "/";
45}
46
47document.addEventListener('DOMContentLoaded', (event) => {
48    add_version_selector().then(() => {
49        var value = window.location.pathname.split('/')[1];
50        document.getElementById("versions").value = value;
51    });
52
53})
54document.addEventListener('DOMContentLoaded', (event) => {
55    function onIntersection(entries) {
56        entries.forEach(entry => {
57            let currentlyLoaded = entry.target.getAttribute("data-is-loaded") == "true";
58            let shouldBeLoaded = entry.intersectionRatio > 0;
59            if(currentlyLoaded != shouldBeLoaded) {
60                entry.target.setAttribute("data-is-loaded", shouldBeLoaded);
61                if(shouldBeLoaded) {
62                    let iframe = document.createElement("iframe");
63                    iframe.src = entry.target.getAttribute("data-real-src");
64                    entry.target.appendChild(iframe);
65                } else {
66                    let iframe = entry.target.querySelector("iframe");
67                    iframe.parentNode.removeChild(iframe);
68                }
69            }
70        });
71    }
72    const config = {
73        rootMargin: '600px 0px',
74        threshold: 0.01
75    };
76    let observer = new IntersectionObserver(onIntersection, config);
77    document.querySelectorAll(".lv-example").forEach(iframe => {
78        observer.observe(iframe);
79    });
80});
81</script>
82{% endblock %}
83