-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmenu.html
More file actions
67 lines (57 loc) · 2.35 KB
/
menu.html
File metadata and controls
67 lines (57 loc) · 2.35 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
<!DOCTYPE>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
</head>
<body>
<div style="margin-bottom: 10px;"><input type="text" id="searchId" style="width: 160px;" placeholder="关键字搜索.."/> </div>
<div id="containerId">
</div>
<script src="./bookdata.js"></script>
<script>
//alert()
$(function(){
var treeData = globelTreeData;
for (let index = 0; index < treeData.length; index++) {
const element = treeData[index];
if (element.id.indexOf(".pdf") > 0){
element.icon = "./images/pdfformt.png"
}
else if (element.id.indexOf(".txt") > 0){
element.icon = "./images/textfile.png"
}
}
$("#containerId").on('changed.jstree',function(e,data){
/*
* //选中节点的id
console.log(data.instance.get_selected(true)[0].id);
//选中节点的text
console.log(data.instance.get_selected(true)[0].text);
console.log(data.instance.get_node(data.selected[0]).id);
console.log(data.instance.get_node(data.selected[0]).text);
*/
var filePath = data.instance.get_node(data.selected[0]).id;
if (filePath && (filePath.indexOf(".pdf") > 0 || filePath.indexOf(".txt") > 0)){
window.open(filePath,'showFrame');
}
}).jstree({
'plugins':["search","types"],
'core' : {
'data' : treeData
} });
})
var to = false;
$("#searchId").keyup(function(){
if (to){
clearTimeout(to);
}
to = setTimeout(() => {
var v= $("#searchId").val();
$("#containerId").jstree(true).search(v);
}, (250));
})
</script>
</body>
</html>