当前位置: 首页 > wordpress > 正文
avatar

无意观看别人的博客看到这款不错的小工具,花了少许时间下载了CSS和JS 第一步,新建CSS文件并取名main. […]

无意观看别人的博客看到这款不错的小工具,花了少许时间下载了CSS和JS

第一步,新建CSS文件并取名main.css代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@charset "utf-8";
/*
For: 问候和电子钟
Author: 红尘泪博客
Author Email: nygzs@qq.com
Author URL: http://www.nygzs.cn
*/

#hitimer_box{margin:.5em 0 1px;border:1px #ccc double;padding:.8em .5em;}
#hitimer_from,#hitimer_count{font-size:1.2em;font-weight:bold;margin:0 3px;}
#hitimer_clock,#hitimer_clock .datimer{width:100%;margin:0;padding:0;}
#hitimer_clock .datimer{margin:0;border:none;color:#000;font-size:12px;font-

family:verdana;border-collapse:collapse;background-color:#ccc;}
#hitimer_clock .datimer td{line-height:150%;text-align:center;border:#dedede 1px

solid;padding:9px 0;}
#hitimer_clock .datimer td b{font-size:14px;}
#hitimer_clock td.toptime{font-size:32px;padding:4px 0;}
#hitimer_clock .ampm{font-size:14px}

第二步,新建JS文件并取名main.js代码如下:

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
For: 问候和电子钟
Author:红尘泪博客
Author Email: nygzs@qq.com
Author URL: http://www.nygzs.cn
*/

document.writeln('
<div id="hitimer_box">欢迎<span id="hitimer_from">外星球</span>的朋友,这是您第<span id="hitimer_count">N</span>次到访本站。</div>
<div id="hitimer_clock"></div>
');
//AREA
var ht_jsload={head:document.getElementsByTagName("body")[0]||document.documentElement,Myload:function(B,A){this.done=false;B.onload=B.onreadystatechange=function(){if(!this.done&amp;&amp;(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){this.done=true;A();B.onload=B.onreadystatechange=null;if(this.head&amp;&amp;B.parentNode){this.head.removeChild(B)}}}},getScript:function(A,C){var B=function(){};if(C!=undefined){B=C}var D=document.createElement("script");D.setAttribute("type","text/javascript");D.setAttribute("src",A);this.head.appendChild(D);this.Myload(D,B)}}
ht_jsload.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function () {
if(remote_ip_info.city==remote_ip_info.province) remote_ip_info.province="";
document.getElementById("hitimer_from").innerText=remote_ip_info.province+remote_ip_info.city
});
//COUNT
var ht_caution = false;
function ht_setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "")
if (!ht_caution || (name + "=" + escape(value)).length &lt;= 4000) document.cookie = curCookie; else if (confirm("Cookie exceeds 4KB and will be cut!")) document.cookie = curCookie; } function ht_getCookie(name) { var prefix = name + "="; var cookieStartIndex = document.cookie.indexOf(prefix); if (cookieStartIndex == -1) return null; var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length); if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length; return (document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex)); } function ht_fixDate(date) { var base = new Date(0); var skew = base.getTime(); if (skew &gt; 0) date.setTime(date.getTime() - skew);
}
(function(){
var now = new Date();
ht_fixDate(now);
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
var visits = ht_getCookie("ht_counter");
if (!visits) visits = 1;
else visits = parseInt(visits) + 1;
ht_setCookie("ht_counter", visits, now, "/");
document.getElementById("hitimer_count").innerText=visits;
})();
//TIME
function ht_time(){
var today = new Date();
var hrs = today.getHours();
var min = today.getMinutes();
var secs = today.getSeconds();
var alsohrs = today.getHours();
var dayNumber = today.getDate();
var year = today.getFullYear();
var ampm="", zero="0";
var month = today.getMonth();
var weekday = today.getDay();
var wdn = ["SUN","MON","TUE","WED","THU","FRI","SAT"];
var mn = ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"];
if (min&lt;10) min=zero+min;
if (secs&lt;10) secs=zero+secs; if (hrs&gt;12) hrs=eval(hrs - 12);
if (hrs&gt;=0 &amp;&amp; hrs&lt;1) hrs=12; if (alsohrs&gt;=12 &amp;&amp; alsohrs&lt;24){
ampm="P.M.";
}else{
ampm="A.M.";
}
tmp='
<div>

';
tmp+='

</div>
<div>

';
tmp+='

</div>
<div>

';
tmp+='

</div>
<table class="datimer">
<tbody>
<tr>
<td class="toptime" colspan="4">';
tmp+=hrs+'<span id="blinker">:</span>'+min;
tmp+='<span class="ampm"> '+ampm+'</span>';
tmp+='</td>
<td>Month
<b>'+mn[month]+'</b></td>
<td>Date
<b>'+dayNumber+'</b></td>
<td>Day
<b>'+wdn[weekday]+'</b></td>
<td>Year
<b>'+year+'</b></td>
</tr>
</tbody>
</table>
';
document.getElementById("hitimer_clock").innerHTML=tmp;
clocktime=setTimeout("ht_time()","1000");
}
function ht_blink(){
var obj = document.getElementById("blinker");
if (obj.style.visibility == "visible"){
obj.style.visibility="hidden";
}else{
obj.style.visibility="visible";
}
eachsecond=setTimeout("ht_blink()","500");
}
ht_time();
ht_blink();

第三步,在需要显示的地方调用下面代码:

1
<div>似水流年<script type="text/javascript">document.writeln(unescape("%3Cscript src=\"<?php bloginfo('template_directory'); ?>/main.js\" type=\"text/javascript\"%3E%3C/script%3E"));</script></div>

至于那些懒得动的朋友可以下载本博客提供的源文件:

问候和电子钟
文件名称:
分类目录:资源分享
更新时间:2016-12-12
下载地址:百度网盘
分享:
---------WwW.13qing.com---------
猜你也喜欢的:

wordpress边栏问候和电子钟:目前有2 条评论

  1. avatar
    板凳
    Jane博客

    为什么不显示真实地址,而是现实来自外星的朋友呢?

    2018-08-10「来自:贵州省六盘水市 联通 的朋友」下午3:30 [回复]
  2. 感谢分享

    2016-12-13「来自:湖北省武汉市 电信 的朋友」下午10:03 [回复]

发表评论