文章分类 - Python基础
摘要:1 #!/use/bin/env python 2 # -*- coding:utf8 -*- 3 count = 0 4 while count < 3 : 5 user = input('>>>>') 6 pwd = input('>>>>') 7 if user == "kele" and p
阅读全文
摘要:1 #!/usr/bin/env pyehon 解释器路径 2 # -*- coding:utf8 -*- 编码 utf8 能用多少表示就用多少表示 3 # python3 无需关注 4 # python2 每个文件中只要出现中文,就必须加 5 #变量,指某一个变化的值 6 """ 7 变量,只能由
阅读全文
公告
/**
* UPDATES AND DOCS AT: https://github.com/BNDong
* https://www.cnblogs.com/bndong/
* @author: BNDong, dbnuo@foxmail.com
* ----------------------------------------------
* @describe: 侧边栏处理
*/
import sidebarTemp from '../../template/sidebar.html';
import navTemp from '../../template/sidebarNav.html';
import '../../style/menu_bubble.css';
import main4 from './lib/main4';
import defaultAvatarImg from './../../images/webp/default_avatar.webp';
import defaultSidebarBgImg from './../../images/sidebar_bg_4.png';
export default function main(_) {
let mainObj;
/**
* 设置侧边栏渲染
*/
(() => {
$('#sidebar_news').prepend(sidebarTemp);
mainObj = main4();
})();
/**
* 设置菜单信息
*/
(() => {
// ------- 设置导航 -------
let navHtml = _.__tools.tempReplacement(navTemp, 'user', _.__status.user);
$('.sidebar-footer').html(navHtml);
// ------- 设置头像 -------
let blogAvatar = _.__config.info.avatar ? _.__config.info.avatar : defaultAvatarImg;
$('#menuBlogAvatar').append("
");
// ------- 设置侧边栏信息 -------
$('.sidebar-title-msg').text(_.__config.sidebar.titleMsg);
})();
/**
* 设置菜单个人信息背景图片
*/
(() => {
let mbg = _.__config.sidebar.infoBackground ? _.__config.sidebar.infoBackground : defaultSidebarBgImg;
$('.container .menu-wrap').css('background-image', 'url(\''+mbg+'\')');
})();
/**
* 定时拉取数据
*/
(() => {
let timeout = 1000;
// ------- 用户个人信息 -------
_.__timeIds.introduceTId = window.setInterval(() => {
let introduceHtml = $('#profile_block').html(),
menuIntroduce = $('#introduce');
if ((typeof introduceHtml == 'string') && menuIntroduce.html() === '') {
menuIntroduce.html(_.__tools.htmlFiltrationScript(introduceHtml));
_.__tools.clearIntervalTimeId(_.__timeIds.introduceTId);
}
}, timeout);
// ------- 博客统计 -------
_.__timeIds.blogStatsTId = window.setInterval(() => {
let blogStatsObj = $('.blogStats'),
statsPostCount = $('#stats_post_count'),
menuBlogStats = $('.sidebar-stats');
if (blogStatsObj.length > 0 && statsPostCount.length > 0) {
menuBlogStats.html(_.__tools.htmlFiltrationScript(blogStatsObj.html())).show();
blogStatsObj.html('')
_.__tools.clearIntervalTimeId(_.__timeIds.blogStatsTId);
}
}, timeout);
// ------- 日历 -------
_.__timeIds.calendarTId = window.setInterval(() => {
let calendarTable = $('#blogCalendar'),
calendar = $('#blog-calendar'),
menuCalendar = $('#calendar-box');
if (calendarTable.length > 0 && menuCalendar.html() === ''){
let calendarHtml = '
';
calendar.remove();
menuCalendar.html(calendarHtml).show();
$('#blog-calendar').css('visibility', 'visible');
_.__tools.clearIntervalTimeId(_.__timeIds.calendarTId);
}
}, timeout);
// ------- 找找看 -------
_.__timeIds.searchTId = window.setInterval(() => {
let sidebarSearch = $('#sidebar_search_box'),
menuSearchBox = $('#sb-sidebarSearchBox');
if (sidebarSearch.length > 0 && menuSearchBox.html() === ''){
menuSearchBox.prepend('');
$('.sidebar-search').show();
_.__tools.clearIntervalTimeId(_.__timeIds.searchTId);
}
}, timeout);
// ------- 积分与排名 -------
_.__timeIds.scorerankTId = window.setInterval(() => {
listHdl(
$('#sidebar_scorerank ul li'),
$('#sb-sidebarScorerank'),
_.__timeIds.scorerankTId
);
}, timeout);
// ------- 最新随笔 -------
_.__timeIds.newEssayTId = window.setInterval(() => {
listHdl(
$('#sidebar_recentposts ul li'),
$('#sb-sidebarRecentposts'),
_.__timeIds.newEssayTId
);
}, timeout);
// ------- 我的标签 -------
_.__timeIds.topTagsTId = window.setInterval(() => {
listHdl(
$('#sidebar_toptags ul li'),
$('#sb-toptags'),
_.__timeIds.topTagsTId
);
}, timeout);
// ------- 随笔分类 -------
_.__timeIds.classifyTId = window.setInterval(() => {
listHdl(
$('#sidebar_postcategory ul li'),
$('#sb-classify'),
_.__timeIds.classifyTId
);
}, timeout);
// ------- 文章分类 -------
_.__timeIds.articleCategoryTId = window.setInterval(() => {
listHdl(
$('#sidebar_articlecategory ul li'),
$('#sb-ArticleCategory'),
_.__timeIds.articleCategoryTId
);
}, timeout);
// ------- 随笔档案 -------
_.__timeIds.recordTId = window.setInterval(() => {
listHdl(
$('#sidebar_postarchive ul li'),
$('#sb-record'),
'icon-task_fill',
_.__timeIds.recordTId
);
}, timeout);
// ------- 文章档案 -------
_.__timeIds.articleTId = window.setInterval(() => {
listHdl(
$('#sidebar_articlearchive ul li'),
$('#sb-articlearchive'),
'icon-document_fill',
_.__timeIds.articleTId
);
}, timeout);
// ------- 阅读排行 -------
_.__timeIds.topViewTId = window.setInterval(() => {
listHdl(
$('#TopViewPostsBlock ul li'),
$('#sb-topview'),
_.__timeIds.topViewTId
);
}, timeout);
// ------- 推荐排行 -------
_.__timeIds.topDiggPostsTId = window.setInterval(() => {
listHdl(
$('#TopDiggPostsBlock ul li'),
$('#sb-topDiggPosts'),
_.__timeIds.topDiggPostsTId
);
}, timeout);
// ------- 最新评论 -------
_.__timeIds.commentsTId = window.setInterval(() => {
let recentComments = $('#sidebar_recentcomments ul'),
menuRecentComments = $('#sb-recentComments');
let getMenuCommentsData = (obj) => {
let html = '';
html += '';
html += ' ';
html += ' '+ title +'';
html += '';
html += '';
html += ' ';
$('#customize-sidebar-menu > ul').append(html);
});
$('#customize-sidebar-menu').show();
$('#customize-sidebar-menu .sidebar-dropdown').show();
}
})();
// ------- 公共函数 -------
function listHdl(old, nld, tid) {
if (old.length > 0 && nld.html() === '') {
nld.html(getMenuData(old));
nld.parent('.sidebar-dropdown').show();
_.__tools.clearIntervalTimeId(tid);
}
}
function getMenuData(obj) {
let html = '
|
|||||||||
日 | 一 | 二 | 三 | 四 | 五 | 六 | |||
---|---|---|---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 | |||
8 | 9 | 10 | 11 | 12 | 13 | 14 | |||
15 | 16 | 17 | 18 | 19 | 20 | 21 | |||
22 | 23 | 24 | 25 | 26 | 27 | 28 | |||
29 | 30 | 1 | 2 | 3 | 4 | 5 | |||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
- ',
ret = /^[1-9]+[0-9]*$/,
title, body, author;
if (obj.find('li').length > 2) {
title = obj.find('li.recent_comment_title');
body = obj.find('li.recent_comment_body');
author = obj.find('li.recent_comment_author');
if (title.length !== body.length || title.length !== author.length) return ;
title.each((i) => {
let p = $(title[i]),
o = p.text() === p.html() ? {} : $(p.html()),
textArr = $.trim(p.text()).split('.');
if (ret.test(textArr[0])) textArr.splice(0,1);
let text = $.trim(textArr.join('.'));
o.length > 0 && o.html(text);
html += '
- ' + (o.length > 0 ? o.prop("outerHTML") : "" + text + "")
+ '' + $(body[i]).text() + '' + '' + $(author[i]).text() + '';
});
}
html += '
- ';
$.each(navList, function (i) {
let iconClass = navList[i].length > 2 ? navList[i][2] : "icon-qianzishenhe";
navHtml += '
- '+(navList[i][0])+' '; }); navHtml += '
- ';
$.each(list.data, (key, val) => {
html += '
- '; html += val[0] + ' '; }); html += '
- ',
ret = /^[1-9]+[0-9]*$/;
obj.each((i) => {
let p = $(obj[i]),
o = p.text() === p.html() ? {} : $(p.html()),
textArr = $.trim(p.text()).split('.');
if (ret.test(textArr[0])) textArr.splice(0,1);
let text = $.trim(textArr.join('.'));
o.length > 0 && o.html(text);
html += '
- ' + (o.length > 0 ? o.prop("outerHTML") : '' + text + '' ) + ' '; }); html += '