-
Notifications
You must be signed in to change notification settings - Fork 0
/
bookmark.html
108 lines (104 loc) · 5.33 KB
/
bookmark.html
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>随机一文 - 「ChenMo · 陈默」</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1"/>
<meta name="viewport"
content="width=device-width, initial-scale=1.0,maximum-scale=1.0, minimum-scale=1, user-scalable=no"/>
<link rel="stylesheet" href="dist/css/main.css?v=0.3">
</head>
<body>
<!-- /panel -->
<div class="ui-content" role="main">
<div class="text-detail">
<p class="text-title">我的收藏</p>
<hr class="sort-separate-line sort-separate-line20"/>
<ul class="favourite-lists" id="favourite_lists">
<!-- <li class="card-shadow">-->
<!-- <span class="favourite-delete" data-id="1">-->
<!-- <img src="./dist/image/delete.svg" alt="" data-index="1">-->
<!-- </span>-->
<!-- <a href="./index.html">-->
<!-- <div>-->
<!-- <span class="favourite-title">对不起什么</span>-->
<!-- </div>-->
<!-- <div class="favourite-author">文 / <span id="favourite_author">我的收藏</span> <span-->
<!-- class="favourite-date">2020-12-12</span></div>-->
<!-- <div class="favourite-desc">宽恕舞台上的第一句台词“对不起”的真正意思,就是“对不起,请原谅我占用了你这一刻的时间,也请原谅我这么无赖地烦着你,要你听我接下来的话”。-->
<!-- </div>-->
<!-- </a>-->
<!-- </li>-->
</ul>
</div>
<div class="footer">
<div class="flex justify-around align-center">
<div class="menu-item menu-item-1" id="back">返回</div>
<!-- <div class="menu-item menu-item-2 bookmark" id="favourite">-->
<!-- <!– <button class="bookmark" aria-checked="true">–>-->
<!-- <svg viewBox="0 0 36 36">-->
<!-- <path class="filled" d="M26 6H10V18V30C10 30 17.9746 23.5 18 23.5C18.0254 23.5 26 30 26 30V18V6Z" />-->
<!-- <path class="default" d="M26 6H10V18V30C10 30 17.9746 23.5 18 23.5C18.0254 23.5 26 30 26 30V18V6Z" />-->
<!-- <path class="corner" d="M10 6C10 6 14.8758 6 18 6C21.1242 6 26 6 26 6C26 6 26 6 26 6H10C10 6 10 6 10 6Z" />-->
<!-- </svg>-->
<!-- <!– </button>–>-->
<!-- </div>-->
<div class="menu-item menu-item-3" id="clear">清空</div>
</div>
</div>
</div>
<script src="dist/js/common.js"></script>
<script>
let lists = document.getElementById('favourite_lists');
let clearData = document.getElementById('clear');
let htmlStr = ''
let count = 0;
function setItem() {
if (typeof localStorage.bookmarkLists !== 'undefined') {
let favourite_lists = JSON.parse(localStorage.getItem('bookmarkLists'))
if (favourite_lists.length > 0) {
favourite_lists.forEach(e => {
htmlStr += '<li class="card-shadow">\n' +
' <span class="favourite-delete" data-index=' + count + '>\n' +
' <img src="./dist/image/delete.svg" class="delete" alt="">\n' +
' </span>\n' +
' <a href="./index.html?c=' + count + '&f=bookmark">\n' +
' <div>\n' +
' <span class="favourite-title">' + e.title + '</span>\n' +
' </div>\n' +
' <div class="favourite-author">文 / <span id="favourite_author">' + e.author + '</span> <span class="favourite-date">' + e.favouriteDate + '</span></div>\n' +
' <div class="favourite-desc">' + e.digest + '</div>\n' +
' </a>\n' +
' </li>'
count++
})
}
if (count === 0) htmlStr = '<img src="./dist/image/noFound.svg" class="no-found" alt="404">'
lists.innerHTML = htmlStr;
}
}
setItem()
let back = document.getElementById('back');
back.onclick = function () {
window.location.href = './index.html'
}
clearData.onclick = function () {
localStorage.removeItem('bookmarkLists');
location.reload();
}
document.querySelectorAll('.favourite-delete').forEach(
button => button.addEventListener('click', e => {
if (typeof localStorage.bookmarkLists !== "undefined") {
let temp = JSON.parse(localStorage.bookmarkLists)
let index = button.dataset.id;
temp.splice(index, 1);
count--
localStorage.setItem('bookmarkLists', JSON.stringify(temp))
setItem();
}
}
)
);
</script>
</body>
</html>