Skip to content

Commit

Permalink
更新2.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
jielive committed Sep 4, 2020
1 parent 2f82b4a commit d46752d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 27 deletions.
8 changes: 4 additions & 4 deletions footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
</ul>
</div>
<?php endif; if ($this->options->PjaxOption || $this->options->AjaxLoad): ?>
<script src="//<?php if ($this->options->cjCDN == 'bc'): ?>cdn.bootcss.com/jquery/2.1.4/jquery.min.js<?php elseif ($this->options->cjCDN == 'cf'): ?>cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js<?php else: ?>cdn.jsdelivr.net/npm/jquery@2.1.4/dist/jquery.min.js<?php endif; ?>"></script>
<script src="//<?php if ($this->options->cjCDN == 'sc'): ?>cdn.staticfile.org/jquery/2.1.4/jquery.min.js<?php elseif ($this->options->cjCDN == 'bc'): ?>cdn.bootcss.com/jquery/2.1.4/jquery.min.js<?php elseif ($this->options->cjCDN == 'jd'): ?>cdn.jsdelivr.net/npm/jquery@2.1.4/dist/jquery.min.js<?php else: ?>cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js<?php endif; ?>"></script>
<?php endif; if ($this->options->PjaxOption): ?>
<script src="//<?php if ($this->options->cjCDN == 'bc'): ?>cdn.bootcss.com/jquery.pjax/2.0.1/jquery.pjax.min.js<?php elseif ($this->options->cjCDN == 'cf'): ?>cdnjs.cloudflare.com/ajax/libs/jquery.pjax/2.0.1/jquery.pjax.min.js<?php else: ?>cdn.jsdelivr.net/npm/jquery-pjax@2.0.1/jquery.pjax.min.js<?php endif; ?>"></script>
<script src="//<?php if ($this->options->cjCDN == 'sc'): ?>cdn.staticfile.org/jquery.pjax/2.0.1/jquery.pjax.min.js<?php elseif ($this->options->cjCDN == 'bc'): ?>cdn.bootcss.com/jquery.pjax/2.0.1/jquery.pjax.min.js<?php elseif ($this->options->cjCDN == 'jd'): ?>cdn.jsdelivr.net/npm/jquery-pjax@2.0.1/jquery.pjax.min.js<?php else: ?>cdnjs.cloudflare.com/ajax/libs/jquery.pjax/2.0.1/jquery.pjax.min.js<?php endif; ?>"></script>
<script>jQuery.fn.Shake=function(n,d){this.each(function(){var jSelf=$(this);jSelf.css({position:'relative'});for(var x=1;x<=n;x++){jSelf.animate({left:(-d)},50).animate({left:d},50).animate({left:0},50)}});return this};$(document).pjax('a:not(a[target="_blank"], a[no-pjax])',{container:'#main',fragment:'#main',timeout:10000}).on('submit','form[id=search], form[id=comment-form]',function(event){$.pjax.submit(event,{container:'#main',fragment:'#main',timeout:10000})}).on('pjax:send',function(){$("#header").prepend("<div id='bar'></div>")}).on('pjax:complete',function(){setTimeout(function(){$("#bar").remove()},300);$('#header').removeClass("on");$('#s').val("");<?php if ($this->options->SidebarFixed): ?>$("#secondary").removeAttr("style");<?php endif; ?>}).on('pjax:end',function(){<?php if ($this->options->AjaxLoad): ?>al();<?php endif; ?>cl();ac();ap();<?php if ($this->options->CustomContent): ?>if(typeof _hmt!=='undefined'){_hmt.push(['_trackPageview',location.pathname+location.search])};if(typeof ga!=='undefined'){ga('send','pageview',location.pathname+location.search)}<?php endif; ?>});function ac(){$body=$('html,body');var g='.comment-list',h='.comment-num',i='.comment-reply a',wi='.whisper-reply',j='#textarea',k='',l='';c();$('#comment-form').submit(function(){$.ajax({url:$(this).attr('action'),type:'post',data:$(this).serializeArray(),error:function(){alert("提交失败,请检查网络并重试或者联系管理员。");return false},success:function(d){if(!$(g,d).length){alert("您输入的内容不符合规则或者回复太频繁,请修改内容或者稍等片刻。");return false}else{k=$(g,d).html().match(/id=\"?comment-\d+/g).join().match(/\d+/g).sort(function(a,b){return a-b}).pop();if($('.page-navigator .prev').length&&l==""){k=''}if(l){d=$('#li-comment-'+k,d).hide();if($('#'+l).find(".comment-children").length<=0){$('#'+l).append("<div class='comment-children'><ol class='comment-list'><\/ol><\/div>")}if(k)$('#'+l+" .comment-children .comment-list").prepend(d);l=''}else{d=$('#li-comment-'+k,d).hide();if(!$(g).length)$('#comments').prepend("<h3>已有 <span class='comment-num'>0<\/span> 条评论<\/h3><ol class='comment-list'><\/ol>");$(g).prepend(d)}$('#li-comment-'+k).fadeIn();var f;$(h).length?(f=parseInt($(h).text().match(/\d+/)),$(h).html($(h).html().replace(f,f+1))):0;TypechoComment.cancelReply();$(j).val('');$(i+','+wi+', #cancel-comment-reply-link').unbind('click');c();if(k){$body.animate({scrollTop:$('#li-comment-'+k).offset().top-50},300)}else{$body.animate({scrollTop:$('#comments').offset().top-50},300)}}}});return false});function c(){$(i+','+wi).click(function(){l=$(this).parent().parent().parent().attr("id")});$('#cancel-comment-reply-link').click(function(){l=''})}}ac();var protoken='<?php echo Typecho_Widget::widget('Widget_Security')->getTokenUrl('Token'); ?>'.replace('Token',"");function ap(){$('.protected .post-title a, .protected .more a').click(function(){var a=$(this).parent().parent();a.find('.word').text("请输入密码访问").css('color','red').Shake(2,10);a.find(':password').focus();return false});$('.protected form').submit(function(){ap_btn=$(this);ap_m=ap_btn.parent().find('.more a');ap_n=ap_btn.find('.word');$(ap_m).addClass('loading').text("请稍等");<?php if (!$this->options->AjaxLoad): ?>apt();<?php else: ?>aps();<?php endif; ?>return false})}ap();<?php if (!$this->options->AjaxLoad): ?>function apt(){var b=$('.protected .post-title a').attr("href");if($('h1.post-title').length){aps()}else{$.ajax({url:window.location.href,success:function(d){protoken=$('.protected form[action^="'+b+'"]',d).attr("action").replace(b,"");if(protoken){aps()}else{$(ap_m).removeAttr("class").text("- 阅读全文 -");ap_n.text("提交失败,请检查网络并重试或者联系管理员。").css('color','red').Shake(2,10);return false}}})}}<?php endif; ?>function aps(){var c=ap_btn.parent().parent().find('.post-title a').attr("href");$.ajax({url:c+protoken,type:'post',data:ap_btn.serializeArray(),error:function(){$(ap_m).removeAttr("class").text("- 阅读全文 -");ap_n.text("提交失败,请检查网络并重试或者联系管理员。").css('color','red').Shake(2,10);return false},success:function(d){if(!$('h1.post-title',d).length){$(ap_m).removeAttr("class").text("- 阅读全文 -");ap_n.text("对不起,您输入的密码错误。").css('color','red').Shake(2,10);$(":password").val("");return false}else{$(ap_m).removeAttr("class").text("- 阅读全文 -");$('h1.post-title').length?$.pjax.reload({container:'#main',fragment:'#main',timeout:10000}):$.pjax({url:c,container:'#main',fragment:'#main',timeout:10000})}}})}</script>
<?php endif; if ($this->options->AjaxLoad): ?>
<script>var isbool=true;<?php if ($this->options->AjaxLoad == 'auto'): ?>$(window).scroll(function(){if(isbool&&$('.ajaxload .next a').attr("href")&&($(this).scrollTop()+$(window).height()+20)>=$(document).height()){isbool=false;aln()}});<?php endif; ?>function al(){$('.ajaxload li[class!="next"]').remove();$('.ajaxload .next a').click(function(){if(isbool){aln()}return false})}al();function aln(){var a='.ajaxload .next a',b=$(a).attr("href");$(a).addClass('loading').text("正在加载");if(b){$.ajax({url:b,error:function(){alert('请求失败,请检查网络并重试或者联系管理员');$(a).removeAttr("class").text("查看更多");return false},success:function(d){var c=$(d).find("#main .post"),e=$(d).find(a).attr("href");if(c){$('.ajaxload').before(c)};$(a).removeAttr("class");if(e){$(a).text("查看更多").attr("href",e)}else{$(a).remove();$('.ajaxload .next').text('没有更多文章了')}if($('.protected',d).length){$('.protected *').unbind();ap()}isbool=true;return false}})}}</script>
<script>var isbool=true;<?php if ($this->options->AjaxLoad == 'auto'): ?>$(window).scroll(function(){if(isbool&&$('.ajaxload .next a').attr("href")&&($(this).scrollTop()+$(window).height()+5)>=$(document).height()){isbool=false;aln()}});<?php endif; ?>function al(){$('.ajaxload li[class!="next"]').remove();$('.ajaxload .next a').click(function(){if(isbool){aln()}return false})}al();function aln(){var a='.ajaxload .next a',b=$(a).attr("href");$(a).addClass('loading').text("正在加载");if(b){$.ajax({url:b,error:function(){alert('请求失败,请检查网络并重试或者联系管理员');$(a).removeAttr("class").text("查看更多");return false},success:function(d){var c=$(d).find("#main .post"),e=$(d).find(a).attr("href");if(c){$('.ajaxload').before(c)};$(a).removeAttr("class");if(e){$(a).text("查看更多").attr("href",e)}else{$(a).remove();$('.ajaxload .next').text('没有更多文章了')}if($('.protected',d).length){$('.protected *').unbind();ap()}isbool=true;return false}})}}</script>
<?php endif; ?>
<?php $this->footer(); ?>
<?php if ($this->options->scrollTop || $this->options->HeadFixed || $this->options->SidebarFixed): ?>
Expand All @@ -47,6 +47,6 @@
<?php endif; if ($this->options->CustomContent): $this->options->CustomContent(); ?>

<?php endif; ?>
<script>var cornertool=true;function cl(){var a=document.getElementById("catalog-col"),b=document.getElementById("catalog"),c=document.getElementById("cornertool"),d;if(a&&!b){if(c){c=c.getElementsByTagName("ul")[0];d=document.createElement("li");d.setAttribute("id","catalog");d.setAttribute("onclick","Catalogswith()");d.appendChild(document.createElement("span"));c.appendChild(d)}else{cornertool=false;c=document.createElement("div");c.setAttribute("id","cornertool");c.innerHTML='<ul><li id="catalog" onclick="Catalogswith()"><span></span></li></ul>';document.body.appendChild(c)}document.getElementById("catalog").className=a.className}if(!a&&b){cornertool?c.getElementsByTagName("ul")[0].removeChild(b):document.body.removeChild(c)}if(a&&b){b.className=a.className}}cl();console.log("\n%c Initial By JIElive %c http://www.offodd.com ","color:#fff;background:#000;padding:5px 0","color:#fff;background:#666;padding:5px 0")</script>
<script><?php if ($this->options->catalog): ?>var cornertool=true;function cl(){var a=document.getElementById("catalog-col"),b=document.getElementById("catalog"),c=document.getElementById("cornertool"),d;if(a&&!b){if(c){c=c.getElementsByTagName("ul")[0];d=document.createElement("li");d.setAttribute("id","catalog");d.setAttribute("onclick","Catalogswith()");d.appendChild(document.createElement("span"));c.appendChild(d)}else{cornertool=false;c=document.createElement("div");c.setAttribute("id","cornertool");c.innerHTML='<ul><li id="catalog" onclick="Catalogswith()"><span></span></li></ul>';document.body.appendChild(c)}document.getElementById("catalog").className=a.className}if(!a&&b){cornertool?c.getElementsByTagName("ul")[0].removeChild(b):document.body.removeChild(c)}if(a&&b){b.className=a.className}}cl();<?php endif; ?>console.log("\n%c Initial By JIElive %c http://www.offodd.com ","color:#fff;background:#000;padding:5px 0","color:#fff;background:#666;padding:5px 0")</script>
</body>
</html><?php if ($this->options->compressHtml): $html_source = ob_get_contents(); ob_clean(); print compressHtml($html_source); ob_end_flush(); endif; ?>
41 changes: 28 additions & 13 deletions functions.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
define('INITIAL_VERSION_NUMBER', '2.4.4');
define('INITIAL_VERSION_NUMBER', '2.4.5');
if (Helper::options()->GravatarUrl) define('__TYPECHO_GRAVATAR_PREFIX__', Helper::options()->GravatarUrl);
error_reporting(0);

function themeConfig($form) {
$logoUrl = new Typecho_Widget_Helper_Form_Element_Text('logoUrl', NULL, NULL, _t('站点 LOGO 地址'), _t('在这里填入一个图片 URL 地址, 以在网站标题前加上一个 LOGO'));
$logoUrl = new Typecho_Widget_Helper_Form_Element_Text('logoUrl', NULL, NULL, _t('站点标题 LOGO 地址'), _t('在这里填入一个图片 URL 地址, 以显示网站标题 LOGO'));
$form->addInput($logoUrl);

$customTitle = new Typecho_Widget_Helper_Form_Element_Text('customTitle', NULL, NULL, _t('自定义站点标题'), _t('仅用于替换页面头部位置的“标题”显示,和Typecho后台设置的站点名称不冲突,留空则显示默认站点名称'));
$form->addInput($customTitle);

$titleForm = new Typecho_Widget_Helper_Form_Element_Radio('titleForm',
array('title' => _t('仅文字'),
'logo' => _t('仅LOGO'),
'all' => _t('LOGO+文字')),
'title', _t('站点标题显示内容'), _t('默认仅显示文字标题,若要显示LOGO,请在上方添加 LOGO 地址'));
$form->addInput($titleForm);

$subTitle = new Typecho_Widget_Helper_Form_Element_Text('subTitle', NULL, NULL, _t('自定义站点副标题'), _t('浏览器副标题,仅在当前页面为首页时显示,显示格式为:<b>标题 - 副标题</b>,留空则不显示副标题'));
$form->addInput($subTitle);

$customTitle = new Typecho_Widget_Helper_Form_Element_Text('customTitle', NULL, NULL, _t('自定义头部站点标题'), _t('仅在页面头部标题位置显示,和Typecho后台设置的站点名称不冲突,留空则显示默认站点名称'));
$form->addInput($customTitle);

$favicon = new Typecho_Widget_Helper_Form_Element_Text('favicon', NULL, NULL, _t('Favicon 地址'), _t('在这里填入一个图片 URL 地址, 以添加一个Favicon,留空则不单独设置Favicon'));
$form->addInput($favicon);

Expand Down Expand Up @@ -66,10 +73,11 @@ function themeConfig($form) {
$form->addInput($SidebarFixed);

$cjCDN = new Typecho_Widget_Helper_Form_Element_Radio('cjCDN',
array('bc' => _t('BootCDN'),
'cf' => _t('CDNJS'),
'jd' => _t('jsDelivr')),
'bc', _t('公共静态资源来源'), _t('默认BootCDN,请根据需求选择合适来源'));
array('sc' => _t('Staticfile'),
'bc' => _t('BootCDN'),
'jd' => _t('jsDelivr'),
'cf' => _t('CDNJS')),
'sc', _t('公共静态资源来源'), _t('默认Staticfile,请根据需求选择合适来源'));
$form->addInput($cjCDN);

$GravatarUrl = new Typecho_Widget_Helper_Form_Element_Radio('GravatarUrl',
Expand Down Expand Up @@ -98,6 +106,13 @@ function themeConfig($form) {
0, _t('Ajax翻页'), _t('默认关闭,启用则会使用Ajax加载文章翻页'));
$form->addInput($AjaxLoad);

$catalog = new Typecho_Widget_Helper_Form_Element_Radio('catalog',
array('post' => _t('使用文章内设定'),
'open' => _t('全部启用'),
0 => _t('全部关闭')),
'post', _t('文章目录'), _t('一键开关全部文章目录,默认使用文章内的设定,(若文章内无任何标题,则不显示目录)'));
$form->addInput($catalog);

$scrollTop = new Typecho_Widget_Helper_Form_Element_Radio('scrollTop',
array(1 => _t('启用'),
0 => _t('关闭')),
Expand Down Expand Up @@ -166,7 +181,7 @@ function themeInit($archive) {
if ($options->AttUrlReplace) {
$archive->content = UrlReplace($archive->content);
}
if ($archive->fields->catalog) {
if ($archive->is('post') && (($options->catalog == 'post' && $archive->fields->catalog) || $options->catalog == 'open')) {
$archive->content = createCatalog($archive->content);
}
}
Expand Down Expand Up @@ -548,8 +563,8 @@ function themeFields($layout) {
$layout->addItem($thumb);

$catalog = new Typecho_Widget_Helper_Form_Element_Radio('catalog',
array(true => _t('启用'),
false => _t('关闭')),
false, _t('文章目录'), _t('默认关闭,启用则会在文章内显示“文章目录”(若文章内无任何标题,则不显示目录)'));
array(1 => _t('启用'),
0 => _t('关闭')),
0, _t('文章目录'), _t('默认关闭,启用则会在文章内显示“文章目录”(若文章内无任何标题,则不显示目录),需要在“控制台-设置外观-文章目录”启用“使用文章内设定”后,方可生效'));
$layout->addItem($catalog);
}
9 changes: 1 addition & 8 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,10 @@
<header id="header">
<div class="container clearfix">
<div class="site-name">
<?php if ($this->options->logoUrl): ?>
<h1>
<a id="logo" href="<?php $this->options->siteUrl(); ?>">
<img src="<?php $this->options->logoUrl() ?>" alt="<?php $this->options->title() ?>" title="<?php $this->options->title() ?>" />
<a id="logo" href="<?php $this->options->siteUrl(); ?>"><?php if ($this->options->logoUrl && ($this->options->titleForm == 'logo' || $this->options->titleForm == 'all')): ?><img src="<?php $this->options->logoUrl() ?>" alt="<?php $this->options->title() ?>" title="<?php $this->options->title() ?>" /><?php endif; ($this->options->titleForm == 'logo' && $this->options->logoUrl) ? '' : ($this->options->customTitle ? $this->options->customTitle() : $this->options->title()) ?>
</a>
</h1>
<?php else: ?>
<h1>
<a id="logo" href="<?php $this->options->siteUrl(); ?>"><?php if ($this->options->customTitle): $this->options->customTitle(); else: $this->options->title(); endif; ?></a>
</h1>
<?php endif; ?>
</div>
<script>function Navswith(){document.getElementById("header").classList.toggle("on")}</script>
<button id="nav-swith" onclick="Navswith()"><span></span></button>
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @package Initial
* @author JIElive
* @version 2.4.4
* @version 2.4.5
* @link http://www.offodd.com/
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
Expand Down
Loading

0 comments on commit d46752d

Please sign in to comment.