欢迎来到RankFan的Blogs

扩大
缩小

Cnblogs 主题2

 

  1 #header{display:none;} /* 将默认的导航头屏蔽掉,这样才能把自己的导航栏加上去 */
  2 
  3 
  4 /* 定制自己导航栏的样式 */
  5 #shwtop ul {
  6     margin: 0px;
  7     padding: 0;
  8     list-style-type: none; /*去除li前的标注*/
  9     background-color: #333;
 10     overflow: hidden; /*隐藏溢出的部分,保持一行*/
 11 }
 12 #shwtop li {
 13     float: left; /*左浮动*/
 14 }
 15 #shwtop li a, .dropbtn {
 16     display: inline-block; /*设置成块*/
 17     color: white;
 18     text-align: center;
 19     text-decoration: none;
 20     padding: 14px 16px;
 21 }
 22 /*鼠标移上去,改变背景颜色*/
 23 #shwtop li a:hover, .dropdown:hover .dropbtn { 
 24     /* 当然颜色你可以自己改成自己喜欢的,我还是挺喜欢蓝色的 */
 25     background-color: blue;
 26 }
 27 #shwtop .dropdown {
 28     /*
 29     display:inline-block将对象呈递为内联对象,
 30     但是对象的内容作为块对象呈递。
 31     旁边的内联对象会被呈递在同一行内,允许空格。
 32     */
 33     display: inline-block;
 34 }
 35 #shwtop .dropdown-content {
 36     display: none;
 37     position: absolute;
 38     background-color: #f9f9f9;
 39     min-width: 150px;
 40     box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
 41 }
 42 #shwtop .dropdown-content a {
 43     display: block;
 44     color: black;
 45     padding: 8px 10px;
 46     text-decoration:none;
 47 }
 48 #shwtop .dropdown-content a:hover {
 49     background-color: #a1a1a1;
 50 }
 51 #shwtop .dropdown:hover .dropdown-content{
 52     display: block;
 53 }
 54 
 55 /* 定制生成博客目录的CSS样式 */
 56 #uprightsideBar{
 57     font-size:15px;
 58     font-family:Arial, Helvetica, sans-serif;
 59     text-align:left;
 60     position:fixed;
 61     /*
 62     将div的位置固定到距离top:150px,right:0px的位置,
 63     这样div就会处在最右边的位置,距离顶部150px,
 64     当然这两个值你可以自己改。
 65     */
 66     top:150px;
 67     right:10px;
 68     width: auto;
 69     height: auto; 
 70 }
 71 #sideBarTab{
 72     float:left;
 73     width:25px; 
 74     box-shadow: 0 0 8px #877788;
 75     border:1px solid #00DDC00;
 76     border-right:none;
 77     text-align:center;
 78     background:rgb(0, 220, 0);
 79 }
 80 #sideBarContents{
 81     float:left;
 82     overflow:auto; 
 83     overflow-x:hidden;!important;
 84     width:200px;
 85     min-height:101px;
 86     max-height:460px;
 87     border:1px solid #e5e5e5;
 88     border-right:none; 
 89     background:#ffffff;
 90 }
 91 #sideBarContents dl{
 92     margin:0;
 93     padding:0;
 94 }
 95 #sideBarContents dt{
 96     margin-top:5px;
 97     margin-left:5px;
 98 }
 99 #sideBarContents dd, dt {
100     cursor: pointer;
101 }
102 #sideBarContents dd:hover, dt:hover {
103     color:#A7995A;
104 }
105 #sideBarContents dd{
106     margin-left:20px;
107 }
108 
109 /* 快速返回顶部 */
110 /* 定制返回顶部按键 */
111 #toTop {
112     background: url(http://images.cnblogs.com/cnblogs_com/shwee/1218109/o_toTop.bmp) no-repeat 0px top;
113     width: 57px;
114     height: 57px;
115     overflow: hidden;
116     position: fixed;
117     right: 20px;
118     bottom: 20px;
119     cursor: pointer;
120 }
121 
122 /* 定制页面扩大按键 */
123 #divExpandViewArea{
124     position: fixed;
125     color: white;
126     padding: 10px 10px;
127     left: 0px;
128     top: 400px;
129     cursor: pointer;
130     opacity: 0.9;
131     background-color: #68228B;
132 }
133 /* 定制页面缩小按键 */
134 #divCollapseViewArea{
135     position: fixed;
136     color: white;
137     padding: 10px 10px;
138     left: 0px;
139     top: 445px;
140     cursor: pointer;
141     opacity: 0.9;
142     background-color: #68228B;
143 }
144 
145 #main_container{
146     margin-left: 40px;
147     margin-right:40px;
148 }
149 
150 /* 定制左侧随笔分类上下项之间的间距,左侧随笔分类显示有多少项,你就在后面增加多少项 */
151 #CatList_LinkList_0_Link_0{
152 }
153 #CatList_LinkList_0_Link_1{
154     margin-top:10px;
155 }
156 #CatList_LinkList_0_Link_2{
157     margin-top:10px;
158 }
159 #CatList_LinkList_0_Link_3{
160     margin-top:10px;
161 }
162 #CatList_LinkList_0_Link_4{
163     margin-top:10px;
164 }
165 #CatList_LinkList_0_Link_5{
166     margin-top:10px;
167 }
168 #CatList_LinkList_0_Link_6{
169     margin-top:10px;
170 }
171 #CatList_LinkList_0_Link_7{
172     margin-top:10px;
173 }
174 #CatList_LinkList_0_Link_8{
175     margin-top:10px;
176 }
177 
178 /* 字体 */
179 /*文章内容详情页面的标h2、h3的样式*/
180 #cnblogs_post_body h2 {
181     background: #2B6695;
182     border-radius: 6px 6px 6px 6px;
183     box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5);
184     color: #FFFFFF;
185     font-family: "微软雅黑" , "宋体" , "黑体" ,Arial;
186     font-size: 17px;
187     font-weight: bold;
188     height: 25px;
189     line-height: 25px;
190     margin: 18px 0 !important;
191     padding: 8px 0 5px 5px;
192     text-shadow: 2px 2px 3px #222222;
193 }
194 #cnblogs_post_body h3 {
195     background: #2B6600;
196     border-radius: 6px 6px 6px 6px;
197     box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5);
198     color: #eb3223;
199     font-family: "微软雅黑" , "宋体" , "黑体" ,Arial;
200     font-size: 13px;
201     font-weight: bold;
202     height: 24px;
203     line-height: 23px;
204     margin: 12px 0 !important;
205     padding: 5px 0 5px 10px;
206     text-shadow: 2px 2px 3px #222222;
207 }
208 
209 /* 定制博客背景图片,url里面是你的图片位置信息 */
210 body { 
211      background-color: #efefef;
212      background-image:url(https://images.cnblogs.com/cnblogs_com/blogs/677960/galleries/2037550/o_210928085530hh.png); 
213      background-repeat: no-repeat; 
214      background-attachment: fixed; 
215      background-position: center 0; 
216      background-size: cover; 
217     padding-top:0px;
218   }
219 
220 /*添加复制按钮*/
221 .cnblogs-markdown pre {
222   position: relative;
223 }
224 .cnblogs-markdown pre > span {
225   position: absolute;
226   top: 0;
227   right: 0;
228   border-radius: 2px;
229   padding: 0 10px;
230   font-size: 12px;
231   background: rgba(0, 0, 0, 0.4);
232   color: #fff;
233   cursor: pointer;
234   display:none;
235 }
236 .cnblogs-markdown pre:hover > span {
237   display:block;
238 }
239 .cnblogs-markdown pre > .copyed {
240   background: #67c23a;
241 }
页面CSS

 

 1 <!-- 添加公告栏图片并指向首页链接 -->
 2 <div align="center">
 3     <a href="http://www.cnblogs.com/RankFan/">
 4     <img src="https://pic.cnblogs.com/avatar/2355125/20210411202630.png"></a> 
 5 </div>
 6 <center>
 7     <p class="gonggao"><a style="color: blue;font-weight: bold;" href="https://www.cnblogs.com/RankFan/p/Bayesian_VAR.html">我的博客目录结构</a></p>
 8     <p class="wenzi">花有重开日,人无再少年</p>
 9 
10     <p>-------------------------------</p>
11 </center>
12 
13 <!-- 为页面添加爱心特效 -->
14 <script type="text/javascript">
15 
16 (function(window,document,undefined){
17     var hearts = [];
18     
19     window.requestAnimationFrame = (function(){
20         return window.requestAnimationFrame || 
21         window.webkitRequestAnimationFrame ||
22         window.mozRequestAnimationFrame ||
23          window.oRequestAnimationFrame ||
24          window.msRequestAnimationFrame ||
25          function (callback){
26              setTimeout(callback,1000/60);
27          }
28     })();
29     
30     init();
31 
32     function init(){
33         css(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: absolute;}.heart:after{top: -5px;}.heart:before{left: -5px;}");
34         attachEvent();
35         gameloop();
36     }
37 
38     function gameloop(){
39         for(var i=0;i<hearts.length;i++){
40             if(hearts[i].alpha <=0){
41                 document.body.removeChild(hearts[i].el);
42                 hearts.splice(i,1);
43                 continue;
44              }
45 
46              hearts[i].y--;
47              hearts[i].scale += 0.004;
48              hearts[i].alpha -= 0.013;
49              hearts[i].el.style.cssText = "left:"+hearts[i].x+"px;top:"+hearts[i].y+"px;opacity:"+hearts[i].alpha+";transform:scale("+hearts[i].scale+","+hearts[i].scale+") rotate(45deg);background:"+hearts[i].color;
50         }
51 
52         requestAnimationFrame(gameloop);
53     }
54 
55     function attachEvent(){
56         var old = typeof window.onclick==="function" && window.onclick;
57         window.onclick = function(event){
58             old && old();
59             createHeart(event);
60         }
61     }
62 
63     function createHeart(event){
64         var d = document.createElement("div");
65         d.className = "heart";
66         hearts.push({
67             el : d,
68             x : event.clientX - 5,
69             y : event.clientY - 5,
70             scale : 1,
71             alpha : 1,
72             color : randomColor()
73         });
74 
75         document.body.appendChild(d);
76     }
77 
78     function css(css){
79         var style = document.createElement("style");
80         style.type="text/css";
81         try{
82             style.appendChild(document.createTextNode(css));
83         }
84         catch(ex){
85             style.styleSheet.cssText = css;
86         }
87 
88         document.getElementsByTagName('head')[0].appendChild(style);
89     }
90 
91     function randomColor(){
92         return "rgb("+(~~(Math.random()*255))+","+(~~(Math.random()*255))+","+(~~(Math.random()*255))+")";
93     }
94     
95 })(window,document);
96 </script>
侧边栏

 

<!-- #034fd8 腾讯蓝 -->
<p style="text-align: margin-left;font-size:35px;margin-bottom:10px;margin-top:20px;opacity: 0.8;color:white">
    <font>欢迎来到RankFan的Blogs</font></p>


<!-- 博客页面脚添加Github链接或其他链接 -->
<!-- 页面左上角 -->
<a href="https://RankXiaoLong.github.io/" title="我的站点" target="_Blank" class="github-corner" aria-label="View source on Github"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#64CEAA; color:#fff; position: absolute; top: 0; border: 0; left: 0; transform: scale(-1, 1);" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
<!-- 页面右上角 -->
<a href="https://github.com/RankXiaoLong" title="我的github地址" target="_Blank" class="github-corner" aria-label="View source on Github">
    <svg width="80" height="80" viewBox="0 0 250 250" style="fill:#FD6C6C; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>

<!-- 创建新的导航栏,内容可更改为你自己的-->
<div id="shwtop" >
    <ul style="margin-left:40px;margin-right: 40px;" class="test11" >
        <div class="dropdown">
            <a href="https://www.cnblogs.com/" target="_Blank" class="dropbtn"><span>博客园首页</span></a>
            <div class="dropdown-content">

            </div>
        </div>

        <div class="dropdown">
            <a href="http://www.cnblogs.com/RankFan/" target="_Blank" class="dropbtn"><span>我的首页</span></a>
            <div class="dropdown-content">

            </div>
        </div>

        <div class="dropdown">
            <a href="https://www.cnblogs.com/RankFan/category/1963292.html" target="_Blank" class="dropbtn">Python杂记</a>
            <div class="dropdown-content">

            </div>
        </div>


        <div class="dropdown">
            <a href="https://www.cnblogs.com/RankFan/category/1967093.html" target="_Blank" class="dropbtn">Python可视化</a>
            <div class="dropdown-content">

            </div>
        </div>


        <div class="dropdown">
            <a href="https://www.cnblogs.com/RankFan/category/1966284.html" target="_Blank" class="dropbtn">机器学习</a>
            <div class="dropdown-content">

            </div>
        </div>


        <div class="dropdown">
            <a href="https://www.cnblogs.com/RankFan/category/1959946.html" target="_Blank" class="dropbtn">状态空间模型</a>
            <div class="dropdown-content">

            </div>
        </div>


        <div class="dropdown">
            <a href="https://www.cnblogs.com/RankFan/category/1997717.html" target="_Blank" class="dropbtn">LaTeX 记事本</a>
            <div class="dropdown-content">

            </div>
        </div>


        <div class="dropdown">
            <a href="https://www.cnblogs.com/RankFan/category/1996733.html"  target="_Blank" class="dropbtn">MIDAS</a>
            <div class="dropdown-content">

            </div>
        </div>


        <div class="dropdown">
            <a href="https://www.cnblogs.com/RankFan/category/2037003.html" class="dropbtn">网站搭建</a>
            <div class="dropdown-content">

            </div>
        </div>


        <div class="dropdown">
            <a target="_Blank" class="dropbtn">学习资源</a>
            <div class="dropdown-content">
                <a class="menu" href="https://docs.djangoproject.com/en/2.0/"  target="_Blank">1.Django2.0官网</a>
                <a class="menu" href="http://docs.jinkan.org/docs/flask/"  target="_Blank">2.Flask文档</a>
                <a class="menu" href="http://www.runoob.com/bootstrap/bootstrap-tutorial.html"  target="_Blank">3.Bootstrap教程</a>
                <a class="menu" href="http://www.django-rest-framework.org/"  target="_Blank">4.REST framework官网</a>
            </div>
        </div>

        <div class="dropdown">
            <a href="https://mp.weixin.qq.com/s/gOer3XV_Q-Np2PWoRihP3g" target="_Blank" class="dropbtn">公众号</a>
        </div>

        <div class="dropdown">
            <a href="https://i.cnblogs.com/settings" target="_Blank" class="dropbtn">Blogs设置</a>
        </div>


    </ul>
</div>


<!-- 快速返回顶部 -->
<!-- 指定返回顶部位置#shwtop -->
<a href="#shwtop"><div id="toTop" style="zoom:0;"></div></a>

<!--添加页面放大和缩小功能按键 -->
<div id="divExpandViewArea" onclick="$('#main_container').css({'margin-left':'-154px'});$('#leftmenu').css({'display':'none'});">扩大</div>
<div id="divCollapseViewArea" onclick="$('#main_container').css({'margin-left':'40px', 'margin-right':'40px'});$('#leftmenu').css({'display':'block'});">缩小</div>
页首

 

  1 <!-- code 复制设置 -->
  2 <script src="https://files.cnblogs.com/files/fenggwsx/clipboard.min.js"></script>
  3 <script src="https://files.cnblogs.com/files/fenggwsx/cp.js"></script>
  4 
  5 async function SyncICOLoader() {
  6     const flag = `ico`
  7     const ico = window.ico ?? false
  8     if (Done(flag) || !ico) return
  9     await Sync(flag, async _ => {
 10         document.querySelector(`#favicon`).href = ico
 11     })
 12     console.log({ico: ico})
 13 }
 14 
 15 
 16 <script>
 17     window.ico = `https://pic.cnblogs.com/avatar/2355125/20210411202630.png` /*可定制ico*/
 18 </script>
 19 
 20 
 21 <!-- 生成博客目录的JS代码,两级目录 -->
 22 <script type="text/javascript">
 23 /*  
 24     这段代码按H2、H3格式生成两级菜单
 25     写博客按H2、H3格式写,不然生成不了
 26     Markdown写作按##、###两级目录写
 27     当然你也可以改写代码成三级菜单
 28     参考:孤傲苍狼    zhang_derek
 29     洪卫    2018-5-18 
 30 */
 31 var BlogDirectory = {
 32     /* 获取元素位置,距浏览器左边界的距离(left)和距浏览器上边界的距离(top)*/
 33     getElementPosition:function (ele) {
 34         var topPosition = 0;
 35         var leftPosition = 0;
 36         while (ele){
 37             topPosition += ele.offsetTop;
 38             leftPosition += ele.offsetLeft;
 39             ele = ele.offsetParent;
 40         }
 41         return {top:topPosition, left:leftPosition};
 42     },
 43     /*获取滚动条当前位置 */
 44     getScrollBarPosition:function () {
 45         var scrollBarPosition = document.body.scrollTop || document.documentElement.scrollTop;
 46         return  scrollBarPosition;
 47     },
 48     /* 移动滚动条,finalPos 为目的位置,internal 为移动速度 */
 49     moveScrollBar:function(finalpos, interval) {
 50         //若不支持此方法,则退出
 51         if(!window.scrollTo) {
 52             return false;
 53         }
 54         
 55         //窗体滚动时,禁用鼠标滚轮
 56         window.onmousewheel = function(){
 57             return false;
 58         };
 59         
 60         //清除计时
 61         if (document.body.movement) {
 62             clearTimeout(document.body.movement);
 63         }
 64         
 65         //获取滚动条当前位置
 66         var currentpos =BlogDirectory.getScrollBarPosition();
 67 
 68         var dist = 0;
 69         //到达预定位置,则解禁鼠标滚轮,并退出
 70         if (currentpos == finalpos) {
 71             window.onmousewheel = function(){
 72                 return true;
 73             }
 74             return true;
 75         }
 76         //未到达,则计算下一步所要移动的距离
 77         if (currentpos < finalpos) {
 78             dist = Math.ceil((finalpos - currentpos)/10);
 79             currentpos += dist;
 80         }
 81         if (currentpos > finalpos) {
 82             dist = Math.ceil((currentpos - finalpos)/10);
 83             currentpos -= dist;
 84         }
 85 
 86         var scrTop = BlogDirectory.getScrollBarPosition();//获取滚动条当前位置
 87         window.scrollTo(0, currentpos);//移动窗口
 88         if(BlogDirectory.getScrollBarPosition() == scrTop)//若已到底部,则解禁鼠标滚轮,并退出
 89         {
 90             window.onmousewheel = function(){
 91                 return true;
 92             }
 93             return true;
 94         }
 95 
 96         //进行下一步移动
 97         var repeat = "BlogDirectory.moveScrollBar(" + finalpos + "," + interval + ")";
 98         document.body.movement = setTimeout(repeat, interval);
 99     },
100 
101     htmlDecode:function (text){
102         var temp = document.createElement("div");
103         temp.innerHTML = text;
104         var output = temp.innerText || temp.textContent;
105         temp = null;
106         return output;
107     },
108     
109     /*
110     创建博客目录,id表示包含博文正文的 div 容器的 id,
111     mt 和 st 分别表示主标题和次级标题的标签名称(如 H2、H3,大写或小写都可以!),
112     interval 表示移动的速度
113     */
114     createBlogDirectory:function (id, mt, st, interval){
115         //获取博文正文div容器
116         var elem = document.getElementById(id);
117         if(!elem) return false;
118         //获取div中所有元素结点
119         var nodes = elem.getElementsByTagName("*");
120         //创建博客目录的div容器
121         var divSideBar = document.createElement('DIV');
122         divSideBar.className = 'uprightsideBar';
123         divSideBar.setAttribute('id', 'uprightsideBar');
124         var divSideBarTab = document.createElement('DIV');
125         divSideBarTab.setAttribute('id', 'sideBarTab');
126         divSideBar.appendChild(divSideBarTab);
127         var h2 = document.createElement('H2');
128         divSideBarTab.appendChild(h2);
129         var txt = document.createTextNode('目录导航');
130         h2.appendChild(txt);
131         var divSideBarContents = document.createElement('DIV');
132         divSideBarContents.style.display = 'none';
133         divSideBarContents.setAttribute('id', 'sideBarContents');
134         divSideBar.appendChild(divSideBarContents);
135         //创建自定义列表
136         var dlist = document.createElement("dl");
137         divSideBarContents.appendChild(dlist);
138         var num = 0;//统计找到的mt和st
139         mt = mt.toUpperCase();//转化成大写
140         st = st.toUpperCase();//转化成大写
141         //遍历所有元素结点
142         for(var i=0; i<nodes.length; i++)
143         {
144             if(nodes[i].nodeName == mt|| nodes[i].nodeName == st)
145             {
146                 //获取标题文本
147                 var nodetext = nodes[i].innerHTML.replace(/<\/?[^>]+>/g,"");//innerHTML里面的内容可能有HTML标签,所以用正则表达式去除HTML的标签
148                 nodetext = nodetext.replace(/ /ig, "");//替换掉所有的
149                 nodetext = BlogDirectory.htmlDecode(nodetext);
150                 //插入锚
151                 nodes[i].setAttribute("id", "blogTitle" + num);
152                 var item;
153                 switch(nodes[i].nodeName)
154                 {
155                     case mt:    //若为主标题
156                         item = document.createElement("dt");
157                         break;
158                     case st:    //若为子标题
159                         item = document.createElement("dd");
160                         break;
161                 }
162 
163                 //创建锚链接
164                 var itemtext = document.createTextNode(nodetext);
165                 item.appendChild(itemtext);
166                 item.setAttribute("name", num);
167                 //添加鼠标点击触发函数
168                 item.onclick = function(){        
169                 var pos = BlogDirectory.getElementPosition(document.getElementById("blogTitle" + this.getAttribute("name")));
170                     if(!BlogDirectory.moveScrollBar(pos.top, interval)) return false;
171                 };
172                 //将自定义表项加入自定义列表中
173                 dlist.appendChild(item);
174                 num++;
175             }
176         }
177 
178         if(num == 0) return false;
179         /* 鼠标进入时的事件处理 */
180         divSideBarTab.onmouseenter = function(){
181             divSideBarContents.style.display = 'block';
182         }
183         /* 鼠标离开时的事件处理 */
184         divSideBar.onmouseleave = function() {
185             divSideBarContents.style.display = 'none';
186         }
187 
188         document.body.appendChild(divSideBar);
189     }
190 
191 };
192 
193 window.onload=function(){
194     /* 页面加载完成之后生成博客目录 */
195     BlogDirectory.createBlogDirectory("cnblogs_post_body","h2","h3",20);
196     
197     //为右下角推荐推荐区域添加关注按钮
198     $('#div_digg').prepend('<div style="padding-bottom: 5px"><span class="icon_favorite" style="padding-top: 2px"></span><a onclick="cnblogs.UserManager.FollowBlogger(\'9a35f2c7-18ab-e111-aa3f-842b2b196315\');" href="javascript:void(0);" style="font-weight: bold; padding-left:5px;">关注一下楼主吧</a> </div>');
199 }
200 </script>
页脚

 

 

posted on 2021-09-28 21:45  RankFan  阅读(60)  评论(0编辑  收藏  举报

导航