Repository navigation
Expand file tree
/
Copy pathpost.html
More file actions
77 lines (59 loc) · 1.83 KB
/
Copy pathpost.html
File metadata and controls
77 lines (59 loc) · 1.83 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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
{% include head.html %}
</head>
<body>
{% include nav.html %}
<div class="container post">
<aside class="postbar"></aside>
<article>
{{content}}
</article>
</div>
{% include foot.html %}
</body>
<script type="text/javascript">
window.onload = function(){
let aside = document.querySelector('aside');
//Nodelist
let h3 = document.querySelectorAll('h3');
if(h3.length==0){aside.style.display = 'none';}
let menu = '';
h3.forEach(function(ele,i){
menu += `<a href="#${ele.innerHTML}">${ele.innerHTML}</a>`
});
aside.innerHTML = aside.innerHTML+menu;
}
if (/Mobi|Android/i.test(navigator.userAgent)){
setTimeout(function(){
document.querySelector('.postbar').style.display = 'none';
},200)
document.getElementById("top").addEventListener('click', function(){
document.querySelector('.postbar').style.display=='none' ? document.querySelector('.postbar').style.display='block' : document.querySelector('.postbar').style.display='none';
})
document.querySelector('.postbar').addEventListener('click', function(){
this.style.display='none';
})
}
// for(let a of document.querySelectorAll('.postbar a')){
// console.log(a)
// if(window.location.pathname.indexOf(a.getAttribute('href')) > -1){
// a.style.color = '#f92672';
// }
// }
// for(let a of document.querySelectorAll('.postbar a')){
// if(window.location.pathname.indexOf(a.getAttribute('href')) > -1){
// a.style.color = '#f92672';
// let h3 = document.querySelectorAll('h3');
// h3.forEach(function(ele,i){
// var span = document.createElement("a");
// span.innerHTML = ele.innerHTML;
// span.setAttribute('class','itema');
// span.href = '#'+ele.innerHTML;
// a.parentNode.appendChild(span);
// });
// }
// }
</script>
</html>