Skip to content

Instantly share code, notes, and snippets.

@bonbombs
Forked from sam0737/clock.html
Last active July 24, 2023 03:26
Show Gist options
  • Save bonbombs/d95ef5655447cb41bc71b8645f45cf8a to your computer and use it in GitHub Desktop.
Save bonbombs/d95ef5655447cb41bc71b8645f45cf8a to your computer and use it in GitHub Desktop.

Revisions

  1. bonbombs revised this gist Oct 23, 2021. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions clock.html
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,9 @@
    <title>A simple clock</title>

    </head>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Dosis:wght@700&display=swap" rel="stylesheet">

    <body translate="no" >
    <div id="output"></div>
  2. @sam0737 sam0737 revised this gist Sep 8, 2017. No changes.
  3. @sam0737 sam0737 created this gist Sep 8, 2017.
    42 changes: 42 additions & 0 deletions clock.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    <!DOCTYPE html>
    <html>

    <head>
    <meta charset="UTF-8">
    <title>A simple clock</title>

    </head>

    <body translate="no" >
    <div id="output"></div>

    <script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js'></script>
    <script>
    // https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
    var urlParams;
    (function () {
    var match,
    pl = /\+/g, // Regex for replacing addition symbol with a space
    search = /([^&=]+)=?([^&]*)/g,
    decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
    query = window.location.search.substring(1);

    urlParams = {};
    while (match = search.exec(query))
    urlParams[decode(match[1])] = decode(match[2]);
    })();

    var output = document.getElementById("output");
    if (urlParams["style"]) output.setAttribute("style", urlParams["style"]);
    if (urlParams["bodyStyle"]) document.body.setAttribute("style", urlParams["bodyStyle"]);

    var c;
    setInterval(
    c = function() {
    output.innerText = moment().format(urlParams["format"] || '');
    }, 1000);
    c();

    </script>
    </body>
    </html>