mirror of
https://github.com/MeiK2333/github-style.git
synced 2025-10-07 01:54:06 +00:00
Fixes #75
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
.vscode
|
.vscode
|
||||||
|
.idea
|
@@ -2,15 +2,13 @@
|
|||||||
|
|
||||||
## 已知问题
|
## 已知问题
|
||||||
|
|
||||||
- 多个可点击元素点击后会出现蓝色的边框
|
- 往年热力图起始点错误
|
||||||
- 移动端模式下点击热力图可能会导致样式错乱
|
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
- 评论
|
- 评论
|
||||||
- 自定义菜单
|
- 自定义菜单
|
||||||
- 更多链接平台支持
|
- 更多链接平台支持
|
||||||
- 热力图和底部列表的时区问题
|
|
||||||
|
|
||||||
## Init hugo site
|
## Init hugo site
|
||||||
|
|
||||||
|
@@ -28,8 +28,8 @@ let contributions;
|
|||||||
function switchYear(year) {
|
function switchYear(year) {
|
||||||
let startDate;
|
let startDate;
|
||||||
let endDate;
|
let endDate;
|
||||||
if (year != now.getFullYear().toString()) {
|
if (year !== now.getFullYear().toString()) {
|
||||||
const date = new Date(`${year}-01-01 00:00:00`);
|
const date = new Date(Number(year), 0, 1, 0, 0, 0, 0);
|
||||||
startDate = new Date(date.getFullYear(), 0, 1);
|
startDate = new Date(date.getFullYear(), 0, 1);
|
||||||
endDate = new Date(date.getFullYear(), 11, 31);
|
endDate = new Date(date.getFullYear(), 11, 31);
|
||||||
} else {
|
} else {
|
||||||
@@ -60,7 +60,7 @@ function switchYear(year) {
|
|||||||
|
|
||||||
const yearList = document.querySelectorAll('.js-year-link');
|
const yearList = document.querySelectorAll('.js-year-link');
|
||||||
for (const elem of yearList) {
|
for (const elem of yearList) {
|
||||||
if (elem.innerText == year) {
|
if (elem.innerText === year) {
|
||||||
elem.classList.add('selected');
|
elem.classList.add('selected');
|
||||||
} else {
|
} else {
|
||||||
elem.classList.remove('selected');
|
elem.classList.remove('selected');
|
||||||
@@ -85,7 +85,7 @@ function monthly(year, month, posts) {
|
|||||||
</time>
|
</time>
|
||||||
</li>`;
|
</li>`;
|
||||||
}
|
}
|
||||||
let html = `
|
return `
|
||||||
<div class="contribution-activity-listing float-left col-12 col-lg-10">
|
<div class="contribution-activity-listing float-left col-12 col-lg-10">
|
||||||
<div class="width-full pb-4">
|
<div class="width-full pb-4">
|
||||||
<h3 class="h6 pr-2 py-1 border-bottom mb-3" style="height: 14px;">
|
<h3 class="h6 pr-2 py-1 border-bottom mb-3" style="height: 14px;">
|
||||||
@@ -133,7 +133,6 @@ function monthly(year, month, posts) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
return html;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function yearList() {
|
function yearList() {
|
||||||
@@ -156,7 +155,7 @@ function yearList() {
|
|||||||
|
|
||||||
function graph(year, posts, startDate, endDate) {
|
function graph(year, posts, startDate, endDate) {
|
||||||
const postsStr = posts.length === 1 ? "post" : "posts";
|
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`;
|
document.querySelector('#posts-count').innerText = `${posts.length} ${postsStr} in the last year`;
|
||||||
} else {
|
} else {
|
||||||
document.querySelector('#posts-count').innerText = `${posts.length} ${postsStr} in ${year}`;
|
document.querySelector('#posts-count').innerText = `${posts.length} ${postsStr} in ${year}`;
|
||||||
@@ -166,7 +165,7 @@ function graph(year, posts, startDate, endDate) {
|
|||||||
const count = {};
|
const count = {};
|
||||||
for (const post of posts) {
|
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')}`;
|
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;
|
count[date] = 1;
|
||||||
} else {
|
} else {
|
||||||
count[date]++;
|
count[date]++;
|
||||||
@@ -183,9 +182,9 @@ function graph(year, posts, startDate, endDate) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j == 0) {
|
if (j === 0) {
|
||||||
if (i <= 51) {
|
if (i <= 51) {
|
||||||
if (startMonth != date.getMonth()) {
|
if (startMonth !== date.getMonth()) {
|
||||||
monthPos.push(i);
|
monthPos.push(i);
|
||||||
startMonth = date.getMonth();
|
startMonth = date.getMonth();
|
||||||
}
|
}
|
||||||
@@ -193,7 +192,7 @@ function graph(year, posts, startDate, endDate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let c;
|
let c;
|
||||||
if (count[dataDate] == undefined) {
|
if (count[dataDate] === undefined) {
|
||||||
c = 0;
|
c = 0;
|
||||||
} else {
|
} else {
|
||||||
c = count[dataDate];
|
c = count[dataDate];
|
||||||
@@ -225,7 +224,7 @@ function graph(year, posts, startDate, endDate) {
|
|||||||
}
|
}
|
||||||
for (let i = 0; i < monthPos.length; i++) {
|
for (let i = 0; i < monthPos.length; i++) {
|
||||||
const month = monthPos[i];
|
const month = monthPos[i];
|
||||||
if (month == -1) {
|
if (month === -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
html += `<text x="${15 * month + 16}" y="-9"
|
html += `<text x="${15 * month + 16}" y="-9"
|
||||||
@@ -275,19 +274,19 @@ function hideTip() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getCoords(elem) {
|
function getCoords(elem) {
|
||||||
var box = elem.getBoundingClientRect();
|
const box = elem.getBoundingClientRect();
|
||||||
|
|
||||||
var body = document.body;
|
const body = document.body;
|
||||||
var docEl = document.documentElement;
|
const docEl = document.documentElement;
|
||||||
|
|
||||||
var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;
|
const scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;
|
||||||
var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;
|
const scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;
|
||||||
|
|
||||||
var clientTop = docEl.clientTop || body.clientTop || 0;
|
const clientTop = docEl.clientTop || body.clientTop || 0;
|
||||||
var clientLeft = docEl.clientLeft || body.clientLeft || 0;
|
const clientLeft = docEl.clientLeft || body.clientLeft || 0;
|
||||||
|
|
||||||
var top = box.top + scrollTop - clientTop;
|
const top = box.top + scrollTop - clientTop;
|
||||||
var left = box.left + scrollLeft - clientLeft;
|
const left = box.left + scrollLeft - clientLeft;
|
||||||
|
|
||||||
return { top, left, width: box.width, height: box.height };
|
return { top, left, width: box.width, height: box.height };
|
||||||
}
|
}
|
||||||
@@ -312,7 +311,7 @@ function relativeTime(dateStr) {
|
|||||||
if (days < 30) {
|
if (days < 30) {
|
||||||
return `${days} days ago`;
|
return `${days} days ago`;
|
||||||
}
|
}
|
||||||
if (date.getFullYear() == now.getFullYear()) {
|
if (date.getFullYear() === now.getFullYear()) {
|
||||||
return `${date.getDate()} ${months[date.getMonth()]}`;
|
return `${date.getDate()} ${months[date.getMonth()]}`;
|
||||||
}
|
}
|
||||||
return `${date.getDate()} ${months[date.getMonth()]} ${date.getFullYear()}`;
|
return `${date.getDate()} ${months[date.getMonth()]} ${date.getFullYear()}`;
|
||||||
|
Reference in New Issue
Block a user