+ 炽灼残渣新增保存功能

+ 格式化代码
This commit is contained in:
2022-11-20 00:19:56 +08:00
parent 0cff88322b
commit c120bf3fdd
9 changed files with 481 additions and 398 deletions

View File

@@ -8,7 +8,8 @@
<link rel="stylesheet" href="./theme.css">
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
let url = "https://api.github.com/repos/hbk01/hbk01.github.io/commits?per_page=10";
let page = 10
let url = `https://api.github.com/repos/hbk01/hbk01.github.io/commits?per_page=${page}`
let functions = [
{
@@ -32,22 +33,22 @@
"location": "./equipment.html"
},
{
"name": "L414-5KR 相关物质计算",
"name": "L414-5KR 相关物质",
"location": "./L414-5KR-impurities.html"
},
{
"name": "L014-1 相关物质计算",
"name": "L014-1 相关物质",
"location": "./L014-1-impurities.html"
}
];
]
$(document).ready(() => {
// var getRandomColor = () => '#' + (Math.random() * 0xffffff << 0).toString(16)
// 加载功能列表
functions.forEach(value => {
let div = `<div class="item" onclick="window.location.href='${value.location}'">${value.name}</div>`;
$(".list").append(div);
});
let div = `<div class="item" onclick="window.location.href='${value.location}'">${value.name}</div>`
$(".list").append(div)
})
// 加载最近的 commit 记录
$.getJSON(url, data => {
@@ -55,34 +56,35 @@
let color2 = '#f3f3f3'
let changeColor = false
data.forEach(element => {
let hash = element.sha.slice(0, 7)
let verified = element.commit.verification.verified
let html_url = element.html_url
// 处理换行和+号
let message = element.commit.message.replaceAll("\n", "<br>");
let message = element.commit.message.replaceAll("\n", "<br>")
if (message.startsWith("+")) {
message = message.replace("+", "<br>&nbsp;&nbsp;<strong>&bull;</strong>");
message = message.replace("+", "<br>&nbsp;&nbsp;<strong>&bull;</strong>")
}
message = message.replaceAll("+", "&nbsp;&nbsp;<strong>&bull;</strong>")
// 处理提交的日期
let date = new Date(element.commit.committer.date) // "2022-10-08T10:54:36Z"
date = new Date(+ new Date(date) + 28800000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
date = new Date(+ new Date(date) + 28800000).toISOString()
date = date.replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
// 组装标题信息
let verifiedString = "<span style='color: green;'><strong>Verified</strong></span>"
let hash = `<a href='${element.html_url}'>${element.sha.slice(0, 7)}</a>`
let verified = `${element.commit.verification.verified ? verifiedString : ""}`
let header = `${hash} ${date} ${verified}`
changeColor = !changeColor
let header = `
${date}
(<a href='${html_url}'>${hash}</a>${verified ? ", <span style='color: green'><strong>Verified</strong></span>" : ""})`
let color = `${changeColor ? color1 : color2}`
let msg = `
<div style="background-color: ${changeColor ? color1 : color2}; padding: 5px 0px 5px 10px">
<div style="background-color: ${color}; padding: 5px 0px 5px 10px">
${header}
${message}
</div>`
$(".changelog").append(msg);
});
});
});
$(".changelog").append(msg)
})
})
})
</script>
<title>QC TOOL</title>
</head>