diff --git a/.gitignore b/.gitignore
index 2608ec2..0ed240d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
.DS_Store
-.vscode
\ No newline at end of file
+.vscode
+.idea
\ No newline at end of file
diff --git a/README.md b/README.md
index 292f4f8..438b6c3 100644
--- a/README.md
+++ b/README.md
@@ -2,15 +2,13 @@
## 已知问题
-- 多个可点击元素点击后会出现蓝色的边框
-- 移动端模式下点击热力图可能会导致样式错乱
+- 往年热力图起始点错误
## TODO
- 评论
- 自定义菜单
- 更多链接平台支持
-- 热力图和底部列表的时区问题
## Init hugo site
diff --git a/static/js/github-style.js b/static/js/github-style.js
index 72a5aaa..04a79b9 100644
--- a/static/js/github-style.js
+++ b/static/js/github-style.js
@@ -28,8 +28,8 @@ let contributions;
function switchYear(year) {
let startDate;
let endDate;
- if (year != now.getFullYear().toString()) {
- const date = new Date(`${year}-01-01 00:00:00`);
+ if (year !== now.getFullYear().toString()) {
+ const date = new Date(Number(year), 0, 1, 0, 0, 0, 0);
startDate = new Date(date.getFullYear(), 0, 1);
endDate = new Date(date.getFullYear(), 11, 31);
} else {
@@ -60,7 +60,7 @@ function switchYear(year) {
const yearList = document.querySelectorAll('.js-year-link');
for (const elem of yearList) {
- if (elem.innerText == year) {
+ if (elem.innerText === year) {
elem.classList.add('selected');
} else {
elem.classList.remove('selected');
@@ -85,7 +85,7 @@ function monthly(year, month, posts) {
`;
}
- let html = `
+ return `
@@ -133,7 +133,6 @@ function monthly(year, month, posts) {
`;
- return html;
}
function yearList() {
@@ -156,7 +155,7 @@ function yearList() {
function graph(year, posts, startDate, endDate) {
const postsStr = posts.length === 1 ? "post" : "posts";
- if (year == now.getFullYear().toString()) {
+ if (year === now.getFullYear().toString()) {
document.querySelector('#posts-count').innerText = `${posts.length} ${postsStr} in the last year`;
} else {
document.querySelector('#posts-count').innerText = `${posts.length} ${postsStr} in ${year}`;
@@ -166,7 +165,7 @@ function graph(year, posts, startDate, endDate) {
const count = {};
for (const post of posts) {
const date = `${post.date.getFullYear()}-${(post.date.getMonth() + 1).toString().padStart(2, '0')}-${post.date.getDate().toString().padStart(2, '0')}`;
- if (count[date] == undefined) {
+ if (count[date] === undefined) {
count[date] = 1;
} else {
count[date]++;
@@ -183,9 +182,9 @@ function graph(year, posts, startDate, endDate) {
continue;
}
- if (j == 0) {
+ if (j === 0) {
if (i <= 51) {
- if (startMonth != date.getMonth()) {
+ if (startMonth !== date.getMonth()) {
monthPos.push(i);
startMonth = date.getMonth();
}
@@ -193,7 +192,7 @@ function graph(year, posts, startDate, endDate) {
}
let c;
- if (count[dataDate] == undefined) {
+ if (count[dataDate] === undefined) {
c = 0;
} else {
c = count[dataDate];
@@ -225,7 +224,7 @@ function graph(year, posts, startDate, endDate) {
}
for (let i = 0; i < monthPos.length; i++) {
const month = monthPos[i];
- if (month == -1) {
+ if (month === -1) {
continue;
}
html += `