|
| 1 | +--- |
| 2 | +layout: page |
| 3 | +--- |
| 4 | +<link rel="stylesheet" href="/js/prettify/prettify.css" /> |
| 5 | +<div class="entry"> |
| 6 | + {{ content }} |
| 7 | + 如果您觉得有帮助,就尽情分享或者<a href="/about" target="_blank">关注我吧</a>:<br/> |
| 8 | + <!--<a href='http://me.alipay.com/beiyuu' target="_blank" style="float:left;"><img src='https://img.alipay.com/sys/personalprod/style/mc/btn-index.png' style="display:inline" /></a>--> |
| 9 | + <div style="float:left;width:160px;"> |
| 10 | + <iframe width="100%" height="75" class="share_self" frameborder="0" scrolling="no" src="http://widget.weibo.com/weiboshow/index.php?language=&width=0&height=75&fansRow=2&ptype=1&speed=0&skin=1&isTitle=0&noborder=0&isWeibo=0&isFans=0&uid=1855270953&verifier=375b89d6&colors=d6f3f7,F8F8F0,666666,0082cb,ecfbfd&dpc=1"></iframe> |
| 11 | + </div> |
| 12 | + <div id="jiathis_style_32x32" style="float:left;margin-left:20px;margin-top:35px;"> |
| 13 | + <a class="jiathis_button_tsina"></a> |
| 14 | + <a class="jiathis_button_douban"></a> |
| 15 | + <a class="jiathis_button_tqq"></a> |
| 16 | + <a class="jiathis_button_renren"></a> |
| 17 | + <a class="jiathis_button_douban9dian"></a> |
| 18 | + <!--<a class="jiathis_button_readitlater"></a>--> |
| 19 | + <!--<a class="jiathis_button_instapaper"></a>--> |
| 20 | + <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a> |
| 21 | + <!--<a class="jiathis_counter_style"></a>--> |
| 22 | + </div> |
| 23 | + <div style="clear:both"></div> |
| 24 | +</div><!-- .entry --> |
| 25 | +<div id="disqus_container"> |
| 26 | + <a href="#" class="comment" onclick="return false;">点击查看评论</a> |
| 27 | + <div id="disqus_thread"></div> |
| 28 | +</div> |
| 29 | +<script type="text/javascript"> |
| 30 | + $(document).ready(function(){ |
| 31 | + $('pre').addClass('prettyprint linenums') //添加Google code Hight需要的class |
| 32 | + |
| 33 | + $('#disqus_container .comment').on('click',function(){ |
| 34 | + $(this).html('加载中...'); |
| 35 | + var disqus_shortname = 'beiyuu'; |
| 36 | + var that = this; |
| 37 | + BYB.includeScript('http://' + disqus_shortname + '.disqus.com/embed.js',function(){$(that).remove()}); |
| 38 | + }); |
| 39 | + |
| 40 | + $('.entry a').each(function(index,element){ |
| 41 | + var href = $(this).attr('href'); |
| 42 | + if(href){ |
| 43 | + if(href.indexOf('#') == 0){ |
| 44 | + }else if ( href.indexOf('/') == 0 || href.toLowerCase().indexOf('beiyuu.com')>-1 ){ |
| 45 | + }else if ($(element).has('img').length){ |
| 46 | + }else{ |
| 47 | + $(this).attr('target','_blank'); |
| 48 | + $(this).addClass('external'); |
| 49 | + } |
| 50 | + } |
| 51 | + }); |
| 52 | + |
| 53 | + if($('h2').length > 2){ |
| 54 | + var h2 = [],h3 = [],tmpl = '<ul>',h2index = 0; |
| 55 | + |
| 56 | + var findScrollableElement = function(els) { |
| 57 | + for (var i = 0, argLength = arguments.length; i < argLength; i++) { |
| 58 | + var el = arguments[i], |
| 59 | + $scrollElement = $(el); |
| 60 | + if ($scrollElement.scrollTop() > 0) { |
| 61 | + return $scrollElement; |
| 62 | + } else { |
| 63 | + $scrollElement.scrollTop(1); |
| 64 | + var isScrollable = $scrollElement.scrollTop() > 0; |
| 65 | + $scrollElement.scrollTop(0); |
| 66 | + if (isScrollable) { |
| 67 | + return $scrollElement; |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | + return []; |
| 72 | + }; |
| 73 | + |
| 74 | + $.each($('h2,h3'),function(index,item){ |
| 75 | + if(item.tagName.toLowerCase() == 'h2'){ |
| 76 | + var h2item = {}; |
| 77 | + h2item.name = $(item).text(); |
| 78 | + h2item.id = 'menuIndex'+index; |
| 79 | + h2.push(h2item); |
| 80 | + h2index++; |
| 81 | + }else{ |
| 82 | + var h3item = {}; |
| 83 | + h3item.name = $(item).text(); |
| 84 | + h3item.id = 'menuIndex'+index; |
| 85 | + if(!h3[h2index-1]){ |
| 86 | + h3[h2index-1] = []; |
| 87 | + } |
| 88 | + h3[h2index-1].push(h3item); |
| 89 | + } |
| 90 | + item.id = 'menuIndex' + index |
| 91 | + }); |
| 92 | + |
| 93 | + //添加h1 |
| 94 | + tmpl += '<li class="h1"><a href="#" data-top="0">'+$('h1').text()+'</a></li>'; |
| 95 | + |
| 96 | + for(var i=0;i<h2.length;i++){ |
| 97 | + tmpl += '<li><a href="#" data-id="'+h2[i].id+'">'+h2[i].name+'</a></li>'; |
| 98 | + if(h3[i]){ |
| 99 | + for(var j=0;j<h3[i].length;j++){ |
| 100 | + tmpl += '<li class="h3"><a href="#" data-id="'+h3[i][j].id+'">'+h3[i][j].name+'</a></li>'; |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | + tmpl += '</ul>'; |
| 105 | + |
| 106 | + var $scrollable = findScrollableElement('body','html'); |
| 107 | + $('body').append('<div id="menuIndex"></div>'); |
| 108 | + $('#menuIndex').append($(tmpl)).delegate('a','click',function(e){ |
| 109 | + e.preventDefault(); |
| 110 | + var scrollNum = $(this).attr('data-top') || $('#'+$(this).attr('data-id')).offset().top; |
| 111 | + //window.scrollTo(0,scrollNum-30); |
| 112 | + $scrollable.animate({ scrollTop: scrollNum-30 }, 400, 'swing'); |
| 113 | + }) |
| 114 | + |
| 115 | + $(window).load(function(){ |
| 116 | + var scrollTop = []; |
| 117 | + $.each($('#menuIndex li a'),function(index,item){ |
| 118 | + if(!$(item).attr('data-top')){ |
| 119 | + var top = $('#'+$(item).attr('data-id')).offset().top; |
| 120 | + scrollTop.push(top); |
| 121 | + $(item).attr('data-top',top); |
| 122 | + } |
| 123 | + }); |
| 124 | + |
| 125 | + $(window).scroll(function(){ |
| 126 | + var nowTop = $(window).scrollTop(),index,length = scrollTop.length; |
| 127 | + if(nowTop+60 > scrollTop[length-1]){ |
| 128 | + index = length |
| 129 | + }else{ |
| 130 | + for(var i=0;i<length;i++){ |
| 131 | + if(nowTop+60 <= scrollTop[i]){ |
| 132 | + index = i |
| 133 | + break; |
| 134 | + } |
| 135 | + } |
| 136 | + } |
| 137 | + $('#menuIndex li').removeClass('on') |
| 138 | + $('#menuIndex li').eq(index).addClass('on') |
| 139 | + }); |
| 140 | + }); |
| 141 | + |
| 142 | + //用js计算屏幕的高度 |
| 143 | + $('#menuIndex').css('max-height',$(window).height()-80); |
| 144 | + } |
| 145 | + |
| 146 | + BYB.includeScript('/js/prettify/prettify.js',function(){prettyPrint()}); |
| 147 | + |
| 148 | + BYB.includeScript('http://v2.jiathis.com/code/jia.js',function(){}) |
| 149 | + }); |
| 150 | +</script> |
0 commit comments