博客删除的代码记录

2020.3.10

<section><%if(post.prevPost&&!post.hideInList){%><div style="color:#ccc;font-size:12px;width:50%;">上一篇<a href="<%= post.prevPost.link %>"><p class="post-title"><b><%=post.prevPost.title%></b></p></a></div><hr><%}%><%if(post.nextPost&&!post.hideInList){%><div style="color:#ccc;font-size:12px;width:50%;">下一篇<a href="<%= post.nextPost.link %>"><p class="post-title"><b><%=post.nextPost.title%></b></p></a></div><%}%></section>

用来在每个 post 下面生成下一篇文章

2020.3.13

html{
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
}

网页黑白代码

2020.3.15

<div id="magnifyImg">
<img src alt="Big Image">
</div>
(function(){var a=document.querySelector("#magnifyImg");var d=a.querySelector("img");var e=document.querySelectorAll(".md_block img");d.addEventListener("click",function(f){a.style.display="none";f&&f.stopPropagation&&f.stopPropagation()},false);for(var c=0;c<e.length;++c){var b=e[c];b.addEventListener("click",(function(g,f){return function(h){h&&h.stopPropagation&&h.stopPropagation();if(window.innerWidth<980){return}d.style.height=d.style.width="auto";if(window.innerWidth/window.innerHeight>f){d.style.height=(window.innerHeight-20)+"px"}else{d.style.width=(window.innerWidth-20)+"px"}a.style.height=window.innerHeight+"px";a.style.lineHeight=window.innerHeight+"px";a.style.display="block";d.src=g}}(b.src,b.width/b.height)),false)}})();

点击图片放大的代码,因为有时候放大效果不好,且移动端不方便使用,所以替换成了如下代码:

<div id="fullPage"><canvas id="canvas"></canvas></div>
<script src="https://cdn.jsdelivr.net/gh/qyxtim/Static@5.2/magnify.js">
#imgBox img{
    display: block;
    width: 80%;
    margin: 30px auto;
}
#fullPage{
    display: none;
    background: black;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 19930428;
}
#fullPage img{
    display: block;
    width: 100%;
}
#canvas{
    width: 100%;
    height: 100%;
    background: none;
    display: block;
}
var wxScale=new WxScale({
	fullPage:document.querySelector("#fullPage"),
	canvas:document.querySelector("#canvas")
});	
var imgBox=document.querySelectorAll("#md_block img");
for(var i=0; i<imgBox.length; i++){
	imgBox[i].onclick=function(e){
		wxScale.start(this);
	}
}

2020.4.7

enableReference = 0
indexTitle = str.indexOf('title', indexC);
if (indexTitle < indexEnd && indexTitle != -1){
    indexTitleEnd = str.indexOf('"', indexTitle + 7);
    title = str.substring(indexTitle + 7, indexTitleEnd);
    indexLink = str.indexOf('href', indexC);
    indexLinkEnd = str.indexOf('"', indexLink + 6);
    link = str.substring(indexLink + 6, indexLinkEnd);
}
if (enableReference == 0){
    str = str + '<h2>References</h2>'
    enableReference = 1;
}
strTemp += '<div style="display: inline; font-size: 80%; line-height: 26px;">[' + String(enableReference) + ']</div>&nbsp&nbsp<p style="display: inline; font-size: 14px; line-height: 26px; color: black; word-break: break-all;">'+title+':<em style="font-style: italic; color: black;">&nbsp<a href="'+link+'" target="_blank" style="text-decoration: none; color: #1e6bb8; word-wrap: break-word; font-weight: bold; border-bottom: 1px solid #1e6bb8;">'+link+'</a></em></p><br>';
enableReference = enableReference + 1;

EJS 自动在文章底部生成 Reference 的代码

  • 已知问题:当链接里有 title 时会导致 Reference 异常。