-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitem.html
More file actions
759 lines (741 loc) · 30.2 KB
/
item.html
File metadata and controls
759 lines (741 loc) · 30.2 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<style>
html, body{
height: 100%;
}
body{
margin:0px;
background-color:#eee;
font-family:sans-serif;
position: absolute;
width: 100%;
}
header{
background-color: #fff;
box-shadow: 0px 0px 10px rgba(0,0,0,0.25);
padding: 5px;
position:fixed;
top:0px;
z-index: 3;
height: 48px;
overflow: hidden;
}
#headBox{
max-width: 1110px;
margin-left:50%;
width:100%;
transform:translate(-50%, 0px);
display:flex;
transition-property: all;
transition-duration: 0.3s;
}
#headBtn{
font-size:0px;
width:38px;
height:38px;
margin:5px;
transition-property: all;
transition-duration: 0.3s;
overflow:hidden;
border-radius:50%
}
#headBtn:hover{
background-color:rgba(127,127,127,0.25);
}
#headBtn:active{
background-color:rgba(127,127,127,0.5);
}
#headText{
flex:1;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
line-height:48px;
font-size:18px;
margin-left:5px;
}
nav{
width:300px;
position:fixed;
height:100%;
display:flex;
flex-direction: column;
overflow:hidden;
background-color:#fff;
top: 0px;
font-size:16px;
left: -300px;
z-index: 4;
animation-name: navClose;
animation-duration: 0.3s;
}
#navBox{
width:300px;
flex:1;
overflow:auto;
}
#navBox button, #toTop{
font-family:sans-serif;
width:100%;
font-size: 16px;
text-align: left;
padding:15px;
background-color:#fff;
border:0px
}
#navBox .link2{
box-shadow: 0px 0px 5px rgba(0,0,0,0.25);
padding:14px 15px;
font-size: 18px;
font-weight: bolder;
}
#navBox button:hover, #toTop:hover{
background:#eee;
}
#navBox .activityIndex{
background:#ddd;
}
#toTop{
overflow: hidden;
white-space: nowrap;
box-shadow: 0px 0px 5px rgba(0,0,0,0.25);
}
main{
min-height: calc(100% - 177px);
background-color: #fff;
max-width: 1080px;
margin-left: 0px;
margin-top: 58px;
transform: translate(0px, 0px);
position: relative;
width: calc(100% - 40px);
padding: 20px;
padding-bottom: 100px;
word-break: break-word;
}
main p, main ul, main ol{
margin: 15px 0px;
font-size: 18px;
line-height: 28px;
}
main ul, main ol{
font-size: 17px;
line-height: 27px;
}
li{
margin-bottom: 10px;
}
#navBg{
position: fixed;
width:100%;
height:100%;
top:0px;
left:0px;
z-index:3;
display: none;
background-color:rgba(0,0,0,0);
transition-property: all;
transition-duration:0.3s;
}
@media only screen and (min-width: 1140px){
main{
margin-left: 50%;
transform: translate(-50%, 0px);
transition-property: all;
transition-duration: 0.3s;
}
}
@media only screen and (min-width: 1320px){
#headBox{
max-width: 1290px;
}
#headBtn{
width:0px;
}
nav{
left: calc(50% - 560px - 90px);
height: calc(100% - 58px);
top: 58px;
width: 180px;
z-index: 2;
border-right: 1px solid #ccc;
animation-name: navOpen;
animation-duration: 0.3s;
transition-property: all;
transition-duration: 0.3s;
}
#navBox{
width: 180px;
}
main{
transform: translate(calc(-50% + 90px), 0px);
}
}
main img,main video{
max-width:100%;
box-shadow:0px 0px 5px #aaa;
}
main video{
background-color: #404040;
}
.microvid::-webkit-media-controls-fullscreen-button, .microvid::-webkit-media-controls-timeline, .microvid::-webkit-media-controls-current-time-display, .microvid::-webkit-media-controls-time-remaining-display, .microvid::-webkit-media-controls-mute-button, .microvid::-webkit-media-controls-volume-slider {
display: none;
}
iframe{
width:100%;
box-shadow:0px 0px 5px #aaa;
border:0px;
}
h1,h2,h3,h4{
margin:0px;
padding-top: 20px;
margin-top: 20px;
margin-bottom: 15px;
}
h1{
margin: 0px;
padding-top: 10px;
font-weight: 300;
font-size: 36px;
}
h2{
font-size:26px;
}
h3{
font-size:22px;
}
h4{
padding-top: 0px;
font-size:18px;
}
@media screen and (max-width: 256px){
main p, main ul, main ol{
margin: 10px 0px;
font-size: 12px;
line-height: 18px;
}
h1,h2,h3,h4{
margin:0px;
padding-top: 13px;
margin-top: 13px;
margin-bottom: 10px;
}
h1{
margin: 0px;
padding-top: 7px;
font-weight: 300;
font-size:28px;
}
h2{
font-size:17px;
}
h3{
font-size:18px;
}
h4{
padding-top: 0px;
font-size:12px;
}
}
.imgTips{
display:inline-block;
position:relative;
}
.imgTips div{
position:absolute;
line-height:0px;
color:#f00;
}
pre, .CodeMirror{
height:auto;
background:#f5f5f5;
border-radius: 10px;
font-size: 16px;
line-height: 24px;
padding:10px;
font-family: consolas, monospace, sans-serif;
}
pre{
overflow:auto
}
</style>
</head>
<body>
<header style="width:calc(100% - 10px)">
<div id="headBox">
<div id="headBtn">
<svg onclick="showNav()" style="height:28px;width:28px;padding:5px;fill:rgb(102, 102, 102)" focusable="false" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"></path></svg>
</div>
<div id="headText">BugTea 个人页面</div>
</div>
</header>
<nav style="transition-duration:0.3s;">
<div id="navBox"></div>
<button id="toTop" onclick="autoScroll(0);hideNav()">↑返回顶部</button>
<!--<img src="../java8/2disk.png"/>-->
</nav>
<main>
<p style="text-align:center">页面正在加载,请稍候...</p>
</main>
<a id="linka" target="_blank"></a>
<div id="navBg" onclick="hideNav()"></div>
<div style="display:none" id="navCloseAni">
@keyframes navClose{
0%, 100%{
height: calc(100% - 58px);
top:58px;
z-index: 2;
border-right:1px solid #aaa;
}
0%{
width:180px;
left: calc(50% - 560px - 90px);
}
100%{
width:0px;
left: calc(50% - 560px);
}
}
</div>
<div style="display:none" id="navOpenAni">
@keyframes navOpen{
0%, 100%{
height: calc(100% - 58px);
top:58px;
z-index: 2;
border-right:1px solid #aaa;
}
0%{
width:0px;
left: calc(50% - 560px);
}
100%{
width:180px;
left: calc(50% - 560px - 90px);
}
}
</div>
<script type="text/javascript">
//errorVisible = false;
//setTimeout(function(){errorVisible = true},1500)
mainBox = document.body.children[2];
headerTextBox = document.getElementById("headText");
//headerBreakIndex = [];
//headerEllipsisText = "...";
//加载外置脚本
function loadJS(path){
var Script = document.createElement("script");
Script.type = "text/javascript";
Script.src = path;
document.body.appendChild(Script);
return Script;
}
//获取滚动位置(浏览器兼容性)
function winScrTop(){
return document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset;
}
//启动页面滚动动画
autoScrollId = 0;
function autoScroll(scrollTo){
if(winScrTop() != scrollTo){
autoScrollId ++;
autoScrDist = 1;
autoScrTop = winScrTop();
//console.log(String((document.documentElement.scrollTop - scrollTo) / 25).split(".")[0])
if(scrollTo + document.body.clientHeight < mainBox.clientHeight) autoScrTgt = scrollTo;
else autoScrTgt = mainBox.clientHeight - document.body.clientHeight
autoScrollProcess(autoScrollId);
}
}
//页面滚动动画程序
function autoScrollProcess(id){
if(id == autoScrollId) {
//向上滑动或向下
if(autoScrTgt < autoScrTop) autoScrTop = autoScrTop - autoScrDist;
else autoScrTop = autoScrTop + autoScrDist;
window.scroll(0,autoScrTop);
//线性平滑加减速
var afterScrollTop = winScrTop();
if(autoScrDist > 1 & autoScrTop < autoScrTgt & autoScrTgt - autoScrTop <= autoScrDist * (1 + autoScrDist) / 2) autoScrDist -= 2;
else if(autoScrDist > 1 & autoScrTop > autoScrTgt & autoScrTop - autoScrTgt <= autoScrDist * (1 + autoScrDist) / 2) autoScrDist -= 2;
else autoScrDist += 2;
//console.log(autoScrDist + " " + autoScrTop + " " + autoScrTgt)
//一帧滑动后执行下一帧
if(/*上滑*/autoScrTop - autoScrDist > autoScrTgt | /*下滑*/autoScrTop + autoScrDist < autoScrTgt) {
setTimeout(function(){autoScrollProcess(id)}, 1);
} else window.scroll(0,autoScrTgt);
}
}
//窗口大小调整
eleMaxWidth = 1080/*主元素*/ + 10 * 2/*主元素内边距*/ + 10 * 2/*主元素外边距*/ + 180/*宽屏导航栏元素*/ + 20/*滚动条(不同浏览器不一样,就当它宽20吧)*/;
nowWidth = minWidth = maxWidth = window.innerWidth;
window.onresize = function(){
//宽度增加时改变导航栏形态
if(window.innerWidth >= 1320) hideNav();
nowWidth = document.body.clientWidth;
//导航栏形态切换动画
//宽度从窄增加时加载动画
if(minWidth){
if(minWidth > nowWidth) minWidth = nowWidth;
if(minWidth < 1320 & nowWidth > minWidth){
var style = document.createElement("style");
style.innerHTML = document.getElementById("navOpenAni").innerHTML;
document.getElementById("navOpenAni").remove();
document.body.appendChild(style);
minWidth = false;
}
}
//宽度从宽减少时加载动画
if(maxWidth){
if(maxWidth < nowWidth) maxWidth = nowWidth;
if(maxWidth >= 1320 & nowWidth <= maxWidth){
var style = document.createElement("style");
style.innerHTML = document.getElementById("navCloseAni").innerHTML;
document.getElementById("navCloseAni").remove();
document.body.appendChild(style);
maxWidth = false;
}
}
//headerEllipsis("none");
}
//索引按钮点击后
function scrollTo(){
autoScroll(Number(this.getAttribute("top")));
hideNav();
}
//加载索引
var lastHeight = 0;
var winlastHeight = document.body.clientHeight;
var winlastWidth = document.body.clientWidth;
var pageLoaded = false;
var scrolled = false;
var scrollReseted = false;
var subTitleIndex = [];
var imgTipDftSize = [];
function loadIndex(){
//检测窗口尺寸
if(winlastHeight != document.body.clientHeight | winlastWidth != document.body.clientWidth){
winlastHeight = document.body.clientHeight;
winlastWidth = document.body.clientWidth;
var sizeChanged = true;
} else var sizeChanged = false;
//检测页面高度
if(mainBox.clientHeight != lastHeight){
if(!sizeChanged){
if(lastFile == proFile) window.scroll(0,lastScroll);
else if(!scrollReseted) {
window.scroll(0,0);
scrollReseted = true;
}
document.cookie = "lastScroll=" + winScrTop();
}
//调整iframe嵌套缩放比为16:10
var iFrameList = mainBox.getElementsByTagName("iframe");
for (i = 0; i < iFrameList.length; i ++){
iFrameList[i].style.height = (iFrameList[i].clientWidth / 16 * 10) + "px"
}
//按照缩放尺寸调整图片标注字体大小
var imgTipsList = mainBox.getElementsByClassName("imgTips");
for (j = 0; j < imgTipsList.length; j ++){
imgTipsList[j].children[0].style.maxWidth = "none";
var tipTxtList = imgTipsList[j].getElementsByTagName("div");
if(pageLoaded) imgTipDftSize[j] = [];
var imgTipDftPpt = [];
for (k = 0; k < tipTxtList.length; k ++){
if(pageLoaded) imgTipDftSize[j][k] = Number(window.getComputedStyle(tipTxtList[k]).fontSize.split("px")[0]);
imgTipDftPpt[k] = imgTipDftSize[j][k] / imgTipsList[j].clientHeight;
}
imgTipsList[j].children[0].style.maxWidth = "100%";
for (k = 0; k < tipTxtList.length; k ++){
tipTxtList[k].style.fontSize = (imgTipsList[j].clientHeight * imgTipDftPpt[k]) + "px";
}
}
pageLoaded = false;
var eleList = mainBox.children;
var n = 0;
for (i = 0; i < eleList.length; i ++){
if (eleList[i].tagName == "H3" || eleList[i].tagName == "H2"){
//当索引按钮不存在时添加一个
subTitleIndex[n] = eleList[i];
if (!document.getElementById("navBox").children[n]){
var linkBtn = document.createElement("button");
if (eleList[i].tagName == "H2") linkBtn.className = "link2";
linkBtn.innerHTML = eleList[i].innerHTML;
linkBtn.onclick = scrollTo;
document.getElementById("navBox").appendChild(linkBtn);
}
//设置索引按钮的目标位置
document.getElementById("navBox").children[n].setAttribute("top", eleList[i].offsetTop);
n ++;
}
}
lastHeight = mainBox.clientHeight;
}
setTimeout(loadIndex,100);
}
//窄宽度导航栏形态
//展开
function showNav(){
if(window.innerWidth < 1320) {
document.body.children[1].style.transitionDuration = "0.3s";
document.body.children[1].style.left = "0px";
document.getElementById("navBg").style.display = "block";
setTimeout("document.getElementById('navBg').style.backgroundColor = 'rgba(0,0,0,0.4)'", 0);
}
}
//收起
function hideNav(){
document.body.children[1].style.transitionDuration = "0.3s";
document.body.children[1].style.left = "";
document.getElementById("navBg").style.backgroundColor = "";
setTimeout("document.getElementById('navBg').style.display = ''", 300);
}
//加载URL参数
lastFile = proFile = lastScroll = loadInfo = false;
var loadParam = window.location.href.split("?");
if (loadParam[1]) {
loadParam = loadParam[1].split("&");
for (i = 0; i < loadParam.length; i ++) {
var par = loadParam[i].split("=");
if(par[0] == "proFile") proFile = par[1];
if(par[0] == "article") proFile = par[1];
}
}
var cookieParam = document.cookie.split("; ");
for (i = 0; i < cookieParam.length; i ++) {
var par = cookieParam[i].split("=");
if(par[0] == "lastScroll") lastScroll = par[1];
if(par[0] == "lastFile") lastFile = par[1];
}
document.cookie = "Max-Age=259200"
document.cookie = "lastFile=" + proFile;
//文件加载后
var loadMD = function(){
var xmlhttp;
if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
else loadInfo = "<h1>错误</h1><p>当前浏览器不被支持。</p>";
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if(xmlhttp.status == 200) {
loadInfo = marked.parse(xmlhttp.responseText);
}
else if(xmlhttp.status == 404) loadInfo = "<h1>错误</h1><p>未能在网站上找到此文章。(404)</p>";
else loadInfo = "<h1>错误</h1><p>未知原因。(" + xmlhttp.status + ")</p>";
loadContent();
}
}
xmlhttp.open("GET",proFile + "?" + Number.parseInt(Math.random() * 1000),true);
xmlhttp.send();
}
//加载内容
var loadContent = function(){
if(loadInfo){
mainBox.innerHTML = loadInfo;
//将./开头路径的图片设置为文章脚本的所在路径
var imgList = mainBox.getElementsByTagName("img");
for (i = 0; i < imgList.length; i ++){
if (imgList[i].getAttribute("src").substring(0, 2) == "./") {
imgList[i].src = srcFnt + imgList[i].getAttribute("src").substring(2);
}
imgList[i].onclick = function(){
document.getElementById("linka").href = this.src;
document.getElementById("linka").click();
}
}
var vidList = mainBox.getElementsByTagName("video");
for (i = 0; i < vidList.length; i ++){
var current = vidList[i];
current.children[0].src = srcFnt + current.children[0].getAttribute("src").substring(2);
current.onclick = function(){
if (this.className == "microvid") {
if (this.paused) {
this.controls = true;
this.onplay = function(){ this.controls = false; }
}
else {
document.getElementById("linka").href = this.children[0].src;
document.getElementById("linka").click();
}
}
}
if (!current.controls) {
current.className = "microvid";
current.controls = true;
current.playsinline = true;
current.controlsList = "nodownload nofullscreen noremoteplayback";
current.onplay = function(){ this.controls = false; }
}
}
//将内容为showLink的链接按钮内容改为其链接,并将./开头路径的链接设置为文章脚本的所在路径
var linkList = mainBox.getElementsByTagName("a");
for (i = 0; i < linkList.length; i ++){
if (linkList[i].innerHTML == "showLink"){
linkList[i].innerHTML = linkList[i].href;
linkList[i].target = "_blank";
}
if (linkList[i].getAttribute("href").substring(0, 8) == "itemDir/") {
linkList[i].href = "item.html?proFile=" + srcFnt + linkList[i].getAttribute("href").substring(8);
}
if (linkList[i].getAttribute("href").substring(0, 2) == "./") {
linkList[i].href = "item.html?proFile=" + srcFnt + linkList[i].getAttribute("href").substring(2);
}
}
//将textarea转换为CodeMirror
var textAreaList = mainBox.getElementsByTagName("textarea");
if (textAreaList.length != 0) {
var txtAreaLst = [];
for (i = 0; i < textAreaList.length; i ++){
txtAreaLst[i] = textAreaList[i];
}
var CodeMirCSS = document.createElement("link");
CodeMirCSS.rel = "stylesheet";
CodeMirCSS.href = "./resources/libs/codemirror/codemirror.css";
document.head.insertBefore(CodeMirCSS,document.head.children[2]);
var CodeMirLDR = loadJS("./resources/libs/codemirror/codemirror.js");
CodeMirLDR.onload = function(){
for (i = 0; i < txtAreaLst.length; i ++){
if(txtAreaLst[i].innerHTML != "") txtAreaLst[i].value = txtAreaLst[i].innerHTML;
var myCodeMirror = CodeMirror.fromTextArea(txtAreaLst[i], {
lineNumbers: false, // 显示行号
readOnly: true
})
}
}
}
//设置标题
pageLoaded = true;
headerText = mainBox.getElementsByTagName("h1")[0].innerHTML;
document.title = headerText;
//获取省略号启用条件(已弃用)
/*
//宽度根据文本宽度自适应
document.body.children[0].style.width = "auto";
//获取省略号宽度
headerTextBox.innerHTML = headerEllipsisText
ellipsisWidth = headerTextBox.clientWidth
headerTextBox.innerHTML = ""
//每增加一个字符获取一次文本加上省略号的宽度
for (i = 0; i < headerText.length; i ++){
headerTextBox.innerHTML += headerText[i];
headerBreakIndex[i] = headerTextBox.clientWidth + ellipsisWidth
}
//恢复原宽度
document.body.children[0].style.width = "calc(100% - 10px)"
//检测并在条件满足时启用省略号
headerEllipsis("none");
*/
headerTextBox.innerHTML = headerText;
//启动索引菜单
loadIndex();
//页面集成JS代码
if (mainBox.children[mainBox.children.length - 1].innerHTML[0] == "/") {
eval(mainBox.children[mainBox.children.length - 1].innerHTML.substring(1));
mainBox.children[mainBox.children.length - 1].remove();
}
} else {
mainBox.innerHTML = "<h1>错误</h1><p>文章源文件无效。</p>";
//if(mainBox.innerHTML != invalidDataError & errorVisible) mainBox.innerHTML = invalidDataError;
//setTimeout(function(){loadContent()},0);
}
}
if(proFile){
//获取文章脚本的所在路径
var srcFnt = "";
var targetFormat = proFile.substring(proFile.length - 3,proFile.length)
if(targetFormat != ".js" & targetFormat != ".md" & proFile[proFile.length - 1] != "/") {
proFile += "/";
targetFormat = ".js";
}
var srcList = proFile.split("/");
for (i = 0; i < srcList.length - 1; i ++){
srcFnt += srcList[i] + "/";
}
//invalidDataError = "<h1>错误</h1><p>文章源文件无效。</p>";
if(targetFormat != ".md") {
//js格式
var Source = loadJS(proFile + "?" + Number.parseInt(Math.random() * 1000));
Source.onload = loadContent;
Source.onerror = function(){
mainBox.innerHTML = "<h1>错误</h1><p>服务器异常或文章已被删除。</p>";
}
}
else {
//md格式
var depend = loadJS("https://cdn.jsdelivr.net/npm/marked/marked.min.js");
var markedIndex = 0;
depend.onload = loadMD;
depend.onerror = function(){
var depend = loadJS("https://cdn.bootcdn.net/ajax/libs/marked/9.0.0/marked.min.js");
depend.onload = loadMD;
depend.onerror = function(){
mainBox.innerHTML = "<h1>错误</h1><p>页面组件加载异常,请检查网络。</p>";
}
markedIndex ++
}
}
} else mainBox.innerHTML = "<h1>错误</h1><p>请检查链接是否正确。</p>";
//检测并在条件满足时启用省略号(已弃用)
/*function headerEllipsis(cnt){
if(cnt == "none") {
cnt = headerBreakIndex.length - 1;
}
//console.log(document.getElementById("headText").clientWidth +""+ headerBreakIndex[cnt])
//逐个字符检测文本宽度
if(headerTextBox.clientWidth < headerBreakIndex[cnt]){
if(cnt != 0){
cnt --
headerEllipsis(cnt);
}
//页面宽度小于文本宽度,启用省略号
} else if(cnt != headerBreakIndex.length - 1){
if(headerTextBox.innerHTML != headerText.substring(0,cnt) + headerEllipsisText) headerTextBox.innerHTML = headerText.substring(0,cnt) + headerEllipsisText;
//页面宽度大于文本宽度
} else {
if(headerTextBox.innerHTML != headerText) headerTextBox.innerHTML = headerText
}
}*/
//指示滚动位置所处的板块对应的导航栏项
var listin = false;
window.onscroll = function(){
document.cookie = "lastScroll=" + winScrTop();
for(i = subTitleIndex.length - 1; i > -1; i --){
if(winScrTop() >= subTitleIndex[i].offsetTop && !listin){
document.getElementById("navBox").children[i].classList.add("activityIndex");
listin = true;
} else document.getElementById("navBox").children[i].classList.remove("activityIndex");
}
listin = false;
}
//触屏导航栏展开时左划隐藏
document.body.children[1].ontouchstart = function(e){
var moveCnt = 0;
var startX = e.touches[0].clientX;
var startY = e.touches[0].clientY;
var conX,conY;
this.style.transitionDuration = "0s";
this.ontouchmove = function(e){
var nowX = e.touches[0].clientX;
var nowY = e.touches[0].clientY;
//获取触点移动后距离
if(moveCnt < 5) {
conY = nowY - startY;
if(conY < 0) conY = startY - nowY;
conX = nowX - startX;
if(conX < 0) conX = startX - nowX;
}
moveCnt ++;
var setX = -(startX - nowX);
if(conX > conY & setX <= 0) this.style.left = setX + "px";
}
this.ontouchend = function(){
if(this.offsetLeft <= -150) hideNav();
else showNav();
}
}
</script>
</body>
</html>