~martijnbraam/struct

559ede2fd9ccd1e56743f4cc9845696712834750 — Martijn Braam 11 months ago 09f7979
Add button to load demo data
1 files changed, 35 insertions(+), 0 deletions(-)

M index.html
M index.html => index.html +35 -0
@@ 107,6 107,27 @@

            #logo {
                height: 48px;
                display: inline-block;
                vertical-align: bottom;
            }

            header nav {
                display: inline-block;
                height: 48px;
                padding-top: 10px;
                padding-left: 10px;
                padding-right: 10px;
            }

            header nav a {
                display: inline-block;
                background: var(--bg);
                padding: 4px 10px;
                border-radius: 3px;
                text-decoration: none;
                color: white;
                font-family: sans-serif;
                margin-bottom: 5px;
            }
        </style>
    </head>


@@ 115,6 136,9 @@
        <div class="container">
            <header>
                <img src="logo.svg" id="logo">
                <nav>
                    <a href="#" id="demo">Demo</a>
                </nav>
            </header>
            <div class="entry">
                <textarea id="struct" placeholder="struct.pack('')"></textarea>


@@ 152,6 176,15 @@
            updateData(format);
        }

        function doDemo(event) {
            event.preventDefault();
            const formatEntry = document.getElementById('struct');
            const dataEntry = document.getElementById('data');
            dataEntry.value = 'FF D8 FF E0 00 10 4A 46 49 46 00 01 01 00 00 01';
            formatEntry.value = "struct.pack('>2s 2sH 5s 2B', soi, app0, length, identifier, major_version, minor_version)";
            onChange();
        }

        document.addEventListener('DOMContentLoaded', function () {
            const dataEntry = document.getElementById('data');
            dataEntry.addEventListener('change', onChange);


@@ 163,6 196,8 @@
            formatEntry.addEventListener('keyup', onChange);

            onChange();

            document.getElementById('demo').addEventListener('click', doDemo);
        });

        function onDataPaste(event) {