This is the 9th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021

【 a Point of the Day 】

The Eiffel Tower, in fact, bears the names of 72 scientists…

A code,

【 Core code 】

  1. GetTodayNowTime () Calculates the current time
        // Calculate the current time conversion
        function getTodayNowTime() {
            var date = new Date(a);// Get the current year, month, day, hour, minute, and second respectively
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var day = date.getDate();
            var hour = date.getHours();
            var minute = date.getMinutes();
            var second = date.getSeconds();
            var week = ["Day"."一"."二"."Three"."Four"."Five"."Six"] // Array of a week
            if (hour < 10) {
                hour = "0" + hour;
            }
            if (second < 10) {
                second = "0" + second
            }
            if (minute < 10) {
                minute = "0" + minute
            }
            var today = year + "Year" + month + "Month" + day + "Day";
            var nowTime = hour + "When" + minute + "Points" + second + "Seconds";
            return today + nowTime + "Week" + week[date.getDay()];
        }
Copy the code
  1. GetPoem () is a random line of poetry
        // Get a random line of poetry
        function getPoem() {
            jinrishici.load(function (result) {
                sentence.innerHTML = result.data.content;
                console.log(result)
                info.innerHTML =  < ' +
                    result
                    .data.origin.title + ' ' ' +
                    '【' + result.data.origin.dynasty + '】' + result.data.origin.author +
                    "</span>";

                poem_lasttime.innerHTML = 'Last click time:' + getTodayNowTime();
            });
        }
Copy the code
  1. Clock () Periodically refreshes the current time
        // Refresh the current time periodically:
        self.setInterval("clock()".1000); // The first argument is the function method and the second is 1 second
        function clock() {
            document.getElementById("clock").innerHTML = "Current time:" + getTodayNowTime();

        }
Copy the code

【 Complete code 】

Random verse. HTML

<! DOCTYPEhtml>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="Width = device - width, initial - scale = 1.0">
    <title>A random line of poetry southern - gold digger</title>
</head>
<script src="http://code.jquery.com/jquery-latest.js">
</script>

<body style="height: 100%; width: 100%; background-color: pink;">
    <! Get a random line of poetry needed -->
    <script src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8"></script>
    <center style="margin-top: 100px;">
        <div style="width: 500px;">
            <h2>A random line of poetry<span><button onclick="getPoem()">In a word</button>
                    <p style="font-size: 14px;" id="poem_lasttime"></p>
                </span>
            </h2>
            <div id="poem_sentence"></div>
            <div id="poem_info" style="float: right;"></div>
        </div>
    </center>
    <div id="clock" style="position: fixed; bottom: 500px; width: 100%; text-align: center;"></div>
    <script type="text/javascript">
        console.log("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
        console.log("********* Test Demo Southerners - Nuggets *********");
        console.log("https://juejin.cn/user/2840793779295133");
        console.log("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");

        getPoem(); // Initialize the random first verse

        var poem_lasttime = document.querySelector("#poem_lasttime"); // Record the time of the last click
        var sentence = document.querySelector("#poem_sentence"); // Poetry content
        var info = document.querySelector("#poem_info"); // Poetry author information

        // Get a random line of poetry
        function getPoem() {
            jinrishici.load(function (result) {
                sentence.innerHTML = result.data.content;
                console.log(result)
                info.innerHTML =  < ' +
                    result
                    .data.origin.title + ' ' ' +
                    '【' + result.data.origin.dynasty + '】' + result.data.origin.author +
                    "</span>";

                poem_lasttime.innerHTML = 'Last click time:' + getTodayNowTime();
            });
        }


        // Refresh the current time periodically:
        self.setInterval("clock()".1000); // The first argument is the function method and the second is 1 second
        function clock() {
            document.getElementById("clock").innerHTML = "Current time:" + getTodayNowTime();

        }

        // Calculate the current time conversion
        function getTodayNowTime() {
            var date = new Date(a);// Get the current year, month, day, hour, minute, and second respectively
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var day = date.getDate();
            var hour = date.getHours();
            var minute = date.getMinutes();
            var second = date.getSeconds();
            var week = ["Day"."一"."二"."Three"."Four"."Five"."Six"] // Array of a week
            if (hour < 10) {
                hour = "0" + hour;
            }
            if (second < 10) {
                second = "0" + second
            }
            if (minute < 10) {
                minute = "0" + minute
            }
            var today = year + "Year" + month + "Month" + day + "Day";
            var nowTime = hour + "When" + minute + "Points" + second + "Seconds";
            return today + nowTime + "Week" + week[date.getDay()];
        }
    </script>
</body>

</html>
Copy the code

Ii. Display and experience

1 First Page 2 Click on another sentence 3 Experience Address

Random verse. HTML

【 the 】

Thank you for reading the end, if you have a different view, you are welcome to leave a comment below this article. I am a southerner who loves computers and loves the motherland. If the content of this article is only for learning reference, if there is any infringement, I am very sorry, please contact the author immediately delete.