';
}
for (var i = 2; i <= mybanner.length; i++) {
str2 = str2 + '
' + i + '
';
}
str = '
' +
'
' +
'' +
'
' +
'
' +
'
' +
str1 +
'
' +
'
' +
'
' +
'
' +
'
1
' +
str2 +
'
' +
'
' +
'
' +
'
' +
'
';
if ($('.day').length > 0) {
$('.forFlow').prepend($(str)) //首页轮播
}
function SlideShow(c) {
var a = document.getElementById("slideContainer"),
f = document.getElementById("slidesImgs").getElementsByTagName("li"),
h = document.getElementById("slideBar"),
n = h.getElementsByTagName("li"),
d = f.length,
c = c || 3000,
e = lastI = 0,
j, m;
function b() {
m = setInterval(function() {
e = e + 1 >= d ? e + 1 - d : e + 1;
g()
}, c)
}
function k() {
clearInterval(m)
}
function g() {
f[lastI].style.display = "none";
n[lastI].className = "";
f[e].style.display = "block";
n[e].className = "on";
lastI = e
}
f[e].style.display = "block";
a.onmouseover = k;
a.onmouseout = b;
h.onmouseover = function(i) {
j = i ? i.target : window.event.srcElement;
if (j.nodeName === "LI") {
e = parseInt(j.innerHTML, 10) - 1;
g()
}
};
b()
};
if ($('.day').length > 0) {
SlideShow(3000);
}
}
// 设置网页tab图标
function setFavio(myprofile) {
$('head').append($('').attr('href', myprofile[0].blogAvatar));
};
// 设置侧边栏公告个人信息
function loadProfile(myprofile) {
var str = '
';
if ($('#cnblogs_post_body') != null) {
$('#MySignature').append(str);
}
}
//运行脚本
function runCode() {
$(function() {
$('myscript').each(function() {
$(this).css('display', 'none');
eval($(this).text());
});
});
}
// 新增/读取 cookie
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toGMTString();
document.cookie = cname + "=" + cvalue + "; " + expires + ";secure; path=/";
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i].trim();
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
var Theme = {
Light: {
'color': '#141418',
'TextColor1': '#141418',
'TextColor2': '#5f5f6b',
'TextColor3': '#97979f',
'DividColor': '#e7eaf0',
'BackgroundColor': '#f4f6fa',
'BlockColor': '#ffffff'
},
Dark: {
'color': '#cfcecf',
'TextColor1': '#cfcecf',
'TextColor2': '#89888c',
'TextColor3': '#57565a',
'DividColor': '#323236',
'BackgroundColor': '#26252a',
'BlockColor': '#201f25'
}
}
function changeThemeColor(Light) {
setCookie('color', Light.color, 30);
setCookie('TextColor1', Light.TextColor1, 30);
setCookie('TextColor2', Light.TextColor2, 30);
setCookie('TextColor3', Light.TextColor3, 30);
setCookie('DividColor', Light.DividColor, 30);
setCookie('BackgroundColor', Light.BackgroundColor, 30);
setCookie('BlockColor', Light.BlockColor, 30);
$('html').css("color", getCookie("color"));
document.documentElement.style.setProperty("--TextColor1", getCookie("TextColor1"));
document.documentElement.style.setProperty("--TextColor2", getCookie("TextColor2"));
document.documentElement.style.setProperty("--TextColor3", getCookie("TextColor3"));
document.documentElement.style.setProperty("--DividColor", getCookie("DividColor"));
document.documentElement.style.setProperty("--BackgroundColor", getCookie("BackgroundColor"));
document.documentElement.style.setProperty("--BlockColor", getCookie("BlockColor"));
}
// 切换主题
function changeTheme() {
if ($('html').css('color') == 'rgb(20, 20, 24)') {
changeThemeColor(Theme.Dark);
} else {
changeThemeColor(Theme.Light);
}
}
function loadThemeColor() {
if (getCookie("color")==""){
$('html').css("color", getCookie("#141418"));
document.documentElement.style.setProperty("--TextColor1", "#141418");
document.documentElement.style.setProperty("--TextColor2", "#5f5f6b");
document.documentElement.style.setProperty("--TextColor3", "#97979f");
document.documentElement.style.setProperty("--DividColor", "#e7eaf0");
document.documentElement.style.setProperty("--BackgroundColor", "#f4f6fa");
document.documentElement.style.setProperty("--BlockColor", "#ffffff");
}
else{
$('html').css("color", getCookie("color"));
document.documentElement.style.setProperty("--TextColor1", getCookie("TextColor1"));
document.documentElement.style.setProperty("--TextColor2", getCookie("TextColor2"));
document.documentElement.style.setProperty("--TextColor3", getCookie("TextColor3"));
document.documentElement.style.setProperty("--DividColor", getCookie("DividColor"));
document.documentElement.style.setProperty("--BackgroundColor", getCookie("BackgroundColor"));
document.documentElement.style.setProperty("--BlockColor", getCookie("BlockColor"));
}
}
// 公告
function loadNewsinfo(news){
str = '
'+ news +'
'
$('#mainContent').prepend(str);
}
// 捷径
function narrow() {
var nowText = $('#blog_nav_shortcut').text();
if (nowText == '打开捷径') {
$('.shortcut').css({
'height': 'auto',
'padding': '20px',
'margin-bottom': '20px'
});
$('#blog_nav_shortcut').text('关闭捷径')
} else {
$('.shortcut').css({
'height': '0',
'padding': '0px',
'margin-bottom': '0px'
});
$('#blog_nav_shortcut').text('打开捷径')
}
return false;
}
function loadShortcut(myHtml) {
var str = '
' + myHtml + '
';
$('#mainContent').prepend(str);
}
/*
MATLAB Highlighter 1.55, a small and lightweight JavaScript library for colorizing your MATLAB syntax.
http://matlabtricks.com/matlab-highlighter
Licensed under the MIT license
Copyright (c) 2013, Zoltan Fegyver
*/
function highlightMATLABCode(d) {
function g(i) {
return (i >= "A" && i <= "Z") || (i >= "a" && i <= "z") || (i == ")")
}
function m(r, j, i) {
var s = j.index,
t;
while (s >= i) {
t = r.charAt(--s);
if (t == "\n") {
break
}
if (t == "'") {
continue
} else {
return !g(t)
}
}
return true
}
function a(i) {
var j = i.length - 1,
r;
while (j > 0) {
r = i.charAt(--j);
if (r == "\n") {
return true
}
if (r == "%") {
return false
}
}
return true
}
function n(t) {
var s, u = 0,
r, v = /(\'[^\'\n]*\')/gi,
j = [];
while (s = v.exec(t)) {
if (m(t, s, u)) {
var w = t.slice(u, s.index);
for (var i = j.length - 2; i >= 0; i -= 2) {
if (w.indexOf("\n") > -1) {
break
}
w = w.concat(j[i])
}
if (a(w)) {
r = s.index + s[1].length;
j.push(t.slice(u, s.index));
j.push(t.slice(s.index, r));
u = r
}
}
}
j.push(t.slice(u));
return j
}
function b(u, j) {
var w = '";
if (j) {
return [w, 'matlab-string">', u, v].join("")
} else {
var t = [{
r: /\b('|break|case|catch|classdef|continue|else|elseif|end|for|function|global|if|otherwise|parfor|persistent|return|spmd|switch|try|while|')\b/gi,
s: "keyword"
}, {
r: /\b([0-9]+)\b/gi,
s: "number"
}, {
r: /([(){}\[\]]+)/gi,
s: "bracket"
}, {
r: /(%[^\n]*)/gi,
s: "comment"
}];
for (var r = 0, s = t.length; r < s; r++) {
u = u.replace(t[r].r, [w, "matlab-", t[r].s, '">$1', v].join(""))
}
return u
}
}
function q(u) {
var w = [],
s = [];
if (typeof u === "undefined") {
u = {
tagPre: true,
tagCode: false,
className: "matlab-code"
}
}
if (typeof u !== "object") {
w.push(document.getElementById(u))
} else {
if (u.tagCode) {
s.push("code")
}
if (u.tagPre) {
s.push("pre")
}
for (var t = 0; t < s.length; t++) {
var x = document.getElementsByTagName(s[t]);
for (var r = 0, v = x.length; r < v; r++) {
if ((u.className == "") || ((x[r].className.toString().length > 0) && ((" " + x[r].className + " ").indexOf(" " +
u.className + " ") > -1))) {
w.push(x[r])
}
}
}
}
return w
}
var p = q(d);
for (var f = 0, o = p.length; f < o; f++) {
var c = n(p[f].innerHTML.toString().replace(/ /mg, "\n")),
h = [],
l = " ";
for (var e = 0, k = c.length; e < k; e++) {
h.push(b(c[e], e % 2))
}
p[f].innerHTML = h.join("").replace(/^[ ]/gm, l).replace(/\n/gm, " ").replace(/\t/gm, l + l)
}
};
// 自定义markdown
function mymd() {
var d = document;
var cnblogs_post_body = d.getElementById('cnblogs_post_body');
if (cnblogs_post_body != null) {
var html = d.getElementById('cnblogs_post_body').innerHTML;
html = md2video(html);
html = md2music(html);
d.getElementById('cnblogs_post_body').innerHTML = html;
}
// 自定义视频语法
function md2video(str) {
var video_str1 = '';
return str.replace(/\