Last active
January 27, 2019 07:36
-
-
Save oit63/6d535033bccef7cce377949227316055 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="stylesheet" type="text/css" href="//fonts.lug.ustc.edu.cn/css?family=Orbitron" /> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/instantclick/3.0.1/instantclick.min.js"></script> | |
<script data-no-instant> | |
InstantClick.on('change', function(isInitialLoad){ | |
if (isInitialLoad === false) { | |
if (typeof MathJax !== 'undefined'){ | |
MathJax.Hub.Queue(["Typeset",MathJax.Hub]); | |
} | |
} | |
}); | |
InstantClick.init(); | |
</script> | |
<style> | |
.MathJax{outline:0;} | |
.MathJax_Display{overflow-x:auto;overflow-y:hidden;} | |
</style> | |
<style> | |
.typo p{text-indent:2em}.sidenotel p{text-indent:-0.37em}.comment-header::before{color:var(--main-color,#666);content:"@ ";position:absolute;left:-1em;font-family:"Orbitron",sans}.typo ul,.typo-ul{list-style:none!important}.typo ul li:before{list-style:circle!important;display:inline-block;content:"ϟ";counter-increment:item;width:.1em;right:.5em;clear:left;bottom:0;margin-left:1em;text-align:right;direction:rtl;font-size:1.1em;vertical-align:baseline;position:relative;font-family:"Orbitron",sans;white-space:wrap;word-wrap:break-word}.footnotes ol{list-style:none}.typo ol{counter-reset:item 0;margin-left:0;padding-left:0}.typo ol li:not(.footnote-item){display:block;margin-bottom:0;margin-left:1.3em;word-wrap:break-word}.typo ol li:not(.footnote-item)::before{display:inline-block;content:"" counter(item) "";counter-increment:item;width:2em;right:.5em;clear:left;bottom:0;margin-left:-1.0em;text-align:right;direction:rtl;font-size:1.1em;vertical-align:baseline;position:relative;font-family:"Orbitron",sans;white-space:wrap;word-wrap:break-word}*{margin:0;padding:0}.target{position:relative}.placeholder{position:absolute;display:block;width:100px;height:50px;top:-50px}.sidenotel{float:left;clear:left;margin-left:-36%;width:29%;margin-top:.66;margin-bottom:.66em;font-size:.85rem;line-height:1.5;vertical-align:baseline;position:relative;counter-increment:sidenote-counter}p{list-style:none;counter-reset:sidenote-counter 0}.fnNumber{font-size:.65rem;font-family:"Orbitron",sans}.navnoca{font-weight:349;text-decoration:none;color:#da2324!important;transition:color .96s linear!important;-o-transition:color .96s linear!important;-ms-transition:color .96s linear!important;-moz-transition:color .96s linear!important;-webkit-transition:color .96s linear!important;word-wrap:break-word;white-space:wrap}.navnoca:hover{word-wrap:break-word;white-space:wrap;color:#da2324!important;text-decoration:none;transition:color 1.96s linear!important;-o-transition:color 1.96s linear!important;-ms-transition:color 1.96s linear!important;-moz-transition:color 1.96s linear!important;-webkit-transition:color 1.96s linear!important}.navnoca:before{content:"";position:absolute;width:0;right:0;bottom:0;height:1px;background:var(--main-color,#666);-webkit-transition:width .3s ease}.footnote-title{font-weight:600;color:#da2324!important}.nav-choosed{font-weight:600;word-wrap:break-word;white-space:wrap}body{counter-reset:h2-counter -1}@media screen and (min-width:1081px){.typo h2:not(.nav-h2):before{content:"x" counter(h2-counter) ".";position:absolute;left:-1.86em}}@media screen and (min-width:100px){.typo h2:not(.nav-h2):before{content:"x" counter(h2-counter) ".";position:none}}.typo h2{position:relative;font-size:1.4em;margin-top:1.8em;padding-top:.8em}.typo h2:not(.nav-h2):before{counter-increment:h2-counter;color:var(--main-color,#666);font-family:"Orbitron",sans;font-size:1.1em}.nav-h1-choosed,.nav-h2-choosed,h2{font-weight:600;color:#da2324!important;word-wrap:break-word;white-space:wrap}.tocify-header-title{font-weight:600;color:#da2324!important}.tocify-header-current{color:#da2324!important}#toc a{display:block;color:#a2acb6}li a{white-space:wrap}.footnote-title{font-weight:300;white-space:pre}.nav-choosed::after{white-space:pre}.single-post .nav-choosed::before{position:absolute;width:0;right:0;bottom:0;height:1px;color:var(--main-color,#666) background:var(--main-color,#666);-webkit-transition:width .3s ease;transition:width .3s ease;transition:color 1.96s linear -webkit-transition:color 1.96s linear} | |
</style> | |
<script> | |
var isOnBigScreen = document.documentElement.clientWidth > 1078 ? true : false ; | |
// 用于跨域调用 | |
document.domain = "no.mk"; | |
var main_color = '#da2324'; //主色调,默认为#86B81B | |
var navDomain="https://blog.no.mk" | |
var codeDomain="https://github.com/tenhow" | |
// 判断是否在iframe里 | |
if(self==top){ | |
var show_search = true; //是否开启搜索功能,默认为true | |
var show_toc = true; //是否开启文章目录,默认为true | |
var show_index_tag = false; //是否开启首页底部标签云,默认为true | |
var show_valine = true; //开启评论功能 | |
var show_author = true; //开启文章底部作者信息 | |
//要开启评论功能需正确填写lc_appId与lc_appKey,并保证show_valine为true | |
var lc_appId = 'kApjPFTQYDNRlhK7neRTMlzl-gzGzoHsz'; | |
var lc_appKey = 'R8iSiU8OJ3HjH3oyWW4H36Om'; | |
//footer相关 | |
var footer_text = 'Hosted on Google Cloud Platform'; //自定义footer第二行文字,默认为空 | |
// 引入导航 | |
$(document ).ready(function(){ | |
//$("#background").show() | |
//$("#background").hide() | |
//$("h1").eq(0).text("准备跃迁.") | |
//$("h1").eq(0).text("开始跃迁..") | |
//$("h1").eq(0).text("正在跃迁...") | |
//$(".post-blog-title a").eq(0).text("") | |
//$(".post-blog-title a").eq(0).append("<i class='iconfont icon-back'></i> "+ "首页") | |
$(".comment-header").text("评") | |
$("h1").eq(0).text("") | |
// 获取带有两个斜杠的路径名 | |
var cpath = window.location.pathname | |
// 去掉最后一个斜杠,获取带有第一个斜杠的路径名 | |
// cpath = cpath.replace(/(.*)[/]$/, '$1'); | |
var fullPageName = cpath.substr(1,cpath.length-2) | |
// 获取不带有斜杠的路径名 | |
//var fullPageName = cpath.substr(1,cpath.length) | |
// 获取页面的附加名 | |
var pageAddonName = fullPageName.replace(/.+\-/, "") | |
// 假设获取到错误的系列名,充其量显示效果就是显示不出导航,正合我意 | |
// 获取系列名 | |
var serieName = fullPageName; | |
var serieNameMatches = fullPageName.match(/.+\-/) | |
if (serieNameMatches !=null && serieNameMatches.length !=0 && serieNameMatches[serieNameMatches.length -1]) { | |
serieName = serieNameMatches[serieNameMatches.length -1] | |
serieName = serieName.substr(0,serieName.length-1) | |
} | |
// 最后一个字符是数字 | |
// var isNumber = !isNaN(lastLetter) | |
// var chapterString = "-pt0" | |
// number(pt0), refs(videos,books,talks,sites,audios), con, phy(pattern) | |
// 添加首 | |
var wrap = "〔跃迁〕" | |
var head="首〔跃迁〕" | |
$(".post-content").prepend("<ol id='nav-ul'></ol>") | |
$(".post-content").children().first().before("<div name="+head+" data-unique="+head+"></div>") | |
$(".post-content").children().first().after("<h2 class='nav-h2' id=''>"+wrap+"</h2>") | |
// 到TOC | |
$("#toc").prepend("<ul id='tocify-header-head' class='tocify-header nav nav-list'><li class='tocify-item ' data-unique="+head+" style='cursor: pointer;'><a>"+wrap+"</a></li></ul>") | |
// 添加尾 到TOC | |
var tail="尾〔跃迁〕" | |
$(".post-content").append("<div name="+tail+" data-unique="+tail+"></div>") | |
$(".post-content").append("<h2 class='nav-h2' id='' >"+wrap+"</h2>") | |
$(".post-content").append("<ol id='nav-ul-end'></ol>") | |
// 到TOC | |
$("#toc").append("<ul id='tocify-header-tail' class='tocify-header nav nav-list'><li class='tocify-item ' data-unique='"+tail+"' style='cursor: pointer;'><a>"+wrap+"</a></li></ul>") | |
var srcpath = serieName | |
// 请求导航文本 | |
var src = navDomain + "/" + srcpath + "-nav" | |
$.get(src, null, function (data, textStatus){ | |
// 去除同域代码 | |
data = data.replace(/<script>.*script>/,""); | |
// 去除斜杠,以得到纯 AppName | |
var appName = srcpath.replace(/\//g,"") | |
// 使用 jquery 转化为对象 | |
var navList = $(data) | |
// 遍历导航对象,以组合成带有 href 的a标签 | |
var navListHtml="" | |
navList.children().each(function(i,n){ | |
var obj = $(n) | |
var pageName = obj.attr("data") | |
var combinedPageName="" | |
// 判断是否遍历遇到了 览 页面对应的标签, | |
// 当没遇到 览 的时候 | |
if (pageName != "glance") { | |
// 组合应用名称和页面的小名 | |
combinedPageName = appName+"-"+pageName | |
// 当遇到了代码页面导航 | |
if (pageName == "code") { | |
obj.prop("href",codeDomain+"/"+ appName) | |
// 在新标签打开 | |
//obj.attr("target","_blank") | |
} else { | |
obj.prop("href","/"+ combinedPageName) | |
} | |
} | |
else { | |
// 当遇到 览 页面的时候 | |
combinedPageName = appName | |
obj.prop("href","/"+appName) | |
var head = obj.text().replace(/\s/g,""); | |
normal_title = "「" + head + "」"; | |
document.title = normal_title; | |
// 给toc添加一个系列标题 | |
head = "「"+head+"」" | |
$(".tocify-item").eq(0).before("<ul id='tocify-header-title' class='tocify-header nav nav-list '><li class='tocify-item ' data-unique="+head+" style='cursor: pointer;'><a class='tocify-header-title'>"+head+"</a></li></ul>") | |
} | |
// 给每个导航目标增加 外框 | |
// 判断是否遍历遇到当前页面对应的标签, 当遇到的时候 | |
if(fullPageName==combinedPageName){ | |
// 拿到当前页面在导航页中的主题名称 | |
var curAText = obj.text() | |
// 在上面基础上加上一个指向标,以达到选中了当前页的效果 | |
var newText = " 〔 " + curAText + " 〕 " | |
//+" ▶◀χ" | |
obj.text(newText) | |
// 给它一个id,方便以后取用 | |
obj.attr("id","nav-cura") | |
obj.attr("disabled","true") | |
obj.addClass("nav-choosed") | |
obj.attr("href","javascript:void(0);") | |
//obj.removeAttr('href') | |
obj.parent().addClass("nav-choosed-li") | |
//str.replace(/〔/g,'') | |
$("h2").eq(1).text(obj.text()).addClass("nav-h2-choosed") | |
$("h1").eq(0).text(obj.text()).addClass("nav-h1-choosed") | |
// 改变toc的标题 | |
$(".tocify-item").eq(2).children().text(newText) | |
// $(".tocify-item").eq(2).children().addClass("tocify-header-current") | |
} else { | |
obj.text("〔 "+obj.text()+" 〕") | |
// 更改颜色为 灰色 表示未选中 | |
//obj.css("color","#cccccc") | |
obj.addClass("navnoca") | |
} | |
navListHtml=navListHtml+obj.parent().prop("outerHTML")+"\n" | |
}); | |
// 将转换成功的导航文本暂存 | |
var navlis = navListHtml | |
// 使用正则方式找到当前页面对应的a标签 | |
//var reg = "/"+fullPageName+".*\"/" | |
// 给当前页面对应的a标签增加一个"ca-nav"的id | |
//navlis = navlis.replace(eval(reg),cpath+"\" "+"id='ca-nav' "); | |
// 将该导航文本添加到 首 下面,以呈现导航区域 | |
$("#nav-ul").append(navlis); | |
// 通过 jquery 选择器 获取当前页面对应的标签 | |
//var caNavText = $("#ca-nav").text() | |
// 把标签替换为斜体标签 | |
//$("#nav-cura").contents().unwrap().wrap("<em class='test-underline'>"); | |
// 并新增加文本, 以实现指向标的视觉效果 | |
//$("#ca-nav").text(caNavText+" χ") | |
// 在 尾 下拷贝一份 首 的导航区域 | |
$("#nav-ul-end").append($("#nav-ul").children().clone()); | |
//设置页面自动跳转到当前页面的主题 | |
//setTimeout("javascript:$('#tocify-header0').children().click()", 0); | |
var hash =decodeURIComponent(window.location.hash); | |
if (hash.indexOf("#")!=-1) { | |
console.log(hash) | |
// 解决刷新后 锚点失效问题 | |
$(function() { | |
var id = hash.split('#')[1]; | |
if(id) { | |
if ($(id)[0]) { | |
/* | |
var t = $('#' + id).offset().top; | |
$(window).scrollTop(t); | |
*/ | |
$('html, body').animate({ | |
scrollTop: $("#"+id).offset().top | |
}, 0) | |
}else { | |
console.log("else") | |
$(".tocify-item[data-unique=" + id + "]").click() | |
} | |
} | |
}) | |
}else { | |
$('html, body').animate({ | |
scrollTop: $("h2").eq(1).offset().top | |
}, 0) | |
} | |
} | |
); | |
// 增加旁注 | |
// 可能有多个pragraph,$("[id=fn1]"),使用这个可以获取所有fn | |
// 然后用$("[id=fnref1]") 获取对应的脚注引用位置 | |
// 又因为ghostv2的内容页允许多个段落存在脚注, | |
// 如果保持使用相同id,会漏选,所以对它们的id 进行修改,让它们各自不同 | |
// 再取得脚注内容,对应引用位置插入旁注 | |
// 获取当前脚注处理位置 | |
var indexFn = 1; | |
// 生成脚注选择器 | |
var curFnSel = "[id=fn"+indexFn+"]" | |
var curFnRefSel = "[id=fnref"+indexFn+"]" | |
// 选择当前索引对应脚注数组 | |
var curFns = $(curFnSel) | |
// 选择当前索引对应脚注引用数组 | |
var curFnRefs = $(curFnRefSel) | |
// 声明遍历过程中要用到的容器 | |
// 当前的返回标签 | |
var fnReturnLabel="" | |
// 当前用于寻找脚注p标签内容的容器 | |
var conForFindText="" | |
// 当前的脚注内容 | |
var curFnText="" | |
// 生成的边注代码 | |
var curSnSpanHtml = "" | |
// 当前遇到的脚注 | |
var curFn="" | |
// 当前遇到的脚注引用 | |
var curFnRef="" | |
// 开始遍历脚注,直到找不到为止,以寻找所有页面上的脚注 | |
while(curFns[0]){ | |
// 遍历过程中,二级遍历使用的索引, | |
var indexSameIndexFn=0; | |
// 当前遇到的脚注 | |
curFn = curFns[indexSameIndexFn] | |
// 寻找到相同位置的脚注引用 | |
curFnRef = curFnRefs[indexSameIndexFn] | |
// 转成jquery 对象待用 | |
curFn = $(curFn) | |
curFnRef = $(curFnRef) | |
// 遍历相同索引的脚注 | |
var indexSameIndexFn=0; | |
while(curFn[0]){ | |
// 使用遇到到的脚注和对应的脚注引用做点什么 | |
// 修改依着二级索引,修改脚注和脚注引用的id,实现不同的段落有不同的url跳转标签 | |
//attr('id','newTop') | |
curFn.attr('id',curFn.attr('id')+"-"+indexSameIndexFn) | |
curFnRef.attr('id',curFnRef.attr('id')+"-"+indexSameIndexFn) | |
// 给脚注引用增加一个css样式 | |
curFnRef.addClass("fnNumber") | |
var curFnRefText = curFnRef.text() | |
curFnRef.text("〔"+ curFnRefText.substr(1,curFnRefText.length-2)+"〕") | |
curFnRef.attr('href',curFnRef.attr('href')+"-"+indexSameIndexFn) | |
// 获取到返回标签 | |
fnReturnLabel = curFn.find(".footnote-backref:eq(0)")//.children().children() | |
//.find("span:eq(0)") | |
// 同步更新返回标签的页面跳转地址 | |
fnReturnLabel.attr('href',fnReturnLabel.attr('href')+"-"+indexSameIndexFn) | |
// 把返回符号换成数字 | |
fnReturnLabel.text("〔"+indexFn+"〕") | |
// 给返回符号增加一个css样式 | |
fnReturnLabel.addClass("fnNumber") | |
// 拷贝一份返回符号到开头 | |
fnReturnLabel.parent().prepend(fnReturnLabel.clone()) | |
// ToQiang: 强迫症的话,可以把#fnref0-0 换成#0-fnref0 | |
// 或者说是,找到有几个含有脚注的段落,再同一列序号之类的 | |
// 通过一个临时容器寻找脚注的内容 | |
//conForFindText = $(curFn.html()); | |
//conForFindText.find("a").remove(); | |
//curFnText = conForFindText.html() | |
curSnSpanHtml = "<span class='sidenotel' "+"id='"+curFn.attr('id')+"'"+">"+curFn.html()+"</span>" | |
// 更新二级索引,以及获取下一个将要遇到的脚注数组 | |
if (isOnBigScreen) { | |
// 屏幕够大,以移除脚注了,只留下旁注 | |
curFn.remove() | |
$(curFnRef).parent().append(curSnSpanHtml) | |
} else { | |
// 显示屏幕太小的话,以只显示脚注 | |
} | |
indexSameIndexFn++ | |
curFn = curFns[indexSameIndexFn] | |
curFnRef = curFnRefs[indexSameIndexFn] | |
curFn = $(curFn) | |
curFnRef = $(curFnRef) | |
} | |
// 更新索引和遇到的脚注以及脚注引用数组 | |
indexFn++; | |
curFnSel = "[id=fn"+indexFn+"]" | |
curFnRefSel = "[id=fnref"+indexFn+"]" | |
curFns = $(curFnSel) | |
curFnRefs = $(curFnRefSel) | |
} | |
// 屏幕够大,以显示旁注,不显示脚注 | |
if (isOnBigScreen) { | |
// 不让就把脚注移除了,只留下旁注 | |
$(".footnotes-sep").remove() | |
} else { | |
// 显示屏幕太小的话不显示旁注,转而显示旁注 | |
// 插入脚注标题 | |
$(".footnotes-sep").after("<p class='footnote-title'>段落脚注〔微跃迁〕</p>") | |
} | |
var c = 0; | |
//document.title = "_" + normal_title | |
setInterval(function(){ | |
document.title = normal_title.substr(normal_title.length-c,1)+""+document.title+""; | |
if (c==normal_title.length) { | |
c=0; | |
document.title = normal_title | |
} | |
c++ | |
},5369) | |
// 转换我的注音元素到正规注音元素 | |
$("r").changeElementType("ruby") | |
$("t").changeElementType("rt") | |
}); | |
} else { | |
// 如果 | |
} | |
/* | |
document.addEventListener('visibilitychange', function () { | |
if (document.visibilityState == 'hidden') { | |
normal_title = document.title; | |
document.title = "["+normal_title+"]"; | |
} else document.title = "〔"+normal_title + "〕"; | |
}); | |
*/ | |
(function($) { | |
$.fn.changeElementType = function(newType) { | |
this.each(function() { | |
var attrs = {}; | |
$.each(this.attributes, function(idx, attr) { | |
attrs[attr.nodeName] = attr.nodeValue; | |
}); | |
$(this).replaceWith(function() { | |
return $("<" + newType + "/>", attrs).append($(this).contents()); | |
}); | |
}); | |
}; | |
})(jQuery); | |
</script> | |
<link rel="dns-prefetch" href="//cdn.bootcss.com" /> | |
<link rel="dns-prefetch" href="//cdn.mathjax.org" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment