分类 web 下的文章

来自:用户不在当前标签页面改变title

实现代码

简单有效,将整个窗口绑定onblur和onfocus。
全选复制放进笔记

window.onblur = function() { document.title = "(●—●)";
}; window.onfocus = function() { document.title = "啦啦啦啦";
}

浏览器兼容性

目前主流的标准浏览器基本都已经支持,部门旧版浏览器需要增加内核前缀,IE从10开始支持。

常见应用场景

幻灯片播放时可在不可见时停止播放,恢复显示后继续播放
每隔一段时间向服务器请求数据的可在切换可见性时停止,减轻服务器负担
网站访问统计提供跟准确的数据
网站title根据可见性变换

例如在typecho主题里footer.php里添加

<script>
window.onblur = function() {
    document.title = "你在看什么呢?";
window.onfocus = function() {
    document.title = "<?php $this->archiveTitle(array(
            'category'  =>  _t('分类 %s 下的文章'),
            'search'    =>  _t('包含关键字 %s 的文章'),
            'tag'       =>  _t('标签 %s 下的文章'),
            'author'    =>  _t('%s 发布的文章')
        ), '', ' - '); ?><?php $this->options->title(); ?>";
    }
};
</script>

另一个版本在http://blog.iplayloli.com/看到的

<script>
        var changeTitle = {
    originTitle: document.title,
    change: function() {
        document.title = " 草榴社區 - t66y.com ";
    },
    reset: function() {
        document.title = changeTitle.originTitle;
    }
};
document.addEventListener('visibilitychange', function() {
    if (document.hidden) {
        changeTitle.change();
    } else {
        changeTitle.reset();
    }
});
</script>

chrome下右键“查看网页源代码”,就会看到

<script>
window.onblur = function() {
    document.title = "你在看什么呢?";
window.onfocus = function() {
    document.title = "用户不在当前标签页面改变title - 52M";
    }
};
</script>

实际效果可以在不同窗口下切换就看到




来自 http://www.tabyouto.com/fixed-sidebar-with-jquery.html
现在很多主题都集成了用Jquery将侧边栏随滚动条固定在屏幕一侧的功能,提高体验度的同时放个小广告也是不错的选择,现在不用插件也可以实现,不用羡慕那些高大上的收费主题,她们有的我们也可以。

CDN引用安装JQuery:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script> <!--Google-->
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script> <!--Microsoft-->

侧边栏滚动结束时固定设定模块

这个代码可以自动获取侧边栏高度,当侧边栏滚动结束后,设定的模块激活并固定在屏幕中,IE6无效。
默认支持两个模块,如果需要增加模块要在第二行添加变量并参照第8行的代码为新变量添加启动的参数。

jQuery(document).ready(function (a) {
        var c = 1,d = 2; //这里设定的是第1和第2
        a.browser.msie && 6 == a.browser.version && !a.support.style || (
        e = a("#sidebar").width(), f = a("#sidebar .widget"), g = f.length, g >= (c > 0) && g >= (d > 0) && a(window).scroll(function () {
                        var b = document.documentElement.scrollTop + document.body.scrollTop;
                        b > f.eq(g - 1).offset().top + f.eq(g - 1).height() ? 0 == a(".roller").length ? (f.parent().append(''), f.eq(c - 1).clone().appendTo(".roller"), c !== d && f.eq(d - 1).clone().appendTo(".roller"), a(".roller").css({ position: "fixed", top: 50, zIndex: 0, width: 250 }), a(".roller").width(e)) : a(".roller").fadeIn(300) : a(".roller").fadeOut(300) })) });

滚动到指定模块时置顶该模块

这串代码适合侧边栏较长的用户,如有JavaScript加载的模块高度会判断出错,建议侧边栏没有JavaScript模块的用户使用。
当滚到 #suggested 时置顶该模块,可以按自己的需要修改。

jQuery(document).ready(function($) {
    $.fn.smartFloat = function() {
        var position = function(element) {
            var top = element.position().top,
            pos = element.css("position");
            $(window).scroll(function() {
                var scrolls = $(this).scrollTop();
                if (scrolls > top) {
                    if (window.XMLHttpRequest) {
                        element.css({
                            position: "fixed",
                            top: 0
                        });
                    } else {
                        element.css({
                            top: scrolls
                        });
                    }
                } else {
                    element.css({
                        position: "absolute",
                        top: top
                    });
                }
            });
        };
        return $(this).each(function() {
            position($(this));
        });
    };
    //绑定,将引号中的内容替换成你想要下拉的模块的ID或者CLASS名字,如"#ABC",".ABC"
    $("#suggested").smartFloat();
});

滚动到一定像素后固定显示

通过设定固定的高度,卷动到该高度时显示置顶的模块。默认给出的是卷动368像素后侧边栏 #sidebar 整体跟随滑动,适合侧边栏少的网站。

var documentHeight = 0;
var topPadding = 15;
$(function() {
    var offset = $("#sidebar").offset();
    documentHeight = $(document).height();
    $(window).scroll(function() {
        var sideBarHeight = $("#sidebar").height();
        if ($(window).scrollTop() > offset.top) {
            var newPosition = ($(window).scrollTop() - offset.top) + topPadding;
            var maxPosition = documentHeight - (sideBarHeight + 368);
            if (newPosition > maxPosition) {
                newPosition = maxPosition;
            }
            $("#sidebar").stop().animate({
                marginTop: newPosition
            });
        } else {
            $("#sidebar").stop().animate({
                marginTop: 0
            });
        };
    });
});

来自 http://www.zzhck.com/491.html

效果如下:
1
实现这个功能需要修改主题的footer.php和css文件

在footer.php中,你想让出现的位置(左侧,中间,右侧)添加如下代码

<!--站点统计开始-->
<span class="btn-primary web-sta"><i class="icon-map-marker icon-white icon12"></i> 站内统计</span>      
<div class="statistics">
<h3>站内统计</h3>
<ul>
<li>建站日期:2014-07-31</li>
<li>运行天数:<?php echo floor((time()-strtotime("2014-07-31"))/86400); ?> 天</li>
<li>分类总数:<?php echo $count_categories = wp_count_terms('category'); ?> 个</li>
<li>日志总数:<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish;?> 篇</li>
<li>标签数量:<?php echo $count_tags = wp_count_terms('post_tag'); ?> 个</li>
<li>评论总数:<?php echo $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments");?> 条</li>
<li>链接数量:<?php $link = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = 'Y'"); echo $link; ?> 个</li>
<li>最后更新:<?php $last = $wpdb->get_results("SELECT MAX(post_modified) AS MAX_m FROM $wpdb->posts WHERE (post_type = 'post' OR post_type = 'page') AND (post_status = 'publish' OR post_status = 'private')");$last = date('Y-n-j', strtotime($last[0]->MAX_m));echo $last; ?></li>
</ul>
</div>
<script type="text/javascript">
$(".footer-inner span.web-sta").hover(function(){
    $(".footer-inner .statistics").slideDown("slow");
},function(){
    $(".footer-inner .statistics").slideUp("slow");
});
</script>
<!--站点统计结束-->

然后修改主题的css文件,增加如下代码

/* 底部站点统计 */
span.web-sta{display:inline-block;height:22px;line-height:22px;padding:0 5px;margin:auto 0px auto 5px;cursor:pointer}
.footer .statistics{max-width:360px;border:1px solid #ddd;border-left:0;position:absolute;top:-156px;right:-1px;font-size:12px;background-color:#444;cursor:pointer;display:none}
.footer .statistics h3{border:0;border-bottom:1px dashed #ff8540;font-size:16px;height:25px;line-height:25px;padding:0px 20px 8px;text-align:left}
.footer .statistics ul{padding:5px 8px;position:relative}
.footer .statistics ul li{min-width:150px;display:inline-block;margin-left:10px;margin-bottom:5px}
.footer .statistics ul li:hover{background-color:#eee}

最后再次感谢王海达老师,他教会了我很多,自己动手,用心学习,前端代码没有秘密可言


来自 http://www.zzhck.com/617.html
相信很多人用了wordpress后都会选择去掉链接中的category,以前比较完美的方法是使用WP No Category Base之类的插件,使用插件有个好处就是301重定向,本站也正在使用Remove Category URL插件!但是插件多了,确实会影响一部分运行速度,比较占用内存和CPU!最近在各种折腾,能用代码的,尽量不用插件!感谢前辈们的分享精神,找到一种效果和WP No Category Base插件一样的代码,再次做个记录,也分享给大家!

将以下代码加在主题目录的functions.php(记住半角和?>前面
add_action('load-themes.php', 'no_category_base_refresh_rules');
// WordPress免插件去除链接categroy
register_activation_hook(__FILE__, 'no_category_base_refresh_rules');
add_action('created_category', 'no_category_base_refresh_rules');
add_action('edited_category', 'no_category_base_refresh_rules');
add_action('delete_category', 'no_category_base_refresh_rules');
function no_category_base_refresh_rules() {
 global $wp_rewrite;
 $wp_rewrite -> flush_rules();
}
register_deactivation_hook(__FILE__, 'no_category_base_deactivate');
function no_category_base_deactivate() {
 remove_filter('category_rewrite_rules', 'no_category_base_rewrite_rules');
 // We don't want to insert our custom rules again
 no_category_base_refresh_rules();
}
// Remove category base
add_action('init', 'no_category_base_permastruct');
function no_category_base_permastruct() {
 global $wp_rewrite, $wp_version;
 if (version_compare($wp_version, '3.4', '<')) {
 // For pre-3.4 support
 $wp_rewrite -> extra_permastructs['category'][0] = '%category%';
 } else {
 $wp_rewrite -> extra_permastructs['category']['struct'] = '%category%';
 }
}
// Add our custom category rewrite rules
add_filter('category_rewrite_rules', 'no_category_base_rewrite_rules');
function no_category_base_rewrite_rules($category_rewrite) {
 //var_dump($category_rewrite); // For Debugging
 $category_rewrite = array();
 $categories = get_categories(array('hide_empty' => false));
 foreach ($categories as $category) {
 $category_nicename = $category -> slug;
 if ($category -> parent == $category -> cat_ID)// recursive recursion
 $category -> parent = 0;
 elseif ($category -> parent != 0)
 $category_nicename = get_category_parents($category -> parent, false, '/', true) . $category_nicename;
 $category_rewrite['(' . $category_nicename . ')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?category_name=$matches[1]&feed=$matches[2]';
 $category_rewrite['(' . $category_nicename . ')/page/?([0-9]{1,})/?$'] = 'index.php?category_name=$matches[1]&paged=$matches[2]';
 $category_rewrite['(' . $category_nicename . ')/?$'] = 'index.php?category_name=$matches[1]';
 }
 // Redirect support from Old Category Base
 global $wp_rewrite;
 $old_category_base = get_option('category_base') ? get_option('category_base') : 'category';
 $old_category_base = trim($old_category_base, '/');
 $category_rewrite[$old_category_base . '/(.*)$'] = 'index.php?category_redirect=$matches[1]';
 
 //var_dump($category_rewrite); // For Debugging
 return $category_rewrite;
}
// Add 'category_redirect' query variable
add_filter('query_vars', 'no_category_base_query_vars');
function no_category_base_query_vars($public_query_vars) {
 $public_query_vars[] = 'category_redirect';
 return $public_query_vars;
}
// Redirect if 'category_redirect' is set
add_filter('request', 'no_category_base_request');
function no_category_base_request($query_vars) {
 //print_r($query_vars); // For Debugging
 if (isset($query_vars['category_redirect'])) {
 $catlink = trailingslashit(get_option('home')) . user_trailingslashit($query_vars['category_redirect'], 'category');
 status_header(301);
 header("Location: $catlink");
 exit();
 }
 return $query_vars;
}
注意事项

如果你已经在用WP No Category Base之类插件的话就别用以上方法了,那个插件用了一次的话就必须得一直用下去;
不然文章页会无法访问,当然你也可以想办法把这个插件彻底卸载了,再用上面的方法!
还有就是把WP No Category Base之类的插件关闭自然也是没用的….切记!!!

关闭No Category之类的插件更换代码的方法:

1.把【固定连接】改为【默认】状态,然后,关闭【WP NO category base】插件
2.再改回之前的URL形式就可以了。
3.最后你就可卸载掉该插件了。


流动公告主要用到的是marquee元素实现的,详细的介绍大家自己百度
下面分享一下我现在用的流动公告代码,效果顶部自己预览

<marquee width="1000px" height="16px" direction="left" scrollamount="3" scrolldelay="5" onmouseover="this.stop()" onmouseout="this.start()">
<span style="color: #0000ff;">贰月叁拾</span>——<span style="color: #ff0000;">欢迎您的到来,期待您能够有所收获!有问题请<a title="留言板" href="http://www.zzhck.com/liuyan">点击这里</a>,给我留言吧!</span></marquee>

复制修改后,直接粘贴到d8主题设置的最新消息里,保存!好了,一切搞定,同样这串代码也可以用在其他地方了,希望大家活学活用!
来自 http://www.zzhck.com/338.html


来自 http://www.zzhck.com/796.html

代码是年前林子分享给我的,非常感谢他!
然后我...

新版轮播代码特点:

1.支持自适应大小
2.可以鼠标选择想看那一张
3.当然你也可以加上超级链接
4.更加简洁易用

详细代码如下,大家可以添加到d8主题设置的导航下方广告位

<style type="text/css">
body{min-width:320px;background-color:#f6f7f7;}
a,img{border:0;}
.index_banner{position:relative;height: auto}
.index_banner ul{overflow:hidden;}
.index_banner li{position:absolute;top:0;left:0;overflow:hidden;width:100%;height:350px;}
.index_banner li a{display:block;margin:0 auto;}
.index_banner cite{position:absolute;bottom:10px;left:50%;z-index:999;display:block;margin-left:-144px;width:288px;height:15px;_display:none;}
.index_banner cite span{float:left;display:block;margin:0 4px;width:40px;height:8px;background-color:#e5e5e5;text-indent:-999em;opacity:.8;cursor:pointer;}
.index_banner cite span:hover{background-color:#f5f5f5;}
.index_banner cite span.cur{background-color:#1d8bd8;cursor:default;}
.clear{clear:both;}
</style>
 
<!-- div -->
<div class="index_banner" id="banner_tabs">
    <ul>
        <li><img src="http://www.zzhck.com/static/img/1.jpg" alt="贰月叁拾" width="100%"></li>
        <li><img src="http://www.zzhck.com/static/img/2.jpg" alt="贰月叁拾" width="100%"></li>      
        <li><img src="http://www.zzhck.com/static/img/3.jpg" alt="贰月叁拾" width="100%"></li>    
        <li><img src="http://www.zzhck.com/static/img/4.jpg" alt="贰月叁拾" width="100%"></li>
        <li><img src="http://www.zzhck.com/static/img/5.jpg" alt="贰月叁拾" width="100%"></li>        
    </ul>
    <!--此处的img是用来占位的,在实际使用中,可以另外制作一张全空的图片-->
    <img style="visibility:hidden;" src="http://www.zzhck.com/static/img/0.png" alt="贰月叁拾" width="100%">
    <cite>
        <span class="cur">1</span>
        <span>2</span>
        <span>3</span>
        <span>4</span>
        <span>5</span>        
    </cite>
    <div class="clear"></div>
</div>
<!-- 下JS -->
<script type="text/javascript">
(function(){
    if(!Function.prototype.bind){
        Function.prototype.bind = function(obj){
            var owner = this,args = Array.prototype.slice.call(arguments),callobj = Array.prototype.shift.call(args);
            return function(e){e=e||top.window.event||window.event;owner.apply(callobj,args.concat([e]));};
        };
    }
})();
var banner_tabs = function(id){
    this.ctn = document.getElementById(id);
    this.adLis = null;
    this.btns = null;
    this.animStep = 0.2;//动画速度0.1~0.9
    this.switchSpeed = 3;//自动播放间隔(s)
    this.defOpacity = 1;
    this.tmpOpacity = 1;
    this.crtIndex = 0;
    this.crtLi = null;
    this.adLength = 0;
    this.timerAnim = null;
    this.timerSwitch = null;
    this.init();
};
banner_tabs.prototype = {
    fnAnim:function(toIndex){
        if(this.timerAnim){window.clearTimeout(this.timerAnim);}
        if(this.tmpOpacity <= 0){
            this.crtLi.style.opacity = this.tmpOpacity = this.defOpacity;
            this.crtLi.style.filter = 'Alpha(Opacity=' + this.defOpacity*100 + ')';
            this.crtLi.style.zIndex = 0;
            this.crtIndex = toIndex;
            return;
        }
        this.crtLi.style.opacity = this.tmpOpacity = this.tmpOpacity - this.animStep;
        this.crtLi.style.filter = 'Alpha(Opacity=' + this.tmpOpacity*100 + ')';
        this.timerAnim = window.setTimeout(this.fnAnim.bind(this,toIndex),50);
    },
    fnNextIndex:function(){
        return (this.crtIndex >= this.adLength-1)?0:this.crtIndex+1;
    },
    fnSwitch:function(toIndex){
        if(this.crtIndex==toIndex){return;}
        this.crtLi = this.adLis[this.crtIndex];
        for(var i=0;i<this.adLength;i++){
            this.adLis[i].style.zIndex = 0;
        }
        this.crtLi.style.zIndex = 2;
        this.adLis[toIndex].style.zIndex = 1;
        for(var i=0;i<this.adLength;i++){
            this.btns[i].className = '';
        }
        this.btns[toIndex].className = 'cur'
        this.fnAnim(toIndex);
    },
    fnAutoPlay:function(){
        this.fnSwitch(this.fnNextIndex());
    },
    fnPlay:function(){
        this.timerSwitch = window.setInterval(this.fnAutoPlay.bind(this),this.switchSpeed*1000);
    },
    fnStopPlay:function(){
        window.clearTimeout(this.timerSwitch);
    },
    init:function(){
        this.adLis = this.ctn.getElementsByTagName('li');
        this.btns = this.ctn.getElementsByTagName('cite')[0].getElementsByTagName('span');
        this.adLength = this.adLis.length;
        for(var i=0,l=this.btns.length;i<l;i++){
            with({i:i}){
                this.btns[i].index = i;
                this.btns[i].onclick = this.fnSwitch.bind(this,i);
                this.btns[i].onclick = this.fnSwitch.bind(this,i);
            }
        }
        this.adLis[this.crtIndex].style.zIndex = 2;
        this.fnPlay();
        this.ctn.onmouseover = this.fnStopPlay.bind(this);
        this.ctn.onmouseout = this.fnPlay.bind(this);
    }
};
var player1 = new banner_tabs('banner_tabs');
</script>

来自 http://www.zzhck.com/815.html
可最近发表长文章,才发现到d8主题默认分页按钮无效,感觉很是纠结
今天忙完工作,参看了网络上各位前辈的代码,在本地做了各种尝试,发现了昂然前辈的一篇文章,可以完美解决wp主题不带有分页功能的问题
代码来源于:http://www.gaoxing.me/nextpage/
大家追求简洁效果的可以直接去看一下这篇文章,我这里只分享一下美化的代码
1.寻找主题目录中的single.php文件,搜索以下代码:

<?php the_content(); ?>

2.找到后在此行代码之下添加如下代码:

<?php wp_link_pages(array('before' => '<div class="fenye">分页阅读:', 'after' => '',
 'next_or_number' => 'next', 'previouspagelink' => '上一页', 'nextpagelink' => "")); ?>  
 <?php wp_link_pages(array('before' => '', 'after' => '', 'next_or_number' => 'number',
 'link_before' =>'<span>', 'link_after'=>'</span>')); ?>  
 <?php wp_link_pages(array('before' => '', 'after' => '</div>',
 'next_or_number' => 'next', 'previouspagelink' => '', 'nextpagelink' => "下一页")); ?>

3.保存single.php文件,为了让大家看一下分页效果,第四部操作请看下页!
4.打开主题的css文件,一般是style.css文件,在文件的末尾添加如下代码:

.fenye {text-align:center;margin:0px auto 10px;}  
.fenye span {background-color:#C73503;color:#fff;font-weight: bold;
margin:0px 1px;padding:3px 6px;text-decoration:none;border:1px solid #D2D2D2;}  
.fenye a {text-decoration:none;}  
.fenye a span {background-color:#F6F6E8;font-weight: normal;
color: #000;text-decoration: none;}  
.fenye a:hover span {background-color:#c73503;color: #fff;}

好了,一切大功告成,发表新文章时,可以直接用可视化编辑器中的分页按钮或者在文本编辑器中插入:

<!--nextpage-->

来实现分页功能,大家可以扩展一下,自己也在文本编辑器上也添加一个按钮!


来自 http://www.zzhck.com/870.html
1
2
代码来自于:开溜网 http://www.kailiuwang.net/wordpress-download-style-share.html
1.css样式代码:

div#download          
{         
    background: url(images/download.png) no-repeat;          
    height:79px;         
    margin:25px 5px 15px 25px;         
    border:solid 1px white;         
    list-style-type:none;         
    width:700px;         
}         
div#download ul          
{         
    list-style: none outside none;         
    margin: 0;         
    padding: 0;         
    width: 10000px;         
    list-style-type:none;         
}         
div#downloadline         
{         
    overflow: hidden;         
    border-left: 1px solid #CDCDCD;         
    width:500px;         
    height:75px;         
    margin-top:2px;         
    margin-left:120px;         
}         
div#download li{margin:0;padding:0;float: left;margin-right:-27px;margin-right:0 \9;}         
div#download li a          
{         
    border-right: 1px solid #CDCDCD;         
    color: #0093DC;         
    text-decoration: none;         
    display: block;         
    float: left;         
    font-size: 16px;         
    font-weight: 700;         
    height: 80px;         
    line-height: 80px;         
    padding-right:10px;         
    font-family: "Microsoft Yahei",微软雅黑,"Segoe UI",Calibri,"Myriad Pro",Myriad,"Trebuchet MS",Helvetica,Arial,sans-serif;         
    overflow:hidden;         
    text-indent:40px;         
}              
div#download li a:hover          
{         
    color: red;         
}             
div#download li a.down         
{         
    background: url(images/custom/download_for_windows_h.gif) no-repeat 5px 22px;            
}              
div#download li a.down:hover         
{         
    background: url(images/custom/download_for_windows.gif) no-repeat 5px 22px;          
}            
div#download li a.down_mac         
{         
    background: url(images/custom/download_for_mac_h.gif) no-repeat 5px 22px;         
}             
div#download li a.down_mac:hover         
{         
    background: url(images/custom/download_for_mac.gif) no-repeat 5px 22px;          
}           
div#download li a.down_linux         
{         
    background: url(images/custom/download_for_linux_h.gif) no-repeat 5px 22px;          
}              
div#download li a.down_linux:hover         
{         
    background: url(images/custom/download_for_linux.gif) no-repeat 5px 22px;          
}              
div#download li a.demo         
{         
    background: url(images/custom/google_custom_search_h.gif) no-repeat 5px 22px;            
}            
div#download li a.demo:hover         
{         
    background: url(images/custom/google_custom_search.gif) no-repeat 5px 22px;          
}

2.使用方法

在发表日志时,选择文本编辑器调用,当然你也可以进一步改成短代码,代码中的下载地址至少保留一个

<div id="download">   
<div id="downloadline">   
<ul>   
     <li><a class="demo" href="http://kailiuwang.net" target="_blank">在线下载</a></li>   
     <li><a class="down_mac" href="http://kailiuwang.net" target="_blank">115网盘</a></li>   
     <li><a class="down_linux" href="http://kailiuwang.net" target="_blank">百度网盘</a></li>   
     <li><a class="down" href="http://kailiuwang.net" target="_blank">千易网盘</a></li>   
</ul>   
</div>   
</div>

3.下载样式所用到的图片

下载下方的压缩包文件,将压缩包中的背景图片download.PNG放入主题的images文件夹中,然后将压缩包中的 custom文件夹 放入images文件夹中。喜欢折腾的朋友可以把css中的图片的路径根据自己的实际需求进行更改!
下载地址:

这个用typecho







来自 http://www.zzhck.com/535.html

代码

<script type="text/javascript" language="javascript">
(function() {
function k(a, b, c) {
if (a.addEventListener) a.addEventListener(b, c, false);
else a.attachEvent && a.attachEvent("on" + b, c)
}
function g(a) {
if (typeof window.onload != "function") window.onload = a;
else {
var b = window.onload;
window.onload = function() {
b();
a()
}
}
}
function h() {
var a = {};
for (type in {
Top: "",
Left: ""
}) {
var b = type == "Top" ? "Y": "X";
if (typeof window["page" + b + "Offset"] != "undefined")
a[type.toLowerCase()] = window["page" + b + "Offset"];
else {
b = document.documentElement.clientHeight ? document.documentElement: document.body;
a[type.toLowerCase()] = b["scroll" + type]
}
}
return a
}
function l() {
var a = document.body,
b;
if (window.innerHeight) b = window.innerHeight;
else if (a.parentElement.clientHeight) b = a.parentElement.clientHeight;
else if (a && a.clientHeight) b = a.clientHeight;
return b
}
function i(a) {
this.parent = document.body;
this.createEl(this.parent, a);
this.size = Math.random() * 5 + 5;
this.el.style.width = Math.round(this.size) + "px";
this.el.style.height = Math.round(this.size) + "px";
this.maxLeft = document.body.offsetWidth - this.size;
this.maxTop = document.body.offsetHeight - this.size;
this.left = Math.random() * this.maxLeft;
this.top = h().top + 1;
this.angle = 1.4 + 0.2 * Math.random();
this.minAngle = 1.4;
this.maxAngle = 1.6;
this.angleDelta = 0.01 * Math.random();
this.speed = 2 + Math.random()
}
var j = false;
g(function() {
j = true
});
var f = true;
window.createSnow = function(a, b) {
if (j) {
var c = [],
m = setInterval(function() {
f && b > c.length && Math.random()
< b * 0.0025 && c.push(new i(a)); ! f && !c.length && clearInterval(m);
for (var e = h().top, n = l(), d = c.length - 1; d >= 0; d--)
if (c[d]) if (c[d].top < e || c[d].top + c[d].size + 1 > e + n) {
c[d].remove();
c[d] = null;
c.splice(d, 1)
} else {
c[d].move();
c[d].draw()
}
},
40);
k(window, "scroll",
function() {
for (var e = c.length - 1; e >= 0; e--) c[e].draw()
})
} else g(function() {
createSnow(a, b)
})
};
window.removeSnow = function() {
f = false
};
i.prototype = {
createEl: function(a, b) {
this.el = document.createElement("img");
this.el.setAttribute
("src", b + "雪花图片的绝对链接地址");
this.el.style.position = "absolute";
this.el.style.display = "block";
this.el.style.zIndex = "99999";
this.parent.appendChild(this.el)
},
move: function() {
if (this.angle < this.minAngle || this.angle > this.maxAngle)
this.angleDelta = -this.angleDelta;
this.angle += this.angleDelta;
this.left += this.speed * Math.cos(this.angle * Math.PI);
this.top -= this.speed * Math.sin(this.angle * Math.PI);
if (this.left < 0) this.left = this.maxLeft;
else if (this.left > this.maxLeft) this.left = 0
},
draw: function() {
this.el.style.top = Math.round(this.top) + "px";
this.el.style.left = Math.round(this.left) + "px"
},
remove: function() {
this.parent.removeChild(this.el);
this.parent = this.el = null
}
}
})();
createSnow("", 40);
</script>
将以上面代码直接复制粘贴到主题中的Header或者Footer文件中,
如果你只想让文章页面显示,那就直接添加到single就可以了。

雪花图片大家可以自己百度搜索,
本站所用的图片是:http://dl.m69w.com/wordpress/snow.png


来自 http://www.xhily.cn/archives/76.html
有木有发现网站一打开上方有一个红色的加载条

一会又没有了 是不是很炫酷啊

今天就教大家怎么弄

其实也是一个大神教的了 可是他的博客关了 就不介绍了

在此 感谢 断青丝大神

代码:

HTML

<script src="2.js"></script>
<link href="2.css" rel="stylesheet" />

Js

(function() {
  var AjaxMonitor, Bar, DocumentMonitor, ElementMonitor, ElementTracker, EventLagMonitor, Evented, Events, NoTargetError, RequestIntercept, SOURCE_KEYS, Scaler, SocketRequestTracker, XHRRequestTracker, animation, avgAmplitude, bar, cancelAnimation, cancelAnimationFrame, defaultOptions, extend, extendNative, getFromDOM, getIntercept, handlePushState, ignoreStack, init, now, options, requestAnimationFrame, result, runAnimation, scalers, shouldTrack, source, sources, uniScaler, _WebSocket, _XDomainRequest, _XMLHttpRequest, _i, _intercept, _len, _pushState, _ref, _ref1, _replaceState,
    __slice = [].slice,
    __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
  defaultOptions = {
    catchupTime: 500,
    initialRate: .03,
    minTime: 500,
    ghostTime: 500,
    maxProgressPerFrame: 10,
    easeFactor: 1.25,
    startOnPageLoad: true,
    restartOnPushState: true,
    restartOnRequestAfter: 500,
    target: 'body',
    elements: {
      checkInterval: 100,
      selectors: ['body']
    },
    eventLag: {
      minSamples: 10,
      sampleCount: 3,
      lagThreshold: 3
    },
    ajax: {
      trackMethods: ['GET'],
      trackWebSockets: false
    }
  };

  now = function() {
    var _ref;
    return (_ref = typeof performance !== "undefined" && performance !== null ? typeof performance.now === "function" ? performance.now() : void  : void 0) != null ? _ref : +(new Date);
  };

  requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;

  cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame;

  if (requestAnimationFrame == null) {
    requestAnimationFrame = function(fn) {
      return setTimeout(fn, 50);
    };
    cancelAnimationFrame = function(id) {
      return clearTimeout(id);
    };
  }

  runAnimation = function(fn) {
    var last, tick;
    last = now();
    tick = function() {
      var diff;
      diff = now() - last;
      if (diff >= 33) {
        last = now();
        return fn(diff, function() {
          return requestAnimationFrame(tick);
        });
      } else {
        return setTimeout(tick, 33 - diff);
      }
    };
    return tick();
  };

  result = function() {
    var args, key, obj;
    obj = arguments[

  extend = function() {
    var key, out, source, sources, val, _i, _len;
    out = arguments[], sources = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
    for (_i = 0, _len = sources.length; _i < _len; _i++) {
      source = sources[_i];
      if (source) {
        for (key in source) {
          if (!__hasProp.call(source, key)) continue;
          val = source[key];
          if ((out[key] != null) && typeof out[key] === 'object' && (val != null) && typeof val === 'object') {
            extend(out[key], val);
          } else {
            out[key] = val;
          }
        }
      }
    }
    return out;
  };

  avgAmplitude = function(arr) {
    var count, sum, v, _i, _len;
    sum = count = 0;
    for (_i = 0, _len = arr.length; _i < _len; _i++) {
      v = arr[_i];
      sum += Math.abs(v);
      count++;
    }
    return sum / count;
  };


  getFromDOM = function(key, json) {
    var data, e, el;
    if (key == null) {
      key = 'options';
    }
    if (json == null) {
      json = true;
    }
    el = document.querySelector("[data-pace-" + key + "]");
    if (!el) {
      return;
    }
    data = el.getAttribute("data-pace-" + key);
    if (!json) {
      return data;
    }
    try {
      return JSON.parse(data);
    } catch (_error) {
      e = _error;
      return typeof console !== "undefined" && console !== null ? console.error("Error parsing inline pace options", e) : void 0;
    }
  };

  Evented = (function() {
    function Evented() {}

    Evented.prototype.on = function(event, handler, ctx, once) {
      var _base;
      if (once == null) {
        once = false;
      }

      if (this.bindings == null) {
        this.bindings = {};
      }
      if ((_base = this.bindings)[event] == null) {
        _base[event] = [];
      }
      return this.bindings[event].push({
        handler: handler,
        ctx: ctx,
        once: once
      });
    };

    Evented.prototype.once = function(event, handler, ctx) {
      return this.on(event, handler, ctx, true);
    };

    Evented.prototype.off = function(event, handler) {
      var i, _ref, _results;
      if (((_ref = this.bindings) != null ? _ref[event] : void 0) == null) {
        return;
      }
      if (handler == null) {
        return delete this.bindings[event];
      } else {
        i = 0;
        _results = [];
        while (i < this.bindings[event].length) {
          if (this.bindings[event][i].handler === handler) {
            _results.push(this.bindings[event].splice(i, 1));
          } else {
            _results.push(i++);
          }
        }
        return _results;
      }
    };

    Evented.prototype.trigger = function() {
      var args, ctx, event, handler, i, once, _ref, _ref1, _results;
      event = arguments[], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
      if ((_ref = this.bindings) != null ? _ref[event] : void 0) {
        i = 0;
        _results = [];
        while (i < this.bindings[event].length) {
          _ref1 = this.bindings[event][i], handler = _ref1.handler, ctx = _ref1.ctx, once = _ref1.once;
          handler.apply(ctx != null ? ctx : this, args);
          if (once) {
            _results.push(this.bindings[event].splice(i, 1));
          } else {
            _results.push(i++);
          }
        }
        return _results;
      }
    };


    return Evented;

  })();

  if (window.Pace == null) {
    window.Pace = {};
  }

  extend(Pace, Evented.prototype);

  options = Pace.options = extend({}, defaultOptions, window.paceOptions, getFromDOM());

  _ref = ['ajax', 'document', 'eventLag', 'elements'];
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    source = _ref[_i];
    if (options[source] === true) {
      options[source] = defaultOptions[source];
    }
  }

  NoTargetError = (function(_super) {
    __extends(NoTargetError, _super);

    function NoTargetError() {
      _ref1 = NoTargetError.super.constructor.apply(this, arguments);
      return _ref1;
    }

    return NoTargetError;

  })(Error);

  Bar = (function() {
    function Bar() {
      this.progress = 0;
    }

    Bar.prototype.getElement = function() {
      var targetElement;
      if (this.el == null) {
        targetElement = document.querySelector(options.target);
        if (!targetElement) {
          throw new NoTargetError;
        }
        this.el = document.createElement('div');
        this.el.className = "pace pace-active";
        document.body.className = document.body.className.replace('pace-done', '');
        document.body.className += ' pace-running';
        this.el.innerHTML = '<div class="pace-progress">\n  <div class="pace-progress-inner"></div>\n</div>\n<div class="pace-activity"></div>';
        if (targetElement.firstChild != null) {
          targetElement.insertBefore(this.el, targetElement.firstChild);
        } else {
          targetElement.appendChild(this.el);
        }
      }
      return this.el;
    };

    Bar.prototype.finish = function() {
      var el;
      el = this.getElement();
      el.className = el.className.replace('pace-active', '');
      el.className += ' pace-inactive';
      document.body.className = document.body.className.replace('pace-running', '');
      return document.body.className += ' pace-done';
    };

    Bar.prototype.update = function(prog) {
      this.progress = prog;
      return this.render();
    };

    Bar.prototype.destroy = function() {
      try {
        this.getElement().parentNode.removeChild(this.getElement());
      } catch (_error) {
        NoTargetError = _error;
      }
      return this.el = void 0;
    };

    Bar.prototype.render = function() {
      var el, progressStr;
      if (document.querySelector(options.target) == null) {
        return false;
      }
      el = this.getElement();
      el.children[

    Bar.prototype.done = function() {
      return this.progress >= 100;
    };

    return Bar;

  })();

  Events = (function() {
    function Events() {
      this.bindings = {};
    }

    Events.prototype.trigger = function(name, val) {
      var binding, _j, _len1, _ref2, _results;
      if (this.bindings[name] != null) {
        _ref2 = this.bindings[name];
        _results = [];
        for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
          binding = _ref2[_j];
          _results.push(binding.call(this, val));
        }
        return _results;
      }
    };

    Events.prototype.on = function(name, fn) {
      var _base;
      if ((_base = this.bindings)[name] == null) {
        _base[name] = [];
      }
      return this.bindings[name].push(fn);
    };

    return Events;

  })();

  _XMLHttpRequest = window.XMLHttpRequest;

  _XDomainRequest = window.XDomainRequest;

  _WebSocket = window.WebSocket;

  extendNative = function(to, from) {
    var e, key, val, _results;
    _results = [];
    for (key in from.prototype) {
      try {
        val = from.prototype[key];
        if ((to[key] == null) && typeof val !== 'function') {
          _results.push(to[key] = val);
        } else {
          _results.push(void 0);
        }
      } catch (_error) {

        e = _error;

      }

    }

    return _results;

  };


  ignoreStack = [];


  Pace.ignore = function() {

    var args, fn, ret;

    fn = arguments[


  Pace.track = function() {

    var args, fn, ret;

    fn = arguments[


  shouldTrack = function(method) {

    var _ref2;

    if (method == null) {

      method = 'GET';

    }

    if (ignoreStack[] === 'track') {

      return 'force';

    }

    if (!ignoreStack.length && options.ajax) {

      if (method === 'socket' && options.ajax.trackWebSockets) {

        return true;

      } else if (_ref2 = method.toUpperCase(), __indexOf.call(options.ajax.trackMethods, _ref2) >= 0) {

        return true;

      }

    }

    return false;

  };


  RequestIntercept = (function(_super) {

    __extends(RequestIntercept, _super);


    function RequestIntercept() {

      var monitorXHR,

        _this = this;

      RequestIntercept.super.constructor.apply(this, arguments);

      monitorXHR = function(req) {

        var _open;

        _open = req.open;

        return req.open = function(type, url, async) {

          if (shouldTrack(type)) {

            _this.trigger('request', {

              type: type,

              url: url,

              request: req

            });

          }

          return _open.apply(req, arguments);

        };

      };

      window.XMLHttpRequest = function(flags) {

        var req;

        req = new _XMLHttpRequest(flags);

        monitorXHR(req);

        return req;

      };

      extendNative(window.XMLHttpRequest, _XMLHttpRequest);

      if (_XDomainRequest != null) {

        window.XDomainRequest = function() {

          var req;

          req = new _XDomainRequest;

          monitorXHR(req);

          return req;

        };

        extendNative(window.XDomainRequest, _XDomainRequest);

      }

      if ((_WebSocket != null) && options.ajax.trackWebSockets) {

        window.WebSocket = function(url, protocols) {

          var req;

          req = new _WebSocket(url, protocols);

          if (shouldTrack('socket')) {

            _this.trigger('request', {

              type: 'socket',

              url: url,

              protocols: protocols,

              request: req

            });

          }

          return req;

        };

        extendNative(window.WebSocket, _WebSocket);

      }

    }


    return RequestIntercept;


  })(Events);


  _intercept = null;


  getIntercept = function() {

    if (_intercept == null) {

      _intercept = new RequestIntercept;

    }

    return _intercept;

  };


  getIntercept().on('request', function(_arg) {

    var after, args, request, type;

    type = _arg.type, request = _arg.request;

    if (!Pace.running && (options.restartOnRequestAfter !== false || shouldTrack(type) === 'force')) {

      args = arguments;

      after = options.restartOnRequestAfter || 0;

      if (typeof after === 'boolean') {

        after = 0;

      }

      return setTimeout(function() {

        var stillActive, _j, _len1, _ref2, _ref3, _results;

        if (type === 'socket') {

          stillActive = request.readyState < 2;

        } else {

          stillActive = (0 < (_ref2 = request.readyState) && _ref2 < 4);

        }

        if (stillActive) {

          Pace.restart();

          _ref3 = Pace.sources;

          _results = [];

          for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {

            source = _ref3[_j];

            if (source instanceof AjaxMonitor) {

              source.watch.apply(source, args);

              break;

            } else {

              _results.push(void 0);

            }

          }

          return _results;

        }

      }, after);

    }

  });


  AjaxMonitor = (function() {

    function AjaxMonitor() {

      var _this = this;

      this.elements = [];

      getIntercept().on('request', function() {

        return _this.watch.apply(_this, arguments);

      });

    }


    AjaxMonitor.prototype.watch = function(_arg) {

      var request, tracker, type;

      type = _arg.type, request = _arg.request;

      if (type === 'socket') {

        tracker = new SocketRequestTracker(request);

      } else {

        tracker = new XHRRequestTracker(request);

      }

      return this.elements.push(tracker);

    };


    return AjaxMonitor;


  })();


  XHRRequestTracker = (function() {

    function XHRRequestTracker(request) {

      var event, size, _j, _len1, _onreadystatechange, _ref2,

        _this = this;

      this.progress = 0;

      if (window.ProgressEvent != null) {

        size = null;

        request.addEventListener('progress', function(evt) {

          if (evt.lengthComputable) {

            return _this.progress = 100 * evt.loaded / evt.total;

          } else {

            return _this.progress = _this.progress + (100 - _this.progress) / 2;

          }

        });

        _ref2 = ['load', 'abort', 'timeout', 'error'];

        for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {

          event = _ref2[_j];

          request.addEventListener(event, function() {

            return _this.progress = 100;

          });

        }

      } else {

        _onreadystatechange = request.onreadystatechange;

        request.onreadystatechange = function() {

          var _ref3;

          if ((_ref3 = request.readyState) ===  || _ref3 === 4) {

            _this.progress = 100;

          } else if (request.readyState === 3) {

            _this.progress = 50;

          }

          return typeof _onreadystatechange === "function" ? _onreadystatechange.apply(null, arguments) : void 0;

        };

      }

    }


    return XHRRequestTracker;


  })();


  SocketRequestTracker = (function() {

    function SocketRequestTracker(request) {

      var event, _j, _len1, _ref2,

        _this = this;

      this.progress = 0;

      _ref2 = ['error', 'open'];

      for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {

        event = _ref2[_j];

        request.addEventListener(event, function() {

          return _this.progress = 100;

        });

      }

    }


    return SocketRequestTracker;


  })();


  ElementMonitor = (function() {

    function ElementMonitor(options) {

      var selector, _j, _len1, _ref2;

      if (options == null) {

        options = {};

      }

      this.elements = [];

      if (options.selectors == null) {

        options.selectors = [];

      }

      _ref2 = options.selectors;

      for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {

        selector = _ref2[_j];

        this.elements.push(new ElementTracker(selector));

      }

    }


    return ElementMonitor;


  })();


  ElementTracker = (function() {

    function ElementTracker(selector) {

      this.selector = selector;

      this.progress = 0;

      this.check();

    }


    ElementTracker.prototype.check = function() {

      var _this = this;

      if (document.querySelector(this.selector)) {

        return this.done();

      } else {

        return setTimeout((function() {

          return _this.check();

        }), options.elements.checkInterval);

      }

    };


    ElementTracker.prototype.done = function() {

      return this.progress = 100;

    };


    return ElementTracker;


  })();


  DocumentMonitor = (function() {

    DocumentMonitor.prototype.states = {

      loading: 0,

      interactive: 50,

      complete: 100

    };


    function DocumentMonitor() {

      var _onreadystatechange, _ref2,

        _this = this;

      this.progress = (_ref2 = this.states[document.readyState]) != null ? _ref2 : 100;

      _onreadystatechange = document.onreadystatechange;

      document.onreadystatechange = function() {

        if (_this.states[document.readyState] != null) {

          _this.progress = _this.states[document.readyState];

        }

        return typeof _onreadystatechange === "function" ? _onreadystatechange.apply(null, arguments) : void 0;

      };

    }


    return DocumentMonitor;


  })();


  EventLagMonitor = (function() {

    function EventLagMonitor() {

      var avg, interval, last, points, samples,

        _this = this;

      this.progress = 0;

      avg = 0;

      samples = [];

      points = 0;

      last = now();

      interval = setInterval(function() {

        var diff;

        diff = now() - last - 50;

        last = now();

        samples.push(diff);

        if (samples.length > options.eventLag.sampleCount) {

          samples.shift();

        }

        avg = avgAmplitude(samples);

        if (++points >= options.eventLag.minSamples && avg < options.eventLag.lagThreshold) {

          _this.progress = 100;

          return clearInterval(interval);

        } else {

          return _this.progress = 100 * (3 / (avg + 3));

        }

      }, 50);

    }


    return EventLagMonitor;


  })();


  Scaler = (function() {

    function Scaler(source) {

      this.source = source;

      this.last = this.sinceLastUpdate = 0;

      this.rate = options.initialRate;

      this.catchup = 0;

      this.progress = this.lastProgress = 0;

      if (this.source != null) {

        this.progress = result(this.source, 'progress');

      }

    }


    Scaler.prototype.tick = function(frameTime, val) {

      var scaling;

      if (val == null) {

        val = result(this.source, 'progress');

      }

      if (val >= 100) {

        this.done = true;

      }

      if (val === this.last) {

        this.sinceLastUpdate += frameTime;

      } else {

        if (this.sinceLastUpdate) {

          this.rate = (val - this.last) / this.sinceLastUpdate;

        }

        this.catchup = (val - this.progress) / options.catchupTime;

        this.sinceLastUpdate = 0;

        this.last = val;

      }

      if (val > this.progress) {

        this.progress += this.catchup  frameTime;

      }

      scaling = 1 - Math.pow(this.progress / 100, options.easeFactor);

      this.progress += scaling  this.rate * frameTime;

      this.progress = Math.min(this.lastProgress + options.maxProgressPerFrame, this.progress);

      this.progress = Math.max(0, this.progress);

      this.progress = Math.min(100, this.progress);

      this.lastProgress = this.progress;

      return this.progress;

    };


    return Scaler;


  })();


  sources = null;


  scalers = null;


  bar = null;


  uniScaler = null;


  animation = null;


  cancelAnimation = null;


  Pace.running = false;


  handlePushState = function() {

    if (options.restartOnPushState) {

      return Pace.restart();

    }

  };


  if (window.history.pushState != null) {

    _pushState = window.history.pushState;

    window.history.pushState = function() {

      handlePushState();

      return _pushState.apply(window.history, arguments);

    };

  }


  if (window.history.replaceState != null) {

    _replaceState = window.history.replaceState;

    window.history.replaceState = function() {

      handlePushState();

      return _replaceState.apply(window.history, arguments);

    };

  }


  SOURCE_KEYS = {

    ajax: AjaxMonitor,

    elements: ElementMonitor,

    document: DocumentMonitor,

    eventLag: EventLagMonitor

  };


  (init = function() {

    var type, _j, _k, _len1, _len2, _ref2, _ref3, _ref4;

    Pace.sources = sources = [];

    _ref2 = ['ajax', 'elements', 'document', 'eventLag'];

    for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {

      type = _ref2[_j];

      if (options[type] !== false) {

        sources.push(new SOURCE_KEYStype);

      }

    }

    _ref4 = (_ref3 = options.extraSources) != null ? _ref3 : [];

    for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) {

      source = _ref4[_k];

      sources.push(new source(options));

    }

    Pace.bar = bar = new Bar;

    scalers = [];

    return uniScaler = new Scaler;

  })();


  Pace.stop = function() {

    Pace.trigger('stop');
    Pace.running = false;
    bar.destroy();
    cancelAnimation = true;
    if (animation != null) {
      if (typeof cancelAnimationFrame === "function") {
        cancelAnimationFrame(animation);
      }
      animation = null;
    }
    return init();
  };

  Pace.restart = function() {
    Pace.trigger('restart');
    Pace.stop();
    return Pace.start();
  };

  Pace.go = function() {
    Pace.running = true;
    bar.render();
    cancelAnimation = false;
    return animation = runAnimation(function(frameTime, enqueueNextFrame) {
      var avg, count, done, element, elements, i, j, remaining, scaler, scalerList, start, sum, _j, _k, _len1, _len2, _ref2;
      remaining = 100 - bar.progress;
      count = sum = 0;
      done = true;
      for (i = _j = 0, _len1 = sources.length; _j < _len1; i = ++_j) {
        source = sources[i];
        scalerList = scalers[i] != null ? scalers[i] : scalers[i] = [];
        elements = (_ref2 = source.elements) != null ? _ref2 : [source];
        for (j = _k = 0, _len2 = elements.length; _k < _len2; j = ++_k) {
          element = elements[j];
          scaler = scalerList[j] != null ? scalerList[j] : scalerList[j] = new Scaler(element);
          done &= scaler.done;
          if (scaler.done) {
            continue;
          }
          count++;
          sum += scaler.tick(frameTime);
        }
      }
      avg = sum / count;
      bar.update(uniScaler.tick(frameTime, avg));
      start = now();
      if (bar.done() || done || cancelAnimation) {
        bar.update(100);
        Pace.trigger('done');
        return setTimeout(function() {
          bar.finish();
          Pace.running = false;
          return Pace.trigger('hide');
        }, Math.max(options.ghostTime, Math.min(options.minTime, now() - start)));
      } else {
        return enqueueNextFrame();
      }
    });
  };

  Pace.start = function(_options) {
    extend(options, _options);
    Pace.running = true;
    try {
      bar.render();
    } catch (_error) {
      NoTargetError = _error;
    }
    if (!document.querySelector('.pace')) {
      return setTimeout(Pace.start, 50);
    } else {
      Pace.trigger('start');
      return Pace.go();
    }
  };

  if (typeof define === 'function' && define.amd) {
    define(function() {
      return Pace;
    });
  } else if (typeof exports === 'object') {
    module.exports = Pace;
  } else {
    if (options.startOnPageLoad) {
      Pace.start();
    }
  }
}).call(this);

CSS

.pace {

-webkit-pointer-events:none;

pointer-events:none;

-webkit-user-select:none;

-moz-user-select:none;

user-select:none;

}

.pace-inactive {

display:none;

}

.pace .pace-progress {

background:#d9534f;/ 颜色控制 /

position:fixed;

z-index:2000;/ 长度控制 /

top:0;

left:0;

height:3px;/ 宽度控制 /

-webkit-transition:width 0.1s; / 时间控制 /

-moz-transition:width 0.1s;  / 时间控制 /

-o-transition:width 0.1s; / 时间控制 /

transition:width 0.1s; / 时间控制 /

}

代码托管在 Runjs 上点击提取

这里打包好了的


来自 http://www.xhily.cn/archives/91.html
看到本网站那个超可爱的时间小人没有 是不是很棒

你也可以拥有

只是html+js+swf

<script charset="Shift_JIS" src="http://dl.m69w.com/typecho/1.js"></script>

js

var swfUrl = "http://chabudai.sakura.ne.jp/blogparts/honehoneclock/honehone_clock_tr.swf";
var swfTitle = "honehoneclock";
LoadBlogParts();
function LoadBlogParts(){
    var sUrl = swfUrl;
    var sHtml = "";
    sHtml += '';
    sHtml += '';
    sHtml += '';
    sHtml += '';
    sHtml += '';
    sHtml += '';
    sHtml += '';
    sHtml += '';
    document.write(sHtml);
}

这句话是调用
http://chabudai.sakura.ne.jp/blogparts/honehoneclock/honehone_clock_tr.swf
这个swf的 打开发现 是一个swf 这个js就是调整swf的大小

把js保存 用html调用就可以出来本网站的特效了 放在适当的地方

注意

网站的js 和 swf 随时可能失效 请下载自行使用


来自 http://www.xhily.cn/archives/157.html
bing搜索首页的壁纸都是每日一换(http://cn.bing.com/

想要这种效果其实一段代码就ok

<?php
    $str=file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx=0&n=1');
    if(preg_match("/<url>(.+?)<\/url>/ies",$str,$matches)){
        $imgurl='http://cn.bing.com'.$matches[1];
    }
    if($imgurl){
        header('Content-Type: image/JPEG');
        @ob_end_clean();
        @readfile($imgurl);
        @flush(); @ob_flush();
        exit();
    }else{
        exit('error');
    }
?>

访问 https://m69w.com/demo/bing.php

可以用作背景图片之类的

文章转自http://johnzhang.cn/2015/02/13/get-bing-daily-picture/ 文中代码出错 已经修改

下载地址 bing.7z

Bing 每日图片获取


来自:http://www.xhily.cn/archives/204.html
还在手动输入评论的信息而烦恼吗
这个技巧分分钟解决

对于 wordpressemlogTypechozb-blog 这几类的 原生评论模块 都可以使用

以下是程序代码,把它存到书签里就行了,,遇到要评论的时候点击这个书签即可一键填写:

avascript:var nn='你的呢称',mm='你的邮箱',uu='你的网站';var emname=document.getElementsByName('comname'),emmail=document.getElementsByName('commail'),emurl=document.getElementsByName('comurl'),wpname=document.getElementsByName('author'),wpmail=document.getElementsByName('email'),wpurl=document.getElementsByName('url'),zbname=document.getElementsByName('inpName'),zbmail=document.getElementsByName('inpEmail'),zburl=document.getElementsByName('inpHomePage'),tpmail=document.getElementsByName('mail');if(emname.length>0){emname[0].value=nn;emmail[0].value=mm;emurl[0].value=uu; void(0);}else if(wpmail.length>0){wpname[0].value=nn;wpmail[0].value=mm;wpurl[0].value=uu;void(0);}else if(zbname.length>0){zbname[0].value=nn;zbmail[0].value=mm;zburl[0].value=uu; void(0);}else if(tpmail.length>0){tpmail[0].value=mm;wpname[0].value=nn;wpurl[0].value=uu;void(0);}

把红色部分改成自己的信息就行了

具体教程
1