-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathscript.js
52 lines (44 loc) · 1.64 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Layout will not be affected after remove below javascript code
// Handle Image Gallery
const galleryMask = document.querySelector(".gallery-mask");
const maskImage = document.querySelector(".mask-image");
const galleryImgs = document.querySelectorAll(".image-item");
galleryMask.addEventListener("click", () => {
galleryMask.classList.add("mask-off");
});
galleryImgs.forEach((item) => {
item.addEventListener("click", () => {
let styleValue = item.getAttribute("style");
maskImage.setAttribute(
"src",
styleValue.slice(styleValue.indexOf(": url(") + 7, -3)
);
galleryMask.classList.remove("mask-off");
});
});
function myFunction() {
// 声明变量
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
// 循环遍历所有列表项,并隐藏那些与搜索查询不匹配的项
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
// Handle Publish Date
const dateData = document.getElementById("dateData");
const sinceData = document.getElementById("sinceData");
let publishDate = "2022-04-26";
dateData.innerHTML = moment(publishDate).format("LL");
sinceData.innerHTML = moment(publishDate).fromNow();