-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
142 lines (137 loc) · 5.02 KB
/
Copy pathindex.js
File metadata and controls
142 lines (137 loc) · 5.02 KB
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
//elements
const e_tooltip = $('mdui-tooltip[content="没有东西的,就一个摆设"]');
const e_sort = $('.sort');
const e_cate = $('.category');
const e_toollist = $('.tools');
const e_rand = $('mdui-button-icon[icon="shuffle"]');
//egg
var clk = 0;
var eggs = {
3: '你怎么还在点',
4: '我说了这个东西没用的,别点了',
5: '你点了,我也不知道',
6: '真的是……',
7: '这么有能耐的话……',
8: '你有本事点到第100次',
9: '你就点吧,懒得告诉你点了多少下,你自己数去',
50: '50下了,你还在点?',
51: '给你一点缓冲,我是来告诉你现在在51~54下',
55: '你就点吧,懒得告诉你点了多少下,你自己数去',
95: '加油哦,就快到了,放慢点吧',
100: '不是你真的这么无聊',
101: '既然这样',
102: '我喜欢你',
103: '≧ ﹏ ≦',
104: '100下是不是太少了()',
105: '写不动了,后面真的没了,除非你能点到一个及其大的数字',
106: '再见~',
110: '我是一个装饰按钮我是一个装饰按钮我是一个装饰按钮',
520: '您已抵达:520下',
530: '我是一个装饰按钮我是一个装饰按钮我是一个装饰按钮',
721: '0721~',
722: '我是一个装饰按钮我是一个装饰按钮我是一个装饰按钮',
10086: '怎么点了10086下?',
10087: '我是一个装饰按钮我是一个装饰按钮我是一个装饰按钮',
114514: '114514+下了,嗯哼哼啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊',
114520: '我是一个装饰按钮我是一个装饰按钮我是一个装饰按钮',
33550336: '你是白厄吗?',
33550337: '再次踏上轮回……',
};
e_tooltip.on('click',function(){
clk++;
if(eggs[clk]){
$(this).attr('content',eggs[clk]);
};
});
//random
e_rand.on('hover mouseenter touchstart mouseup',()=>{
e_rand.attr('href', links[Math.floor(Math.random() * links.length)].url)
});
//trigger
e_sort.on('change',function(){
if(e_sort.val() === ''){
e_sort.val('recommend');
};
show_tools(links, e_sort.val(), e_cate.val());
});
e_cate.on('change',function(){
if(e_cate.val() === ''){
e_cate.val('no');
};
show_tools(links, e_sort.val(), e_cate.val());
});
show_tools(links, e_sort.val(), e_cate.val());
print_rcm();
function show_tools(list, sort, cate) {
// prepare
const categorized = {};
if (cate === 'no') {
categorized.no = [...list].sort((a, b) =>
b.slot[sort] - a.slot[sort]
);
} else {
list.forEach(item => {
const categoryValue = item.slot[cate];
if (!categorized[categoryValue]) {
categorized[categoryValue] = [];
};
categorized[categoryValue].push(item);
});
Object.entries(categorized).forEach(([key, items]) => {
items.sort((a, b) =>
b.slot[sort] - a.slot[sort]
);
});
};
console.log(categorized);
// show
e_toollist.empty();
if(cate === 'no'){
for(let i=0;i<categorized.no.length;i++){
let item = categorized.no[i];
let card = $(`
<mdui-card clickable href="${item.url}">
<mdui-icon name="${item.icon}" class="item-icon"></mdui-icon>
<h1>${item.name}</h1>
<p>${item.desc}</p>
${item.github ? `<mdui-chip href="${item.github}" icon="code" target="_blank">Source</mdui-chip>` : ''}
</mdui-card>`);
e_toollist.append(card);
};
} else {
let cate_list = cate_order[cate];
for(let i=0;i<cate_list.length;i++){
let key = cate_list[i][0];
let name = cate_list[i][1];
let items = categorized[key];
if(items){
let group = $(`<mdui-collapse-item value="item-${i}">
<mdui-list-item slot="header" icon="folder--outlined">${name}</mdui-list-item>
</mdui-collapse-item>`);
for(let j=0;j<items.length;j++){
let item = items[j];
let card = $(`
<mdui-card clickable href="${item.url}">
<mdui-icon name="${item.icon}" class="item-icon"></mdui-icon>
<h1>${item.name}</h1>
<p>${item.desc}</p>
${item.github ? `<mdui-chip href="${item.github}" icon="code" target="_blank">Github</mdui-chip>` : ''}
</mdui-card>`);
group.append(card);
};
e_toollist.append(group);
};
};
};
};
function print_rcm(){
let rcm_list = [];
for(let i=0;i<links.length;i++){
let item = links[i];
rcm_list.push({'name':item.name,'recommend':item.slot.recommend});
};
rcm_list.sort(function(a,b){
return b.recommend - a.recommend;
});
console.log(rcm_list);
};