summaryrefslogtreecommitdiff
path: root/plugin_loader/templates/plugin_view.html
blob: 9d7ba1bc4b7aab27be8b8f1c7c0238bf8e42a260 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<link rel="stylesheet" href="/static/styles.css">
<script>
    const tile_iframes = [];
    window.addEventListener("message", function (evt) {
        tile_iframes.forEach(iframe => {
            iframe.contentWindow.postMessage(evt.data, "http://127.0.0.1:1337");
        });
    }, false);

    function loadPlugin(callsign, name) {
        this.parent.postMessage("PLUGIN_LOADER__"+name, "https://steamloopback.host");
        location.href = `/plugins/load_main/${callsign}`;
    }
</script>

{% if not plugins|length %}
    <div class="quickaccessmenu_TabGroupPanel_1QO7b Panel Focusable">
        <div class="quickaccesscontrols_EmptyNotifications_3ZjbM" style="padding-top:7px;">
            No plugins installed
        </div>
    </div>
{% endif %}

<div class="quickaccessmenu_TabGroupPanel_1QO7b Panel Focusable">
    {% for plugin in plugins %}
        {% if plugin.tile_view_html|length %}
            <div class="quickaccesscontrols_PanelSectionRow_26R5w">
                <div onclick="loadPlugin('{{ plugin.callsign }}', '{{ plugin.name }}')"
                    class="basicdialog_Field_ugL9c basicdialog_WithChildrenBelow_1RjOd basicdialog_InlineWrapShiftsChildrenBelow_3a6QZ basicdialog_ExtraPaddingOnChildrenBelow_2-owv basicdialog_StandardPadding_1HrfN basicdialog_HighlightOnFocus_1xh2W Panel Focusable"
                    style="--indent-level:0; margin: 0px; padding: 0px; padding-top: 8px;">
                    <iframe id="tile_view_iframe_{{ plugin.callsign }}" 
                        scrolling="no" marginwidth="0" marginheight="0"
                        hspace="0" vspace="0" frameborder="0"
                        style="border-radius: 2px;"
                        src="/plugins/load_tile/{{ plugin.callsign }}">
                    </iframe>
                    <script>
                        (function() {
                            let iframe = document.getElementById("tile_view_iframe_{{ plugin.callsign }}");
                            tile_iframes.push(document.getElementById("tile_view_iframe_{{ plugin.callsign }}"));

                            iframe.onload = function() {
                                let html = iframe.contentWindow.document.children[0];
                                let last_height = 0;

                                setInterval(function() {
                                    let height = iframe.contentWindow.document.children[0].scrollHeight;
                                    if (height != last_height) {
                                        iframe.height = height + "px";
                                        last_height = height;
                                    }
                                }, 100);

                                iframe.contentWindow.document.body.onclick = function () {
                                    loadPlugin('{{ plugin.callsign }}', '{{ plugin.name }}');
                                };
                            }
                        })();
                    </script>
                </div>
            </div>
        {% else %}
            <div class="quickaccesscontrols_PanelSectionRow_26R5w">
                <div onclick="loadPlugin('{{ plugin.callsign }}', '{{ plugin.name }}')"
                    class="basicdialog_Field_ugL9c basicdialog_WithChildrenBelow_1RjOd basicdialog_InlineWrapShiftsChildrenBelow_3a6QZ basicdialog_ExtraPaddingOnChildrenBelow_2-owv basicdialog_StandardPadding_1HrfN basicdialog_HighlightOnFocus_1xh2W Panel Focusable"
                    style="--indent-level:0; margin: 0px; padding: 0px; padding-top: 8px;">
                    <div class="basicdialog_FieldChildren_279n8">
                        <button type="button" tabindex="0"
                            class="DialogButton _DialogLayout Secondary basicdialog_Button_1Ievp Focusable">{{ plugin.name }}
                        </button>
                    </div>
                </div>
            </div>
        {% endif %}
    {% endfor %}
</div>