view assets/index.html.hbs @ 53:f81d2fdcbe63

Split index template
author Lewin Bormann <lbo@spheniscida.de>
date Fri, 22 Jul 2022 18:11:28 -0700
parents ce8e102ee2e0
children 2a7b358c2710
line wrap: on
line source

<!DOCTYPE html>
<html>
    <head>
        <title>Analyrics</title>

        <meta name="robots" content="noindex">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <link rel="stylesheet" href="static/style.css" type="text/css" />
        <link rel="icon" type="image/png" href="static/favicon.ico">

        <script src="static/chart.min.js" type="application/javascript"></script>

        <script type="application/javascript">
            let from = "{{ date.today }}";
            let duration = {{ date.duration }}; // in days

            function formatDate(d) {
                let m = d.getUTCMonth()+1; m = m < 10 ? "0"+m : m;
                let day = d.getUTCDate(); day = day < 10 ? "0"+day : day;

                return `${d.getUTCFullYear()}-${m}-${day}`;
            }
            function adjustURLDateParams(dateOffsetDays, durationMultiplier) {
                let usp = new URLSearchParams(window.location.search);
                let from_date = new Date(usp.get("from") || from);
                console.log("from date", from_date, " ", dateOffsetDays);
                let gduration = +usp.get("duration") || duration;

                let new_from_date = formatDate(new Date(from_date.getTime() + dateOffsetDays * 86400 * 1000));
                console.log(from_date, new_from_date);
                let new_duration = gduration * durationMultiplier;

                usp.set("from", new_from_date);
                usp.set("duration", new_duration.toFixed());
                window.location.search = usp.toString();
            };
            function toggleBots(checkboxid) {
                let box = document.getElementById(checkboxid);
                let usp = new URLSearchParams(window.location.search);
                usp.set("includebots", box.checked);
                window.location.search = usp.toString();
            };
        </script>

    </head>
    <body>

    <!-- Header -->
    <div id="header">
        <span id="logo">AnaLyrics</span>
        <a class="useraction" href="login">Log in</a>
    </div>
    {{#if flash}}<div id="flash"><span id="flashtext">{{flash}}<span></div>{{/if}}
    {{#if error}}<div id="error"><span id="errortext">{{error}}</span></div>{{/if}}
    </body>
</html>