@@ -21,7 +21,7 @@ setTimeout(function () {
21
21
22
22
// 初始化
23
23
function init ( list ) {
24
- var toc = document . createElement ( "ul " ) ;
24
+ var toc = document . createElement ( "div " ) ;
25
25
addStyle ( toc , {
26
26
"position" : "fixed" ,
27
27
"margin-right" : "20px" ,
@@ -36,9 +36,11 @@ function init(list) {
36
36
"bottom" : "20px" ,
37
37
"overflow-x" : "hidden" ,
38
38
"overflow" : "auto" ,
39
- // "background": "gainsboro ",
39
+ "background-color " : "#fafbfc " ,
40
40
"border" : "1px solid #d1d5da" ,
41
+ "cursor" :"e-resize"
41
42
} )
43
+ var toc_ul = document . createElement ( "ul" ) ;
42
44
var stack = new Array ( ) ;
43
45
44
46
@@ -75,46 +77,11 @@ function init(list) {
75
77
}
76
78
a . setAttribute ( "href" , hreftagname ) ;
77
79
// li.appendChild(a);
78
- toc . appendChild ( li ) ;
79
- toc . lastChild . appendChild ( a ) ;
80
-
81
-
82
-
83
- // var level = parseInt(header.tagName.replace('H', ''), 10);
84
- // // 通过两个where循环对栈进行调整,确保stack中标题级数与当前标题级数相同
85
- // while (stack.length < level) {
86
- // stack.push(0);
87
- // }
88
- // while (stack.length > level) {
89
- // stack.pop();
90
- // }
91
- // // debugger;
92
-
93
-
94
- // // 最小一级标题标号步进 + 1
95
- // stack[stack.length - 1]++;
96
- // // 生成标题标号( 1.1,1.2.. )
97
- // var index = stack.join(".")
98
- // // 生成标题ID
99
- // var id = "title" + index;
100
- // header.setAttribute('id', id);
101
- // var li = document.createElement("li");
102
- // addStyle(li, {
103
- // "listStyle": "none",
104
- // })
105
- // toc.appendChild(li);
106
- // var a = document.createElement("a");
107
- // addStyle(a, {
108
- // "color": "#0366d6",
109
- // "textOverflow ": "ellipsis"
110
- // })
111
- // // 为目录项设置链接
112
- // a.setAttribute("href", "#" + id)
113
- // // 目录项文本前面放置缩进空格
114
- // a.innerHTML = new Array(level * 4).join(' ') + index + new Array(2).join(' ') + header.textContent;
115
- // toc.lastChild.appendChild(a);
80
+ toc_ul . appendChild ( li ) ;
81
+ toc_ul . lastChild . appendChild ( a ) ;
116
82
117
83
}
84
+ toc . appendChild ( toc_ul ) ;
118
85
return toc ;
119
86
}
120
87
0 commit comments