With the ringing of the last alarm clock of the vacation, the 19-day summer vacation has come to an end, and the challenge of senior year is now approaching.
Early this morning, I went to school to check the class assignments. Class 6—still a regular class. Fortunately, the classroom is in a good location, so I am quite satisfied with this class assignment. Not many of my old classmates are in the same class as me, which means I can meet more new friends; that is also quite nice. Next comes a year of working hard to prepare for the challenge.
The topic has gone off track. This is a technical blog post, mainly because I wanted to add a countdown component to my blog, so here is 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 cohort 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 the above line and comment it out.
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>
That’s it. For the specific result, just check the right sidebar of this blog.
An Aside
This is the last technical blog post before 2019.06.09. Starting an hour from now, my laptop will be locked away in a cabinet. Over the next 310 days, I will try hard to restrain myself from touching things unrelated to my studies. I may occasionally write about my feelings, but there will be very few such posts. As for the internet, I won’t think about it for the time being...
Wait for me to come back. When the countdown on the right turns into -2天, it will mean that I have completed more than 300 days of intensive training. Regardless of whether I do well on the exam by then, I will have made the effort, and therefore won’t have to regret it later. No matter where the future takes me, I must live up to every step I have taken. 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 a $10 top-up plus the $50 GitHub gave me, the $5-per-month server will last exactly one year, enough to get me through the end of the gaokao. The server is configured to create an automatic snapshot backup once a month. In addition, I set up a scheduled task in Baota to back up the entire site to Alibaba Cloud OSS once every three days, retaining 120 copies—also exactly one year when calculated. If nothing goes wrong with the website, it should run safely until I finish my exam. So, I can let go now.
I really like a line from the TV series The Way We Were:
I return, I return; the fields are about to go to waste, so why not come home?
Then I 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 contact. That’s all, then. I should go to school now. Goodbye.