Source: site.view [edit]
Function name: share
Arguments: info
Description:
Page type: html
Render function:  
Module: sportstreak

Page source:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Open Graph / Facebook -->
    <meta property="og:type" content="website">
    <meta property="og:url" content="https://sports-streak.com">
    <meta property="og:title" content="Sports Streak">
    <meta property="og:description" content="A basketball-themed this-or-that trivia game about the top 75 NBA players.">
    <meta property="og:image" content="https://sports-streak.com/images/bball-texture2.png">

    <!-- Twitter -->
    <meta property="twitter:card" content="https://sports-streak.com/site/pyramid(5)">
    <meta property="twitter:url" content="https://sports-streak.com">
    <meta property="twitter:title" content="Sports Streak">
    <meta property="twitter:description" content="A basketball-themed this-or-that trivia game about the top 75 NBA players.">
    <meta property="twitter:image" content="https://sports-streak.com/images/bball-texture2.png">

    <title>Sports Streak</title>
    <script type="text/javascript">

        // Return just the date, in format 12/31/2023
        function formatDate(date) {
           let year = date.getFullYear();
           let month = date.getMonth() + 1; // getMonth() is zero-indexed
           let day = date.getDate();
           return `${month.toString().padStart(2, '0')}/${day.toString().padStart(2, '0')}/${year}`;
        }

        var round = 0;
        var total = 0;
        var today;
        var todayCookie;


        // Parses the incoming info, and show the content.
        function onLoad() {
           round = 0;
           total = 0;

           today = formatDate(new Date());   // as formatted string  eg 11/31/2023

           todayCookie = JSON.parse( atob( "<webl>info</webl>" ) );

           // If we already played today, update screen but don't allow play
           if ("total" in todayCookie) {
              round = todayCookie.round;
              total = todayCookie.total;
              document.getElementById("question").innerText = "On " + today + ", I got " + round + " sports questions right in a row!  Can you beat my streak?  My multi-day streak is now " + total + ".";
           } 
           else {
              // hide the share button until the game is finished, then start the game...
              document.getElementById("shareBtn").style.display = 'none';
           }           
        }

        // Copies the link to a clipboard to share
        function play() {
           let url = "http://sports-stream.com/site/share:" + btoa('{ "round":' + round + ', "total": ' + total + ', "date": "' + today + '" }');
           if (copyStringToClipboard(url)) {
              alert("A link was copied to your clipboard that you can share with friends to show off your great score!");
           }
        }

    </script>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        header, footer {
            background-color: #f4f4f4;
            text-align: center;
            padding: 5px 0;
        }
        main {
            padding: 10px;
            text-align: center;
        }
        .question p {
            font-size: 1.2em;
        }
        .instructions p {
            font-size: 1em;
        }
        .options {
            display: flex;
            justify-content: space-around;
            margin: 10px 0;
        }
        .option {
            text-align: center;
        }
        .streak {
            text-align: center;
            font-size: 1.5em;
            margin: 12px 0;
        }
        .result {
            font-size: 2em;
            margin: 20px 0;
        }
        .option img {
            width: 100px;
            height: auto;
        }
        .feedback {
            margin-top: 20px;
        }
        .pButton {
            padding: 10px;
            margin: 10px;
            background-color: #007bff;
            color: white;
            border: none;
            cursor: pointer;
        }
        #stat {
            font-weight: bold;
        }
        button:hover {
            background-color: #0056b3;
        }
        footer p {
            font-size: 0.8em;
        }
    </style>
</head>


<body onload="onLoad()">
    <header>
            <div id="title">
                <img width=250 src="http://sports-streak.com/images/ss-logo.png">
            </div>
    </header>
    <main>
        <section class="question">
            <p id="question"></p>
        </section>
        <section class="instructions">
            <p>Sports Streak: Guess which player has the higher stat in a category. Correct guesses build your streak. Play daily to extend your multi-day streak!</p>
        </section>
        <section class="feedback">
            <a href="http://sports-streak.com" class="pButton">Play!</a>
            <p>&nbsp;</p>
        </section>
    </main>
    <footer>
        <p>Copyright (c) 2024 by 52 Productions, Inc.  All rights reserved.</p>
    </footer>
</body>
</html>