@@ -311,9 +311,9 @@ function Base() {
311311 if ( ac === 'down' ) {
312312 var docHeight = $ ( document ) . height ( ) ;
313313 var windowHeight = $ ( window ) . height ( ) ;
314- tools . actScroll ( docHeight - windowHeight , 2000 )
314+ tools . actScroll ( docHeight - windowHeight , 900 )
315315 } else {
316- tools . actScroll ( 0 , 2000 )
316+ tools . actScroll ( 0 , 900 )
317317 }
318318 }
319319 }
@@ -410,12 +410,21 @@ function Base() {
410410 * 日/夜间模式控制
411411 */
412412 this . setDayNightControl = function ( ) {
413- var h = parseInt ( new Date ( ) . getHours ( ) ) , head = $ ( 'head' ) ,
414- daySwitch = window . cnblogsConfig . switchDayNight . auto . enable ?
415- ( h >= window . cnblogsConfig . switchDayNight . auto . nightHour ? '' :
416- ( h >= window . cnblogsConfig . switchDayNight . auto . dayHour ? 'daySwitch' : '' )
417- ) : 'daySwitch' ,
418- html = '<div id="dayNightSwitch" class="generalWrapper">' +
413+ var h = parseInt ( new Date ( ) . getHours ( ) ) , head = $ ( 'head' ) , cookieKey = 'cnblogs_config_isNight' , exp = 4 * 3600 , daySwitch ;
414+
415+ switch ( tools . getCookie ( cookieKey ) ) {
416+ case 'day' :
417+ daySwitch = 'daySwitch' ; break ;
418+ case 'night' :
419+ daySwitch = '' ; break ;
420+ default :
421+ daySwitch = window . cnblogsConfig . switchDayNight . auto . enable ?
422+ ( h >= window . cnblogsConfig . switchDayNight . auto . nightHour ? '' :
423+ ( h >= window . cnblogsConfig . switchDayNight . auto . dayHour ? 'daySwitch' : '' )
424+ ) : 'daySwitch' ; break ;
425+ }
426+
427+ var html = '<div id="dayNightSwitch" class="generalWrapper">' +
419428 ' <div class="onOff ' + daySwitch + '">' +
420429 ' <div class="star star1"></div>' +
421430 ' <div class="star star2"></div>' +
@@ -437,10 +446,12 @@ function Base() {
437446 if ( ! daySwitch ) head . append ( '<link type="text/css" id="baseDarkCss" rel="stylesheet" href="' + getJsDelivrUrl ( 'base.dark.css' ) + '">' ) ;
438447
439448 $ ( '#dayNightSwitch .onOff' ) . click ( function ( ) {
440- if ( $ ( this ) . hasClass ( 'daySwitch' ) ) {
449+ if ( $ ( this ) . hasClass ( 'daySwitch' ) ) { // 夜间
450+ tools . setCookie ( cookieKey , 'night' , exp ) ;
441451 $ ( this ) . removeClass ( 'daySwitch' ) ;
442452 head . append ( '<link type="text/css" id="baseDarkCss" rel="stylesheet" href="' + getJsDelivrUrl ( 'base.dark.css' ) + '">' ) ;
443- } else {
453+ } else { // 日间
454+ tools . setCookie ( cookieKey , 'day' , exp ) ;
444455 $ ( this ) . addClass ( 'daySwitch' ) ;
445456 $ ( 'head link#baseDarkCss' ) . remove ( ) ;
446457 }
@@ -1215,8 +1226,6 @@ function Base() {
12151226 hltype = window . cnblogsConfig . essayCodeHighlightingType . toLowerCase ( ) ,
12161227 hltheme = window . cnblogsConfig . essayCodeHighlighting . toLowerCase ( ) ;
12171228
1218- if ( window . cnblogsConfig . codeMaxHeight ) pre . css ( 'max-height' , '70vh' ) ;
1219-
12201229 switch ( hltype ) {
12211230 case 'highlightjs' :
12221231 setCodeBefore ( 1 ) ;
@@ -1324,7 +1333,10 @@ function Base() {
13241333 }
13251334
13261335 function setCodeBefore ( type ) {
1327- pre . css ( 'cssText' , "font-family:'Ubuntu Mono',monospace !important; font-size: 14px !important;" ) ;
1336+ var cssText = "font-family:" + window . cnblogsConfig . essayCode . fontFamily + " !important; font-size: " + window . cnblogsConfig . essayCode . fontSize + " !important;" ;
1337+ if ( window . cnblogsConfig . codeMaxHeight ) cssText += 'max-height: 70vh;' ;
1338+ pre . css ( 'cssText' , cssText ) ;
1339+
13281340 $ . each ( pre , function ( i ) {
13291341 var obj = $ ( this ) , pid = 'pre-' + tools . randomString ( 6 ) , codeLine , html = '' ;
13301342
@@ -1385,72 +1397,42 @@ function Base() {
13851397 } ;
13861398
13871399 /**
1388- * 设置评论框样式
1400+ * 设置评论样式
13891401 */
13901402 this . setCommentStyle = function ( ) {
1391-
1392- var commentList = $ ( '.blog_comment_body[id!=tbCommentBodyPreviewBody]' ) ,
1393- commentPlaceholder = $ ( '#blog-comments-placeholder' ) ;
1394-
1395- $ ( '#comment_form_container .comment_textarea' ) . css ( {
1396- width :'100%' ,
1397- height : '100%'
1398- } ) ;
1399-
1400- commentAvatar ( commentList ) ;
1401- commentList . addClass ( 'hvr-bob' ) ;
1402-
1403- //气泡效果
14041403 timeIds . commentTId = window . setInterval ( function ( ) {
1405- if ( commentPlaceholder . html ( ) != '' || $ ( "#comments_pager_bottom" ) . length > 0 ) {
1406- CommentBubble ( ) ;
1407- bndongJs . clearIntervalTimeId ( timeIds . commentTId ) ;
1408- }
1409- } , 1000 ) ;
1410-
1411- function commentAvatar ( commentList ) {
1412- commentList . each ( function ( i ) {
1413- var p = $ ( commentList [ i ] ) . attr ( 'id' ) . split ( '_' ) ,
1414- html = '' ;
1415- if ( p . length > 0 ) {
1416- var idIndex = p . length - 1 ;
1417- var id = p [ idIndex ] ;
1418- var idTmp = id . toString ( ) . match ( / [ 0 - 9 ] / g ) ;
1419- if ( $ . isArray ( idTmp ) ) id = idTmp . join ( '' ) ;
1420- var op = $ ( '#comment_' + id + '_avatar ') ;
1421- if ( op . length > 0 && op . text ( ) != '' ) {
1422- var patch = op . text ( ) ;
1423- html += '<img class="comment-avatar" src="' + patch + '"/> ';
1424- } else {
1425- html += '<img class="comment-avatar" src="https://cdn.jsdelivr.net/gh/BNDong/Cnblogs-Theme-SimpleMemory@master/img/webp/default_avatar.webp"/>' ;
1404+ if ( $ ( '.feedbackItem' ) . length > 0 ) {
1405+ setComment ( ) ;
1406+ bndongJs . clearIntervalTimeId ( timeIds . commentTId ) ;
1407+ }
1408+ } , 1000 ) ;
1409+
1410+ function setComment ( ) {
1411+ var feedbackItem = $ ( '.feedbackItem' ) ;
1412+ if ( feedbackItem . length > 0 ) {
1413+ $ . each ( feedbackItem , function ( i ) {
1414+ var obj = $ ( this ) , feedbackCon = obj . find ( '.feedbackCon' ) , feedbackListSubtitle = obj . find ( '.feedbackListSubtitle' ) ,
1415+ commentBody = feedbackCon . length ? feedbackCon . find ( '.blog_comment_body' ) : [ ] , avatarHtml = '' ,
1416+ idInfo = commentBody . length ? commentBody . attr ( 'id' ) . split ( '_' ) : undefined ;
1417+ if ( idInfo && idInfo . length > 0 ) {
1418+ var id = idInfo [ idInfo . length - 1 ] , idTmp = id . toString ( ) . match ( / [ 0 - 9 ] / g ) ;
1419+ if ( $ . isArray ( idTmp ) ) id = idTmp . join ( ' ') ;
1420+ var op = $ ( '#comment_' + id + '_avatar' ) , patch = op . length > 0 ? $ . trim ( op . text ( ) )
1421+ : 'https://cdn.jsdelivr.net/gh/BNDong/Cnblogs-Theme-SimpleMemory@master/img/webp/default_avatar.webp' ;
1422+ var ac = $ ( '#a_comment_author_' + id ) , ah = ac . length ? ac . attr ( 'href' ) : 'javascropt:void(0); ';
1423+ avatarHtml = '<div class="feedbackAvatar"><a href="' + ah + '" target="_blank"><img src="' + patch + '"/></a></div>' ;
1424+ obj . prepend ( avatarHtml ) ;
14261425 }
1427- $ ( commentList [ i ] ) . before ( html ) ;
1428- }
1429- } ) ;
1430- }
1431-
1432- function CommentBubble ( ) {
1433- var w1 = '<div class="list">' +
1434- '<table class="out" border="0" cellspacing="0" cellpadding="0"> ' +
1435- '<tr>' +
1436- '<td align="left" valign="bottom" class="q">' +
1437- '<table border="0" cellpadding="0" cellspacing="0" style=""> ' +
1438- '<tr><td class="topleft"></td><td class="top"></td><td class="topright"></td></tr> ' +
1439- '<tr><td class="left"></td> <td align="left" class="conmts"><p>' ;
1440-
1441-
1442- var w2 = '</p> </td> <td class="right"></td></tr> ' +
1443- '<tr><td class="bottomleft"></td><td class="bottom"></td><td class="bottomright"></td></tr> ' +
1444- '</table>' +
1445- '</td> ' +
1446- '</tr> ' +
1447- '</table> ' +
1448- '</div>' ;
1449-
1450- $ . each ( $ ( ".blog_comment_body" ) , function ( i , t ) {
1451- $ ( t ) . html ( w1 + $ ( t ) . html ( ) + w2 ) ;
1452- } ) ;
1453- $ ( ".louzhu" ) . closest ( ".feedbackItem" ) . find ( ".out" ) . removeClass ( "out" ) . addClass ( "inc" ) ;
1426+ if ( feedbackListSubtitle . length && feedbackListSubtitle . find ( '.louzhu' ) . length ) {
1427+ feedbackListSubtitle . addClass ( 'feedbackListSubtitle-louzhu' ) ;
1428+ }
1429+ } ) ;
1430+ $ ( feedbackItem [ 0 ] ) . css ( 'padding-top' , '0' ) ;
1431+ $ ( feedbackItem [ feedbackItem . length - 1 ] ) . css ( 'padding-bottom' , '0' ) ;
1432+ var cssText = "font-family:" + window . cnblogsConfig . essayCode . fontFamily + " !important; font-size: " + window . cnblogsConfig . essayCode . fontSize + " !important; border-radius: 5px;padding: 10px;" ;
1433+ if ( window . cnblogsConfig . essayCodeHighlightingType === 'cnblogs' ) cssText += 'color: #000;' ;
1434+ $ ( 'head' ) . append ( '<style>.feedbackCon pre {' + cssText + 'background-color: ' + $ ( '.postBody pre' ) . css ( 'background-color' ) + ' !important;' + '}</style>' ) ;
1435+ }
14541436 }
14551437 } ;
14561438
0 commit comments