MENU

SiteRunningTime插件博客运行时间修改

SiteRunningTime插件启用后,它默认是按照已经运行了

本站已经运行xx年xx月xx日xx时xx分xx秒

这样对于我来说,感觉一点都不好看,我想要的效果是

本站已经运行xx天xx时xx分xx秒

有需求就得该改对吧,程序猿枯计哭晕在厕所了

修改方法

打开插件的那个Plugin.php文件,底部有个Javascript标签,没错,我们就是要改它。
原来的JS代码如下

<script>
    var startTime="$startTime";
    var calculationTime=function(startTime){
    var s1=new Date(startTime.replace(/-/g,"/")),
    s2=new Date(),
    runTime=parseInt((s2.getTime()-s1.getTime())/1000);
    var year=Math.floor(runTime/86400/365);
    runTime=runTime%(86400*365);
    var month=Math.floor(runTime/86400/30);
    runTime=runTime%(86400*30);
    var day=Math.floor(runTime/86400);
    runTime=runTime%86400;
    var hour=Math.floor(runTime/3600);
    runTime=runTime%3600;
    var minute=Math.floor(runTime/60);
    runTime=runTime%60;
    var second=runTime;
    document.querySelector(".SiteRunningTime > .year").innerText=year;
    document.querySelector(".SiteRunningTime > .month").innerText=month;
    document.querySelector(".SiteRunningTime > .day").innerText=day;
    document.querySelector(".SiteRunningTime > .hour").innerText=hour;
    document.querySelector(".SiteRunningTime > .minute").innerText=minute;
    document.querySelector(".SiteRunningTime > .second").innerText=second};
    setInterval("calculationTime(startTime)",1000);
    var node = document.createElement("span");
    node.innerHTML = '本站运行了<label class="year"></label><label class="month">0</label>月<label class="day">0</label>日<label class="hour">0</label>时<label class="minute">0</label>分<label class="second">0</label>秒';node.className = "SiteRunningTime";
    document.getElementById("footer").appendChild(node);
</script>

现在这段代码改为如下

<script>
    var startTime="$startTime";
    var calculationTime=function(startTime){
    var s1=new Date(startTime.replace(/-/g,"/")),
    s2=new Date(),
    runTime=parseInt((s2.getTime()-s1.getTime())/1000);
        var day=Math.floor(runTime/86400);
        runTime = runTime%86400;
        var hour=Math.floor(runTime/3600);
        runTime = runTime%3600;
        var minute=Math.floor(runTime/60);
        var second=runTime%60;
        document.querySelector(".SiteRunningTime > .day").innerText=day;
        document.querySelector(".SiteRunningTime > .hour").innerText=hour;
        document.querySelector(".SiteRunningTime > .minute").innerText=minute;
        document.querySelector(".SiteRunningTime > .second").innerText=second};
        setInterval("calculationTime(startTime)",1000);
        var node = document.createElement("span");
        node.innerHTML = '本站运行了<label class="day">0</label>天<label class="hour">0</label>时<label class="minute">0</label>分<label class="second">0</label>秒';
        node.className = "SiteRunningTime";
        document.getElementById("footer").appendChild(node);
</script>

效果看本站的底部啦。

标签: 博客
返回文章列表 文章二维码 打赏
本页链接的二维码
打赏二维码