Skip to content

Commit c9aef0b

Browse files
Update Implementation_of_data _structures_and_algorithms.js
1 parent 414cfd3 commit c9aef0b

1 file changed

Lines changed: 90 additions & 199 deletions

File tree

Lines changed: 90 additions & 199 deletions
Original file line numberDiff line numberDiff line change
@@ -1,209 +1,100 @@
1-
// 博客列表数据
2-
const blogList = [
3-
{
4-
title: '重新学树结构',
5-
content: '重新学树结构,包括二叉树、二叉树遍历算法、线索二叉树、哈夫曼编码……',
6-
icon: 'https://img-blog.csdnimg.cn/7b943421c19c4c7ca3928d66a0f1d9dc.jpeg#pic_center',
7-
link: '../../h5/sjjg/retree.html'
8-
},
9-
{
10-
title: '重新学图结构',
11-
content: '重新学图结构,包括概念、深度优先遍历、广度优先遍历、Prim算法、拓扑排序……',
12-
icon: 'https://img-blog.csdnimg.cn/34be94321c754413a42a4655debf142f.jpeg#pic_center',
13-
link: '../../h5/sjjg/regraph.html'
14-
},
15-
{
16-
title: 'C++面向对象实现稀疏矩阵的三元组表示',
17-
content: '使用C++手搓一个矩阵,能够矩阵转置、行列式求值、初等变换、逆矩阵、伴随矩阵求取等等等',
18-
icon: 'https://tse2-mm.cn.bing.net/th/id/OIP-C.JDKxAR-ti_KYYS9PObNpbgHaFG?pid=ImgDet&rs=1',
19-
link: '../../h5/sjjg/C++面向对象实现稀疏矩阵的三元组表示.html'
20-
},
21-
{
22-
title: '使用C++手搓一个矩阵',
23-
content: '使用C++手搓一个矩阵,能够矩阵转置、行列式求值、初等变换、逆矩阵、伴随矩阵求取等等等',
24-
icon: 'https://ts2.cn.mm.bing.net/th?id=OSK.98fe6647469a7ad3487d6274db57825a&w=188&h=132&c=7&o=6&dpr=1.3&pid=SANGAM',
25-
link: '../../h5/sjjg/手搓矩阵.html'
26-
},
27-
{
28-
title: '串结构',
29-
content: 'C++面向对象实现串,使用顺序存储的存储结构(附源代码)',
30-
icon: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.31vNg59mc0tJYE07qp_8ygHaCX?w=314&h=111&c=7&r=0&o=5&dpr=1.4&pid=1.7',
31-
link: '../../h5/sjjg/C++面向对象实现串,使用顺序存储的存储结构(附源代码).html'
32-
},
33-
{
34-
title: '邻接表图',
35-
content: '基于C++实现邻接表来表示图结构',
36-
icon: 'https://ts1.cn.mm.bing.net/th/id/R-C.8120cd354de7f107e88f25d41be15540?rik=82jalkofwWVAIQ&riu=http%3a%2f%2fimage.mamicode.com%2finfo%2f201901%2f20190128195839913108.png&ehk=tYOlVwqstfAfIQ3lIg2VNrq1Ct%2fPCfGOHdRH2PCX81A%3d&risl=&pid=ImgRaw&r=0',
37-
link: '../../h5/sjjg/C++实现邻接表来表示图结构(附源代码).html'
38-
},
39-
{
40-
title: '可视化二叉树',
41-
content: 'C++顺序存储实现二叉树并可视化(附源代码)',
42-
icon: 'https://pic3.zhimg.com/v2-400b251b664b915d44eca03351b1177a_r.jpg',
43-
link: '../../h5/sjjg/C++顺序存储实现二叉树并可视化(附源代码).html'
44-
},
45-
{
46-
title: '顺序栈',
47-
content: '基于C++的顺序栈的实现(附源代码)',
48-
icon: 'https://www.maxing128.com/wp-content/uploads/2017/10/SqStackPush.png',
49-
link: '../../h5/sjjg/C++顺序栈的实现.html'
50-
},
51-
{
52-
title: '邻接矩阵-图',
53-
content: '基于C++实现邻接矩阵表示的图结构(附源代码)',
54-
icon: 'https://sslprod.oss-cn-shanghai.aliyuncs.com/stable/slides/kaqmsk/kaqmsk_1440-28.jpg',
55-
link: '../../h5/sjjg/基于C++实现邻接矩阵表示的图结构(附源代码).html'
56-
},
57-
{
58-
title: '矩阵与行列式',
59-
content: 'C++面向对象实现矩阵(包含行列式)的一些操作(附源代码)',
60-
icon: 'https://th.bing.com/th/id/R.af12dd5d78d0e8f5b1e6d09218791d3c?rik=lHY7Jkphzy0CPw&pid=ImgRaw&r=0',
61-
link: '../../h5/sjjg/C++面向对象实现矩阵(包含行列式)的一些操作(附源代码).html'
62-
},
63-
{
64-
title: '多项式',
65-
content: '基于C++顺序存储实现多项式操作',
66-
icon: 'https://pic3.zhimg.com/v2-499e0b5a82d3e59ee0c9e949f15c8ea6_r.jpg',
67-
link: '../../h5/sjjg/C++面向对象+顺序表实现多项式的一些基本操作(附源代码).html'
68-
},
69-
{
70-
title: '带头结点的单链表',
71-
content: 'C++面向对象技术实现带头结点的单链表',
72-
icon: 'https://ts1.cn.mm.bing.net/th/id/R-C.ba9cee382124e480954a107f58a914af?rik=fBHuGF6gPq0gpw&riu=http%3a%2f%2fbbs.yanzhishi.cn%2fimage%2fshow%2fattachments-2020-06-R4dmYSKD5edf4d0085a27.png&ehk=wvVRU90U3a4PIjy6LfqyxK7PbvEfFxwa49BJuzl8zAA%3d&risl=&pid=ImgRaw&r=0',
73-
link: '../../h5/sjjg/C++面向对象技术实现带头结点的单链表.html'
74-
},
75-
{
76-
title: '链栈',
77-
content: '基于C++链栈的实现(附源代码)',
78-
icon: 'https://www.yht7.com/upload/image/2021/05/20/2021520101811926.png',
79-
link: '../../h5/sjjg/C++链栈的实现(附源代码).html'
80-
},
81-
{
82-
title: '顺序存储-队列',
83-
content: '基于C++面向对象技术实现顺序队列',
84-
icon: 'https://pic4.zhimg.com/80/v2-cf1c5c40578f002a8480b3475ce36a63_qhd.jpg',
85-
link: '../../h5/sjjg/基于C++面向对象技术实现顺序队列(附源代码).html'
86-
},
87-
{
88-
title: '顺序存储-线性表',
89-
content: 'C++实现顺序线性表(附源代码)',
90-
icon: 'https://pic4.zhimg.com/v2-ef9c513a7a4f197144321a9c79697dbb_b.png',
91-
link: '../../h5/sjjg/C++实现顺序线性表(附源代码).html'
92-
},
93-
{
94-
title: '链式存储-二叉树',
95-
content: 'C++链式存储实现二叉树(附源代码)',
96-
icon: 'https://tse2-mm.cn.bing.net/th/id/OIP-C.4wnL0Y7nHnbT0i9PrwNvQQHaEl?pid=ImgDet&rs=1',
97-
link: '../../h5/sjjg/C++链式存储实现二叉树(附源代码).html'
98-
},
99-
{
100-
title: '十字链表表示有向图',
101-
content: 'C++实现十字链表来表示有向图(附源代码)',
102-
icon: 'https://www.jxtxzzw.com/wp-content/uploads/2018/01/20170222122117558-1920x1314.jpg',
103-
link: '../../h5/sjjg/C++实现十字链表来表示有向图(附源代码).html'
104-
},
105-
{
106-
title: '深度搜索算法',
107-
content: '使用C++,基于邻接矩阵实现深度优先算法(附源代码)',
108-
icon: 'https://imgconvert.csdnimg.cn/aHR0cHM6Ly91cGxvYWQtaW1hZ2VzLmppYW5zaHUuaW8vdXBsb2FkX2ltYWdlcy85NDA2Mjk5LWQ4Y2E5ODQ2MjMzNGRhOWIucG5n?x-oss-process=image/format,png',
109-
link: '../../h5/sjjg/使用C++,基于邻接矩阵实现深度优先算法(附源代码).html'
110-
},
111-
{
112-
title: 'Prim算法',
113-
content: '基于C++无向网邻接表实现Prim算法(附源代码)',
114-
icon: 'https://pic4.zhimg.com/80/v2-b589c7cd61067b56b2ee886329916207_720w.webp',
115-
link: '../../h5/sjjg/基于C++无向网邻接表实现Prim算法(附源代码).html'
116-
},
117-
{
118-
title: '二维数组',
119-
content: '基于C语言动态的创建二维数组,可以自动扩容并且获取每行长度',
120-
icon: 'https://imgconvert.csdnimg.cn/aHR0cDovL2ltZy5ibG9nLmNzZG4ubmV0LzIwMTcxMDI1MTk1OTA0MjQ0?x-oss-process=image/format,png',
121-
link: '../../h5/sjjg/基于C语言动态的创建二维数组,可以自动扩容并且获取每行长度.html'
122-
},
123-
{
124-
title: '带头结点的循环链表',
125-
content: 'C++面向对象实现带头结点的循环链表(附源代码)',
126-
icon: 'https://tse4-mm.cn.bing.net/th/id/OIP-C.QR4BLR-vXNA2cZcZwsf0GQHaER?w=260&h=180&c=7&r=0&o=5&dpr=1.3&pid=1.7',
127-
link: '../../h5/sjjg/C++面向对象实现带头结点的循环链表(附源代码).html'
128-
}
129-
];
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>博客列表</title>
6+
<style>
7+
/* 搜索框样式 */
8+
.search-container {
9+
margin-bottom: 20px;
10+
text-align: center;
11+
}
12+
13+
.search-input {
14+
width: 400px;
15+
padding: 5px;
16+
margin-right: 10px;
17+
18+
}
19+
/* 返回按钮样式 */
20+
.return-button {
21+
padding: 5px;
13022

131-
const blogListContainer= document.getElementById('blogListContainer');
23+
}
24+
.search-button {
25+
padding: 5px;
26+
}
13227

133-
// 初始化博客列表
134-
function initBlogList() {
135-
blogListContainer.innerHTML = '';
136-
blogList.forEach(blog => {
137-
const blogCard = document.createElement('div');
138-
blogCard.className = 'blog-card';
139-
// 添加链接
140-
const link = document.createElement('a');
141-
link.href = blog.link;
142-
// 创建博客图标元素
143-
const icon = document.createElement('img');
144-
icon.className = 'blog-icon';
145-
icon.src = blog.icon;
146-
// 创建博客内容元素
147-
const content = document.createElement('div');
148-
content.className = 'blog-content';
149-
// 创建博客标题元素
150-
const title = document.createElement('div');
151-
title.className = 'blog-title';
152-
title.textContent = blog.title;
153-
// 创建博客描述元素
154-
const description = document.createElement('div');
155-
description.className = 'blog-description';
156-
description.textContent = blog.content;
157-
// 将元素添加到DOM中
158-
content.appendChild(title);
159-
content.appendChild(description);
160-
link.appendChild(icon);
161-
link.appendChild(content);
162-
blogCard.appendChild(link);
163-
blogListContainer.appendChild(blogCard);
164-
});
165-
}
166-
// 搜索功能
167-
function searchBlog() {
168-
const keyword = document.getElementById('searchInput').value;
169-
const blogCards = document.getElementsByClassName('blog-card');
170-
Array.from(blogCards).forEach(blogCard => {
171-
const title = blogCard.querySelector('.blog-title').textContent; // 获取标题文本内容
172-
const description = blogCard.querySelector('.blog-description').textContent; // 获取描述文本内容
173-
if (title.includes(keyword) || description.includes(keyword)) {
174-
blogCard.style.display = 'flex';
175-
// 关键字高亮显示
176-
const regex = new RegExp(`(${keyword})(?![^<]*>|[^<>]*<\/a>)`, 'gi');
177-
blogCard.innerHTML = blogCard.innerHTML.replace(regex, '<span class="highlight">$1</span>');
178-
// console.log(blogCard.innerHTML);
179-
} else {
180-
blogCard.style.display = 'none';
28+
/* 外部容器样式 */
29+
.blog-list-container {
30+
display: flex;
31+
flex-wrap: wrap;
32+
justify-content: center;
33+
align-items: flex-start;
18134
}
182-
});
183-
}
18435

36+
/* 博客卡片样式 */
37+
.blog-card {
38+
width: calc(50% - 20px);
39+
margin: 10px;
40+
padding: 20px;
41+
background-color: #f0f0f0;
42+
/*box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);*/
43+
display: flex;
44+
align-items: center;
45+
border-radius: 10px;
46+
box-shadow: 0 0 5px 5px #fff;
47+
transition: transform .3s;
48+
}
18549

186-
// 返回按钮功能
187-
function returnToAllBlogs() {
188-
const blogCards = document.getElementsByClassName('blog-card');
189-
Array.from(blogCards).forEach(blogCard => {
190-
blogCard.style.display = 'flex';
191-
blogCard.innerHTML = blogCard.innerHTML.replace('<span class="highlight">', '').replace('</span>', '');
192-
});
50+
/* 左侧图标样式 */
51+
.blog-icon {
52+
float: left;
53+
margin-bottom: 20px;
54+
width: 120px;
55+
border-radius: 15px;
56+
height: 120px;
19357
}
19458

195-
// 添加搜索按钮点击事件
196-
document.getElementById('searchButton').addEventListener('click', searchBlog);
59+
/* 右侧内容样式 */
60+
.blog-content {
61+
flex-grow: 1;
62+
float: left;
63+
padding-left: 10px;
64+
color: darkblue;
65+
}
19766

198-
// 添加回车键事件,触发搜索功能
199-
document.getElementById('searchInput').addEventListener('keydown', (event) => {
200-
if (event.key === 'Enter') {
201-
searchBlog();
202-
}
203-
});
67+
/* 标题样式 */
68+
.blog-title {
69+
font-size: 18px;
70+
font-weight: bold;
71+
margin-bottom: 10px;
72+
}
20473

205-
// 添加返回按钮点击事件
206-
document.getElementById('returnButton').addEventListener('click', returnToAllBlogs);
74+
/* 内容样式 */
75+
.blog-description {
76+
font-size: 14px;
77+
color: #777;
78+
}
20779

208-
// 初始化博客列表
209-
initBlogList();
80+
/* 关键字高亮样式 */
81+
.highlight {
82+
background-color: yellow;
83+
font-weight: bold;
84+
}
85+
body {
86+
background-color: tan;
87+
}
88+
</style>
89+
</head>
90+
<body>
91+
<div class="search-container">
92+
<input type="text" class="search-input" id="searchInput" placeholder="输入关键字搜索博客">
93+
<button class="search-button" id="searchButton">搜索</button>
94+
<button class="return-button" id="returnButton">返回</button>
95+
</div>
96+
<div class="blog-list-container" id="blogListContainer"></div>
97+
<script src="../../js/Implementation_of_data%20_structures_and_algorithms.js">
98+
</script>
99+
</body>
100+
</html>

0 commit comments

Comments
 (0)