Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
东方怂天
famicn
提交
32bce4e0
F
famicn
项目概览
东方怂天
/
famicn
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
famicn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
32bce4e0
编写于
11月 03, 2018
作者:
P
Pengan Zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add search support
上级
58f76252
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
48 addition
and
7 deletion
+48
-7
base.css
base.css
+6
-1
index.html
index.html
+7
-1
index.js
index.js
+35
-5
未找到文件。
base.css
浏览文件 @
32bce4e0
...
...
@@ -59,6 +59,11 @@ a:active {
text-decoration
:
none
;
}
figure
a
{
figure
a
{
display
:
block
;
}
#loadmore
{
text-align
:
center
;
display
:
block
;
}
\ No newline at end of file
index.html
浏览文件 @
32bce4e0
...
...
@@ -35,8 +35,11 @@
</li>
</ul>
</nav>
<div
class=
"feature-wrapper p
t-5 p
b-5 mt-0 mt-lg-0"
>
<div
class=
"feature-wrapper pb-5 mt-0 mt-lg-0"
>
<div
class=
"container"
>
<div
class=
"form-inline"
>
<input
class=
"form-control col-sm-1 col-md-3 my-3"
type=
"search"
id=
"search-text"
oninput=
"search()"
placeholder=
"搜索"
>
</div>
<div
class=
"row"
id=
"machine-list"
>
<div
id=
"base-cell"
class=
"col-sm-12 col-md-3"
style=
"display:none"
>
...
...
@@ -50,6 +53,9 @@
</div>
</div>
</div>
<div>
<a
id=
"loadmore"
href=
"#"
onclick=
"loadmore()"
>
加载更多
</a>
</div>
<div
style=
"display: none;"
>
<img
src=
"cart.gif"
>
</div>
...
...
index.js
浏览文件 @
32bce4e0
...
...
@@ -13,16 +13,20 @@ function getUrlVars() {
function
processJson
(
data
)
{
machineList
=
data
;
machine
List
=
splitArrayByTime
(
machineList
);
reordered
List
=
splitArrayByTime
(
machineList
);
var
i
,
j
,
temparray
,
chunk
=
32
;
for
(
i
=
0
,
j
=
machine
List
.
length
;
i
<
j
;
i
+=
chunk
)
{
temparray
=
machine
List
.
slice
(
i
,
i
+
chunk
);
for
(
i
=
0
,
j
=
reordered
List
.
length
;
i
<
j
;
i
+=
chunk
)
{
temparray
=
reordered
List
.
slice
(
i
,
i
+
chunk
);
pages
.
push
(
temparray
);
}
showMachines
(
pages
[
loadedPage
]);
}
function
loadmore
()
{
showMachines
(
pages
[
loadedPage
]);
}
function
showMachines
(
machines
)
{
var
base
=
$
(
"
#base-cell
"
);
var
machineListContainer
=
$
(
"
#machine-list
"
);
...
...
@@ -44,11 +48,37 @@ function showMachines(machines) {
clone
.
show
();
clone
.
attr
(
"
id
"
,
machine
.
id
);
clone
.
find
(
"
a
"
).
attr
(
"
href
"
,
playerlink
);
clone
.
find
(
"
figcaption
"
).
text
(
title
)
clone
.
find
(
"
.figure-img
"
).
attr
(
"
src
"
,
imageLink
)
clone
.
find
(
"
figcaption
"
).
text
(
title
);
clone
.
find
(
"
.figure-img
"
).
attr
(
"
src
"
,
imageLink
);
clone
.
addClass
(
"
show-data
"
);
machineListContainer
.
append
(
clone
);
}
loadedPage
++
;
if
(
loadedPage
>=
pages
.
length
)
{
$
(
"
#loadmore
"
).
hide
();
}
}
function
search
()
{
var
keyword
=
$
(
"
#search-text
"
).
val
();
if
(
!
keyword
||
keyword
.
length
==
0
)
{
$
(
"
.show-data
"
).
remove
();
loadedPage
=
0
;
processJson
(
machineList
);
return
;
}
var
searchResult
=
[];
for
(
i
=
0
;
i
<
machineList
.
length
;
i
++
)
{
var
text
=
machineList
[
i
].
name
+
machineList
[
i
].
vendor
;
if
(
text
.
includes
(
keyword
))
{
searchResult
.
push
(
machineList
[
i
]);
}
}
pages
=
[];
loadedPage
=
0
;
$
(
"
.show-data
"
).
remove
();
showMachines
(
searchResult
);
}
function
splitArrayByTime
(
someArray
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录