-
Notifications
You must be signed in to change notification settings - Fork 0
/
BookMarks.html
638 lines (623 loc) · 21.2 KB
/
BookMarks.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
<html>
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script
async
src="https://www.googletagmanager.com/gtag/js?id=UA-169217093-1"
></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "UA-169217093-1");
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.min.js"></script>
<link rel="shortcut icon"
href=https://i.loli.net/2020/06/11/jqHydZv8sN9RWDt.png type=image/x-icon>
<link rel=icon href=https://i.loli.net/2020/06/11/jqHydZv8sN9RWDt.png
type=image/gif>
<title>Your navigation</title>
<style>
body,
ul,
ol,
li,
p,
h1,
h2,
h3,
h4,
h5,
h6,
form,
fieldset,
table,
td,
img,
div {
margin: 0;
padding: 0;
border: 0;
}
body {
background: #fff;
color: #333;
font-size: 12px;
margin-top: 5px;
font-family: "Arial", "Microsoft YaHei", "黑体", "宋体", sans-serif;
}
ul,
ol {
list-style-type: none;
}
select,
input,
img,
select {
vertical-align: middle;
}
a {
text-decoration: none;
}
a:link {
color: #009;
}
a:visited {
color: #800080;
}
a:hover,
a:active,
a:focus {
color: #c00;
text-decoration: underline;
}
#fakebox {
background: white;
cursor: text;
}
</style>
<style>
.logo {
background-size: 100%;
background-repeat: no-repeat;
width: 200px;
height: 100px;
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0c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40N2MxMC41IDAgMTcuOTggNC4xMiAyMy42IDkuNDlsLTYuNjQgNi42NGMtNC4wMy0zLjc4LTkuNDktNi43Mi0xNi45Ny02LjcyLTEzLjg2IDAtMjQuNyAxMS4xNy0yNC43IDI1LjAzIDAgMTMuODYgMTAuODQgMjUuMDMgMjQuNyAyNS4wMyA4Ljk5IDAgMTQuMTEtMy42MSAxNy4zOS02Ljg5IDIuNjYtMi42NiA0LjQxLTYuNDYgNS4xLTExLjY1bC0yMi40OS4wMXoiLz48L3N2Zz4=);
margin: 0 auto;
}
.search {
text-align: center;
}
.s-input {
border: 0;
outline: 0;
font-size: 14px;
width: 400px;
text-align: center;
border: 1px solid #ddd;
border-radius: 26px;
padding: 10px;
}
.shuqian-cont {
max-width: 1000px;
margin: 0 auto;
margin-top: 20px;
}
.group-t {
font-size: 14px;
color: #333;
text-align: center;
}
.one-grop-content {
padding-top: 10px;
display: flex;
flex-wrap: wrap;
position: relative;
right: -30px;
}
.a-wrap {
align-items: center;
border: 1px solid #dddddd;
line-height: 30px;
vertical-align: middle;
height: 30px;
display: inline-block;
padding-left: 10px;
padding-right: 10px;
border-radius: 15px;
margin-right: 15px;
margin-bottom: 12px;
user-select: none;
position: relative;
}
.a-wrap img {
display: inline-block;
}
.a-wrap span {
display: inline-block;
}
a:active {
color: #333;
}
a:checked,
a:visited {
color: #333;
}
a:hover {
text-decoration: none;
background-color: #eee;
}
.more-link:hover {
cursor: pointer;
}
.add-link {
border: 0;
display: flex;
}
.add-link input {
border: 0;
display: inline-block;
vertical-align: middle;
border-bottom: 1px solid #ddd;
padding-bottom: 3px;
outline: 0;
}
.tianjia-btn {
background-color: azure;
outline: 0;
}
[v-cloak] {
display: none;
}
.delete-l {
background-image: url(https://i.loli.net/2020/06/11/BgbfxFv7y6oecIk.png);
background-size: 100% 100%;
position: absolute;
right: -3px;
height: 16px;
width: 16px;
top: -6px;
display: none;
}
.edit-l {
background-image: url(https://i.loli.net/2020/06/11/uz1SYth4d5f2JUP.png);
background-size: 100% 100%;
position: absolute;
left: -6px;
height: 18px;
width: 18px;
top: -6px;
display: none;
}
.a-wrap:hover .delete-l {
display: block;
}
.a-wrap:hover .edit-l {
display: block;
}
.close-add {
background-image: url(https://i.loli.net/2020/06/11/BgbfxFv7y6oecIk.png);
width: 20px;
height: 20px;
background-size: 100%;
margin-left: 20px;
cursor: pointer;
}
.md-icon {
position: relative;
top: -2px;
}
.edit-group-name {
background-image: url(https://i.loli.net/2020/06/11/uz1SYth4d5f2JUP.png);
background-size: 100% 100%;
position: absolute;
height: 18px;
width: 18px;
right: -8px;
top: 16px;
display: none;
cursor: pointer;
}
.delete-group {
background-image: url(https://i.loli.net/2020/06/11/BgbfxFv7y6oecIk.png);
background-size: 100% 100%;
position: absolute;
height: 18px;
width: 18px;
right: -34px;
top: 16px;
display: none;
cursor: pointer;
}
.group-t:hover .edit-group-name {
display: block;
}
.group-t:hover .delete-group {
display: block;
}
button {
cursor: pointer;
}
.add-gruopbtn {
border: 0;
background-color: #fff;
color: #ddd;
}
</style>
</head>
<body>
<div style="height: 80px;"></div>
<!-- Titel -->
<center>
<h1><span id="project-title">BookMarks</span><a id="proj-title-btn"> 📝</a></h1>
<a id="export-btn">Export</a> | <a id="import-dialog-open">Import</a>
</center>
<!-- Titel -->
<dialog id="import-dialog" style="width: 450px; height: 150px; position: absolute; top: 0px; padding: 1em 2em 1em 2em;">
<form id="import-form" autocomplete="off">
<label for="import-url">
(复制当前目录可在选择文件时使用)
<input type="text" id="import-url" style="width: 380px;background-color: lightgray;" readonly>
<button id="import-copy-btn">copy</button>
</label>
<input type="file" id="import-file" accept=".json" style="margin-top: 2em;border: 1px solid blue;width: 380px;">
<button id="import-btn">import</button>
<p style="margin-top: 3em; text-align: right;">
<button id="import-dialog-close">close</button>
</p>
</form>
</dialog>
<script>
const localLocation = decodeURI(location.toString());
function getWorkingDir() {
let s = localLocation;
s = s.substring('file:///'.length);
const i = s.lastIndexOf('/');
let wd = s.substring(0, i) + '/';
if (window.navigator.platform.startsWith('Win')) {
wd = wd.replace(/\//g, '\\');
}
return wd;
}
const workingDir = getWorkingDir();
const importUrl = document.querySelector('#import-url');
const importCopyBtn = document.querySelector('#import-copy-btn');
importUrl.value = workingDir;
importCopyBtn.addEventListener('click', event => {
event.preventDefault();
new Promise(resolve => resolve(importUrl.select()))
.then(() => document.execCommand('copy'));
});
function localStorageClear() {
localStorage.removeItem("_my_nav_");
}
function clearAndFillLocalStorage(db) {
localStorageClear();
localStorage.setItem("_my_nav_", JSON.stringify(db));
};
const importDialog = document.querySelector('#import-dialog');
document.querySelector('#import-dialog-open').addEventListener('click', event => {
event.preventDefault();
importDialog.setAttribute('open', '');
});
document.querySelector('#import-btn').addEventListener('click', function (event) {
event.preventDefault();
const file = document.querySelector('#import-file').files[0];
const reader = new FileReader();
reader.onerror = function () {
window.alert("导入文件失败!");
}
reader.onload = function () {
let db = JSON.parse(reader.result);
clearAndFillLocalStorage(db);
window.location.reload();
}
reader.readAsText(file);
});
document.querySelector('#import-dialog-close').addEventListener('click', event => {
event.preventDefault();
importDialog.removeAttribute('open');
});
</script>
<dialog id="export-dialog"
style="width: 450px; height: 150px; position: absolute; top: 0px; padding: 2em;">
<p>请右键点击以下链接, 另存为文件</p>
<p style="text-align: center"><a id="json-url" download="small-plans.json">small-plans.json</a></p>
<label for="export-url">
当前目录:
<input type="text" id="export-url" form="export-form" style="width: 320px;background-color: lightgray;" readonly>
<button id="export-copy-btn">copy</button>
</label>
<p><span style="color: red">注意:</span> 覆盖旧文件时请务必确认文件名!</p>
<form style="margin-top: 2em; text-align: right;" id="export-form">
<button id="export-dialog-close">close</button>
</form>
</dialog>
<script>
const exportUrl = document.querySelector('#export-url');
const exportCopyBtn = document.querySelector('#export-copy-btn');
exportUrl.value = workingDir;
exportCopyBtn.addEventListener('click', event => {
event.preventDefault();
new Promise(resolve => resolve(exportUrl.select()))
.then(() => document.execCommand('copy'));
});
function getDB() {
return app.list
};
function showJsonUrl() {
let dbBlob = new Blob([JSON.stringify(getDB(), null, 2)], {type: 'application/json'});
let jsonUrl = window.URL.createObjectURL(dbBlob);
const jsonUrlElem = document.querySelector('#json-url');
jsonUrlElem.setAttribute('href', jsonUrl);
jsonUrlElem.setAttribute('download', jsonFileName);
jsonUrlElem.innerText = jsonFileName;
};
const exportDialog = document.querySelector('#export-dialog');
document.querySelector('#export-btn').addEventListener('click', function (event) {
event.preventDefault();
exportDialog.setAttribute('open', '');
showJsonUrl();
});
document.querySelector('#export-dialog-close').addEventListener('click', event => {
event.preventDefault();
exportDialog.removeAttribute('open');
});
</script>
<div id="app">
<div class="shuqian-cont" v-for="group,gindex in list" v-cloak>
<div class="group-t">
<span
style="
padding: 15px;
position: relative;
display: inline-block;
letter-spacing: 2px;
color: #333;
font-weight: bold;
"
>{{group.group_name}}
<div
v-show="editGroupNameIndex===-1"
class="edit-group-name"
@click.prevent="showEditGroupName(gindex)"
></div>
<div
v-show="editGroupNameIndex===-1&&gindex!==0"
class="delete-group"
@click.prevent="deleteGroup(gindex)"
></div>
<!-- 修改group name -->
<div
class="a-wrap add-link"
style="margin: 20px; display: none;"
v-show="editGroupNameIndex === gindex"
>
<input
v-model="newGroupName"
style="margin-left: 20px;"
placeholder="new group name"
/>
<button class="tianjia-btn" @click="saveNewGroupName">
EDIt GROUP NAME
</button>
<div class="close-add" @click="closeShowEditGroupName"></div>
</div>
<!-- 修改group name 结束 -->
</span>
</div>
<div class="one-grop-content">
<div v-for="(l,index) in group.link_list">
<a class="a-wrap" :href="l.link" target="_blank">
<img
style="width: 16px; height: 16px;"
class="md-icon"
title=""
alt=""
:src="'https://www.google.com/s2/favicons?domain='+l.link"
/>
<span style="margin-left: 5px;" v-text="l.desc"></span>
<div
class="delete-l"
@click.prevent="deleteLink(gindex,index)"
></div>
<div
class="edit-l"
@click.prevent="toeditLink(gindex,index,l.link,l.desc)"
></div>
</a>
<!-- 修改form -->
<div
class="a-wrap add-link"
v-show="editGi===gindex&&editlI===index"
>
<input v-model="editLink" placeholder="link" />
<input
v-model="editDesc"
style="margin-left: 20px;"
placeholder="describe"
/>
<button class="tianjia-btn" @click="saveEditLink">EDIt</button>
<div class="close-add" @click="closeEdit"></div>
</div>
<!-- 修改form结束 -->
</div>
<!-- 添加按钮 -->
<div
class="a-wrap more-link"
:style="addShow===gindex?'background:#eee':''"
>
<div @click="showAdd(gindex)">+ add</div>
</div>
<!-- 添加按钮结束 -->
<!-- 增加form -->
<div class="a-wrap add-link" v-show="addShow === gindex">
<input v-model="group.add_link" placeholder="link address" />
<input
v-model="group.add_desc"
style="margin-left: 20px;"
placeholder="description"
/>
<button class="tianjia-btn" @click="addLink(gindex)">ADD</button>
<div class="close-add" @click="closeAdd"></div>
</div>
<!-- 增加form 结束 -->
</div>
</div>
<div style="text-align: center; margin-top: 40px; height: 100px;">
<button class="tianjia-btn add-gruopbtn" @click="addGroup">
ADD GROUP
</button>
</div>
</div>
<script>
var app = new Vue({
el: "#app",
data: {
list: [],
addShow: -1,
editGi: -1,
editlI: -1,
editLink: "",
editDesc: "",
editGroupNameIndex: -1,
newGroupName: "",
},
methods: {
showAdd: function (i) {
if (i !== this.addShow) {
//关闭修改
this.closeEdit();
this.addShow = i;
} else {
this.addShow = -1;
}
},
addLink: function (i) {
let addDesc = this.list[i].add_desc;
let addLink = this.list[i].add_link;
this.list[i].link_list.push({ link: addLink, desc: addDesc });
this.list[i].add_desc = "";
this.list[i].add_link = "";
this.addShow = -1;
this.saveStorage();
},
deleteLink: function (gI, lI) {
let that = this;
this.list[gI].link_list.splice(lI, 1);
this.saveStorage();
},
saveStorage: function () {
let that = this;
setTimeout(function () {
localStorage.setItem("_my_nav_", JSON.stringify(that.list));
window.postMessage(
{ name: "_send_my_nav_", data: JSON.stringify(that.list) },
"*"
);
}, 100);
},
closeAdd: function () {
this.addShow = -1;
},
toeditLink: function (gI, lI, link, desc) {
// 关闭新增
this.closeAdd();
this.editGi = gI;
this.editlI = lI;
this.editLink = link;
this.editDesc = desc;
},
closeEdit: function () {
this.editGi = -1;
this.editlI = -1;
},
saveEditLink: function () {
this.list[this.editGi].link_list[this.editlI].link = this.editLink;
this.list[this.editGi].link_list[this.editlI].desc = this.editDesc;
this.saveStorage();
this.closeEdit();
},
showEditGroupName: function (groupIndex) {
this.editGroupNameIndex = groupIndex;
},
closeShowEditGroupName: function () {
this.editGroupNameIndex = -1;
},
saveNewGroupName: function () {
this.list[this.editGroupNameIndex].group_name = this.newGroupName;
this.saveStorage();
this.closeShowEditGroupName();
},
deleteGroup: function (gindex) {
if (this.list[gindex].link_list.length === 0) {
this.list.splice(gindex, 1);
this.saveStorage();
} else {
var r = confirm(
"Deleting a group will remove all links in the group"
);
if (r == true) {
this.list.splice(gindex, 1);
this.saveStorage();
} else {
}
}
},
addGroup: function () {
this.list.push({
group_name: "new group" + (this.list.length + 1),
add_desc: "",
add_link: "",
link_list: [],
});
this.saveStorage();
},
},
});
let data = JSON.parse(localStorage.getItem("_my_nav_"));
if (data) {
app.list = data;
} else {
app.list = [
{
group_name: "default group",
add_desc: "",
add_link: "",
link_list: [
{
link: "https://github.com/channg",
desc: "channg",
},
],
},
];
}
document.addEventListener("visibilitychange", function () {
let data = JSON.parse(localStorage.getItem("_my_nav_"));
if (data) {
app.list = data;
}
});
document.getElementById("inputTxt").focus();
// 从chrome插件中获取
window.addEventListener(
"message",
function (event) {
if (event.data.name === "_my_nav_") {
console.log(event.data);
try {
let data = JSON.parse(event.data.data);
if (data) {
app.list = data;
}
} catch (e) {}
}
},
false
);
</script>
</body>
</html>