Gaokao Countdown: This May Be My Last Technical Blog Post
With the ringing of the last alarm of the vacation, my 19-day summer vacation has come to an end, and the challenge of my senior year of high school lies ahead.
Early this morning, I went to school to check the class assignments. Class 6—still an ordinary class. Fortunately, the classroom is in a good location, so I am fairly satisfied with this assignment. Not many of my old classmates are in the same class as me, which means I can get to know more new friends. That is also a good thing. From now on, it is time to work hard and prepare for the year ahead.
That was a digression. This is a technical blog post, mainly about adding a countdown component to my blog, which led to the following code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>高考倒计时</title>
<script language="javascript" type="text/javascript">
var interval = 1000;
function ShowCountDown(year, month, day, divname) {
var now = new Date();
var endDate = new Date(year, month - 1, day);
var leftTime = endDate.getTime() - now.getTime(); // 剩余毫秒
var leftsecond = parseInt(leftTime / 1000);
var day1 = Math.floor(leftsecond / (60 * 60 * 24)); // 剩余天
var hour = Math.floor((leftsecond - day1 * 24 * 60 * 60) / 3600); // 剩余时
var minute = Math.floor((leftsecond - day1 * 24 * 60 * 60 - hour * 3600) / 60); // 剩余分
var second = Math.floor(leftsecond - day1 * 24 * 60 * 60 - hour * 3600 - minute * 60); // 剩余秒
var cc = document.getElementById(divname);
cc.innerHTML = "距离高考" + year + "年" + month + "月" + day + "日还有:" + day1 + "天" + hour + "小时" + minute + "分" + second + "秒"; // 显示
}
window.setInterval(function() {
ShowCountDown(2019, 6, 7, 'gaokao1');
}, interval);
</script>
</head>
<body>
<div id="gaokao1"></div>
</body>
</html>
ShowCountDown(2019, 6, 7, 'gaokao1'); is the endpoint of the countdown (that is, the beginning of the first battle for this class of senior high school students).
As for how to integrate it into the Handsome theme used by this blog:
Open the /usr/themes/handsome/component/sidebar.php file.
Comment out line 98 (the line number may differ between versions):
<h3 class="widget-title m-t-none text-md"><?php _me("广告") ?></h3>
In any case, just find and comment out the line above.
Then, in 设置外观, enter the following HTML in 全局右侧边栏广告位:
<div class="panel b-a">
<h4 class="font-thin padder">
高考倒计时
</h4>
<ul class="list-group">
<li class="list-group-item">
<script language="javascript" type="text/javascript">
function ShowCountDown(year, month, day, divname) {
var now = new Date();
var endDate = new Date(year, month - 1, day);
var leftTime = endDate.getTime() - now.getTime(); // 剩余毫秒
var leftsecond = parseInt(leftTime / 1000);
var day1 = Math.floor(leftsecond / (60 * 60 * 24)); // 剩余天
var hour = Math.floor((leftsecond - day1 * 24 * 60 * 60) / 3600); // 剩余时
var minute = Math.floor((leftsecond - day1 * 24 * 60 * 60 - hour * 3600) / 60); // 剩余分
var second = Math.floor(leftsecond - day1 * 24 * 60 * 60 - hour * 3600 - minute * 60); // 剩余秒
var cc = document.getElementById(divname);
cc.innerHTML = "距离高考" + year + "年" + month + "月" + day + "日还有:" + day1 + "天" + hour + "小时" + minute + "分" + second + "秒"; // 显示
}
window.setInterval(function() {
ShowCountDown(2019, 6, 7, 'gaokao1');
}, interval);
</script>
<div id="gaokao1"></div>
</li>
</ul>
</div>
And that is it. You can see the specific result in the right sidebar of this blog.
An Aside
This is my last technical blog post before 2019.06.09. Starting an hour from now, my laptop will be locked in a cabinet. Over the next 310 days, I will work hard to restrain myself from touching anything unrelated to my studies. I may occasionally write about my feelings, but even that will be rare. I will temporarily stop thinking about the Internet...
Wait for me to come back. When the countdown on the right turns into -2天, it means I have completed more than 300 days of intensive training. No matter whether I do well on the exam by then, I will have put in the effort, so I will not end up regretting it. No matter where the future takes me, I must do right by every step I take. Even if it may leave behind a few regrets, aren't those also part of my own experience?
Just a few days ago, I moved all the websites to DigitalOcean. With 10 dollars added to my account plus the 50 dollars given by GitHub, the server costing 5 dollars per month will last exactly one year, carrying me through until after the gaokao. The server is configured to automatically create a snapshot backup once a month. In addition, I have set up a scheduled task in BaoTa to back up the entire site to Alibaba Cloud OSS once every three days, retaining 120 copies. Calculated out, that also happens to be one year. If nothing goes wrong with the website, it should run safely until I finish the exam. So, I can let go now.
I really like a line from the TV series The Way We Were:
Return, return; the fields will be overgrown—why not go home?
Then I also imitated it and wrote a line for myself:
The road ahead is long; for the rest of my life, why not pursue it?
Over the next 300-plus days, I may be out of touch. That is all, then. I should head to school now. Goodbye.
Comments
(0)No comments yet. Start the conversation.