mirror of
https://github.com/kaka111222333/kaka111222333.github.io.git
synced 2025-12-21 17:25:07 +08:00
创建博客
This commit is contained in:
39
static/js/category.js
Normal file
39
static/js/category.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 页面ready方法
|
||||
*/
|
||||
$(document).ready(function() {
|
||||
categoryDisplay();
|
||||
});
|
||||
|
||||
/**
|
||||
* 分类展示
|
||||
* 点击右侧的分类展示时
|
||||
* 左侧的相关裂变展开或者收起
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
function categoryDisplay() {
|
||||
selectCategory();
|
||||
$('.categories-item').click(function() {
|
||||
window.location.hash = "#" + $(this).attr("cate");
|
||||
selectCategory();
|
||||
});
|
||||
}
|
||||
|
||||
function selectCategory(){
|
||||
var exclude = ["",undefined];
|
||||
var thisId = window.location.hash.substring(1);
|
||||
var allow = true;
|
||||
for(var i in exclude){
|
||||
if(thisId == exclude[i]){
|
||||
allow = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(allow){
|
||||
var cate = thisId;
|
||||
$("section[post-cate!='" + cate + "']").hide(200);
|
||||
$("section[post-cate='" + cate + "']").show(200);
|
||||
} else {
|
||||
$("section[post-cate='All']").show();
|
||||
}
|
||||
}
|
||||
3751
static/js/gitment.js
Normal file
3751
static/js/gitment.js
Normal file
File diff suppressed because it is too large
Load Diff
45
static/js/post.js
Normal file
45
static/js/post.js
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
layout: null
|
||||
---
|
||||
|
||||
/**
|
||||
* 页面ready方法
|
||||
*/
|
||||
$(document).ready(function() {
|
||||
generateContent();
|
||||
// share();
|
||||
gitment();
|
||||
});
|
||||
|
||||
/**
|
||||
* 侧边目录
|
||||
*/
|
||||
function generateContent() {
|
||||
var $mt = $('.toc');
|
||||
var toc = $(".post ul#markdown-toc").clone().get(0);
|
||||
$mt.each(function(i,o){
|
||||
$(o).html(toc);
|
||||
});
|
||||
}
|
||||
|
||||
function share(){
|
||||
window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"1","bdSize":"24"},"share":{}};
|
||||
with(document)0[getElementsByTagName("script")[0].parentNode.appendChild(createElement('script')).src='//bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
|
||||
}
|
||||
|
||||
|
||||
function gitment() {
|
||||
var gitment = new Gitment({
|
||||
id: window.location.pathname,
|
||||
owner: '{{site.github.username}}',
|
||||
repo: '{{site.gitment.repo}}',
|
||||
oauth: {
|
||||
client_id: '{{site.gitment.client_id}}',
|
||||
client_secret: '{{site.gitment.client_secret}}',
|
||||
},
|
||||
});
|
||||
gitment.render('post-comment')
|
||||
$("#post-comment").removeClass('hidden');
|
||||
}
|
||||
|
||||
|
||||
55
static/js/script.js
Normal file
55
static/js/script.js
Normal file
@@ -0,0 +1,55 @@
|
||||
---
|
||||
layout: null
|
||||
---
|
||||
|
||||
/**
|
||||
* 页面ready方法
|
||||
*/
|
||||
$(document).ready(function() {
|
||||
|
||||
console.log("你不乖哦,彼此之间留点神秘感不好吗?");
|
||||
|
||||
backToTop();
|
||||
search();
|
||||
});
|
||||
|
||||
/**
|
||||
* 回到顶部
|
||||
*/
|
||||
function backToTop() {
|
||||
$("[data-toggle='tooltip']").tooltip();
|
||||
var st = $(".page-scrollTop");
|
||||
var $window = $(window);
|
||||
var topOffset;
|
||||
//滚页面才显示返回顶部
|
||||
$window.scroll(function() {
|
||||
var currnetTopOffset = $window.scrollTop();
|
||||
if (currnetTopOffset > 0 && topOffset > currnetTopOffset) {
|
||||
st.fadeIn(500);
|
||||
} else {
|
||||
st.fadeOut(500);
|
||||
}
|
||||
topOffset = currnetTopOffset;
|
||||
});
|
||||
|
||||
//点击回到顶部
|
||||
st.click(function() {
|
||||
$window.scrollTop(0)
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function search(){
|
||||
(function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
|
||||
(w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
|
||||
e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.appendChild(s);
|
||||
})(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');
|
||||
|
||||
_st('install','{{site.swiftype.searchId}}','2.0.0');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
221
static/js/tagCloud.js
Normal file
221
static/js/tagCloud.js
Normal file
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* @copyright http://blog.rainynight.top/
|
||||
* Licensed under MIT
|
||||
*/
|
||||
(function($){
|
||||
$.fn.tagCloud = function(){
|
||||
|
||||
var $this = $(this);
|
||||
|
||||
for(var i=0; i<$this.length;i++){
|
||||
execute($this.get(i));
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
function execute(shell){
|
||||
//半径
|
||||
var radius = 120;
|
||||
//是否活动
|
||||
var active = true;
|
||||
//是否分散
|
||||
var scatter = true;
|
||||
//旋转速度
|
||||
var speed = 2;
|
||||
//右旋偏移
|
||||
var rightOffset = 50;
|
||||
//下旋偏移
|
||||
var downOffset = 0;
|
||||
//与眼睛的距离
|
||||
var distance=300;
|
||||
|
||||
var items = shell.getElementsByTagName('a');
|
||||
var itemWraps = [];
|
||||
for(var i=0; i<items.length; i++)
|
||||
{
|
||||
var tag = {};
|
||||
var item = items[i];
|
||||
tag.item = item;
|
||||
tag.offsetWidth = item.offsetWidth;
|
||||
tag.offsetHeight = item.offsetHeight;
|
||||
itemWraps.push(tag);
|
||||
}
|
||||
|
||||
initPosition();
|
||||
|
||||
shell.onmouseover=function ()
|
||||
{
|
||||
active = false;
|
||||
};
|
||||
|
||||
shell.onmouseout=function ()
|
||||
{
|
||||
active = true;
|
||||
};
|
||||
|
||||
setInterval(update, 30);
|
||||
|
||||
function update()
|
||||
{
|
||||
var a;
|
||||
var b;
|
||||
|
||||
if(active)
|
||||
{
|
||||
a = (-Math.min( Math.max( -downOffset, -radius ), radius ) / radius ) * speed;
|
||||
b = (Math.min( Math.max( -rightOffset, -radius ), radius ) / radius ) * speed;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
with(trigonometric(a,b,0)) {
|
||||
for (var j = 0; j < itemWraps.length; j++) {
|
||||
var rx1 = itemWraps[j].x;
|
||||
var ry1 = itemWraps[j].y * ca + itemWraps[j].z * (-sa);
|
||||
var rz1 = itemWraps[j].y * sa + itemWraps[j].z * ca;
|
||||
|
||||
var rx2 = rx1 * cb + rz1 * sb;
|
||||
var ry2 = ry1;
|
||||
var rz2 = rx1 * (-sb) + rz1 * cb;
|
||||
|
||||
var rx3 = rx2 * cc + ry2 * (-sc);
|
||||
var ry3 = rx2 * sc + ry2 * cc;
|
||||
var rz3 = rz2;
|
||||
|
||||
itemWraps[j].x = rx3;
|
||||
itemWraps[j].y = ry3;
|
||||
itemWraps[j].z = rz3;
|
||||
|
||||
var per = distance / (distance + rz3);
|
||||
|
||||
itemWraps[j].scale = per;
|
||||
itemWraps[j].alpha = per;
|
||||
|
||||
itemWraps[j].alpha = (itemWraps[j].alpha - 0.6) * (10 / 6);
|
||||
}
|
||||
}
|
||||
doPosition();
|
||||
}
|
||||
|
||||
function doPosition()
|
||||
{
|
||||
var l=shell.offsetWidth/2;
|
||||
var t=shell.offsetHeight/2;
|
||||
for(var i=0;i<itemWraps.length;i++)
|
||||
{
|
||||
items[i].style.left=itemWraps[i].x+l-itemWraps[i].offsetWidth/2+'px';
|
||||
items[i].style.top=itemWraps[i].y+t-itemWraps[i].offsetHeight/2+'px';
|
||||
|
||||
items[i].style.fontSize=Math.ceil(12*itemWraps[i].scale/2)+8+'px';
|
||||
|
||||
items[i].style.filter="alpha(opacity="+100*itemWraps[i].alpha+")";
|
||||
items[i].style.opacity=itemWraps[i].alpha;
|
||||
}
|
||||
ensureDepth();
|
||||
}
|
||||
|
||||
function ensureDepth()
|
||||
{
|
||||
var tmp=[];
|
||||
|
||||
for(var i=0;i<items.length;i++)
|
||||
{
|
||||
tmp.push(items[i]);
|
||||
}
|
||||
|
||||
tmp.sort
|
||||
(
|
||||
function (vItem1, vItem2)
|
||||
{
|
||||
if(vItem1.z>vItem2.z)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if(vItem1.z<vItem2.z)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
for(var i=0;i<tmp.length;i++)
|
||||
{
|
||||
tmp[i].style.zIndex=i;
|
||||
}
|
||||
}
|
||||
|
||||
function trigonometric( a, b, c)
|
||||
{
|
||||
var dtr = Math.PI/radius;
|
||||
var rst = {};
|
||||
with(rst) {
|
||||
sa = Math.sin(a * dtr);
|
||||
ca = Math.cos(a * dtr);
|
||||
sb = Math.sin(b * dtr);
|
||||
cb = Math.cos(b * dtr);
|
||||
sc = Math.sin(c * dtr);
|
||||
cc = Math.cos(c * dtr);
|
||||
}
|
||||
return rst;
|
||||
}
|
||||
|
||||
|
||||
function initPosition()
|
||||
{
|
||||
var phi=0;
|
||||
var theta=0;
|
||||
var max=itemWraps.length;
|
||||
var tmp=[];
|
||||
var oFragment=document.createDocumentFragment();
|
||||
|
||||
for(var i=0; i<items.length; i++)
|
||||
{
|
||||
tmp.push(items[i]);
|
||||
}
|
||||
|
||||
//随机排序
|
||||
tmp.sort
|
||||
(
|
||||
function ()
|
||||
{
|
||||
return Math.random()<0.5?1:-1;
|
||||
}
|
||||
);
|
||||
|
||||
for(var i=0;i<tmp.length;i++)
|
||||
{
|
||||
oFragment.appendChild(tmp[i]);
|
||||
}
|
||||
|
||||
shell.appendChild(oFragment);
|
||||
|
||||
for( var i=1; i<max+1; i++){
|
||||
if( scatter )
|
||||
{
|
||||
phi = Math.acos(-1+(2*i-1)/max);
|
||||
theta = Math.sqrt(max*Math.PI)*phi;
|
||||
}
|
||||
else
|
||||
{
|
||||
phi = Math.random()*(Math.PI);
|
||||
theta = Math.random()*(2*Math.PI);
|
||||
}
|
||||
//坐标变换
|
||||
itemWraps[i-1].x = radius * Math.cos(theta)*Math.sin(phi);
|
||||
itemWraps[i-1].y = radius * Math.sin(theta)*Math.sin(phi);
|
||||
itemWraps[i-1].z = radius * Math.cos(phi);
|
||||
|
||||
items[i-1].style.left=itemWraps[i-1].x+shell.offsetWidth/2-itemWraps[i-1].offsetWidth/2+'px';
|
||||
items[i-1].style.top=itemWraps[i-1].y+shell.offsetHeight/2-itemWraps[i-1].offsetHeight/2+'px';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
})($);
|
||||
3
static/js/tags.js
Normal file
3
static/js/tags.js
Normal file
@@ -0,0 +1,3 @@
|
||||
$(function(){
|
||||
$('.tagCloud').tagCloud();
|
||||
});
|
||||
88
static/js/toc.js
Normal file
88
static/js/toc.js
Normal file
@@ -0,0 +1,88 @@
|
||||
// https://github.com/ghiculescu/jekyll-table-of-contents
|
||||
(function($){
|
||||
$.fn.toc = function(options) {
|
||||
var defaults = {
|
||||
noBackToTopLinks: false,
|
||||
title: '<i>Jump to...</i>',
|
||||
minimumHeaders: 3,
|
||||
headers: 'h1, h2, h3, h4, h5, h6',
|
||||
listType: 'ol', // values: [ol|ul]
|
||||
showEffect: 'show', // values: [show|slideDown|fadeIn|none]
|
||||
showSpeed: 'slow' // set to 0 to deactivate effect
|
||||
},
|
||||
settings = $.extend(defaults, options);
|
||||
|
||||
function fixedEncodeURIComponent (str) {
|
||||
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
|
||||
return '%' + c.charCodeAt(0).toString(16);
|
||||
});
|
||||
}
|
||||
|
||||
var headers = $(settings.headers).filter(function() {
|
||||
// get all headers with an ID
|
||||
var previousSiblingName = $(this).prev().attr( "name" );
|
||||
if (!this.id && previousSiblingName) {
|
||||
this.id = $(this).attr( "id", previousSiblingName.replace(/\./g, "-") );
|
||||
}
|
||||
return this.id;
|
||||
}), output = $(this);
|
||||
if (!headers.length || headers.length < settings.minimumHeaders || !output.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 === settings.showSpeed) {
|
||||
settings.showEffect = 'none';
|
||||
}
|
||||
|
||||
var render = {
|
||||
show: function() { output.hide().html(html).show(settings.showSpeed); },
|
||||
slideDown: function() { output.hide().html(html).slideDown(settings.showSpeed); },
|
||||
fadeIn: function() { output.hide().html(html).fadeIn(settings.showSpeed); },
|
||||
none: function() { output.html(html); }
|
||||
};
|
||||
|
||||
var get_level = function(ele) { return parseInt(ele.nodeName.replace("H", ""), 10); }
|
||||
var highest_level = headers.map(function(_, ele) { return get_level(ele); }).get().sort()[0];
|
||||
var return_to_top = '<i class="icon-arrow-up back-to-top"> </i>';
|
||||
|
||||
var level = get_level(headers[0]),
|
||||
this_level,
|
||||
html = settings.title + " <"+settings.listType+">";
|
||||
headers.on('click', function() {
|
||||
if (!settings.noBackToTopLinks) {
|
||||
window.location.hash = this.id;
|
||||
}
|
||||
})
|
||||
.addClass('clickable-header')
|
||||
.each(function(_, header) {
|
||||
this_level = get_level(header);
|
||||
if (!settings.noBackToTopLinks && this_level === highest_level) {
|
||||
$(header).addClass('top-level-header').after(return_to_top);
|
||||
}
|
||||
if (this_level === level) // same level as before; same indenting
|
||||
html += "<li><a href='#" + fixedEncodeURIComponent(header.id) + "'>" + header.innerHTML + "</a>";
|
||||
else if (this_level <= level){ // higher level than before; end parent ol
|
||||
for(i = this_level; i < level; i++) {
|
||||
html += "</li></"+settings.listType+">"
|
||||
}
|
||||
html += "<li><a href='#" + fixedEncodeURIComponent(header.id) + "'>" + header.innerHTML + "</a>";
|
||||
}
|
||||
else if (this_level > level) { // lower level than before; expand the previous to contain a ol
|
||||
for(i = this_level; i > level; i--) {
|
||||
html += "<"+settings.listType+"><li>"
|
||||
}
|
||||
html += "<a href='#" + fixedEncodeURIComponent(header.id) + "'>" + header.innerHTML + "</a>";
|
||||
}
|
||||
level = this_level; // update for the next one
|
||||
});
|
||||
html += "</"+settings.listType+">";
|
||||
if (!settings.noBackToTopLinks) {
|
||||
$(document).on('click', '.back-to-top', function() {
|
||||
$(window).scrollTop(0);
|
||||
window.location.hash = '';
|
||||
});
|
||||
}
|
||||
|
||||
render[settings.showEffect]();
|
||||
};
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user