模板
01
<script language=
"javascript"
type
=
"text/javascript"
>
02
function
postDigg(ftype,aid)
03
{
04
var taget_obj = document.getElementById(
'diggNum'
+aid);
05
06
var saveid = GetCookie(
'diggid'
); //我所有赞过的文章
id
07
//alert(saveid);
08
if
(saveid != null)
09
10
var saveids = saveid.
split
(
','
);
11
var hasid =
false
;
12
saveid =
''
13
j = 1;
14
for
(i=saveids.length-1;i>=0;i--)
15
16
(saveids[i]==aid && hasid)
continue
; //我顶过
17
else
18
(saveids[i]==aid && !hasid) hasid =
true
19
saveid += (saveid==
? saveids[i] :
+saveids[i]);
20
j++;
21
(j==20 && hasid)
break
22
(j==19 && !hasid)
23
}
24
25
(hasid) {
26
//alert(
"您已经顶过该帖,请不要重复顶帖 !"
27
//如果点击后,被赞过.则不需要更新统计,直接改变颜色
28
$(
'#digg'
+aid).addClass(
"icon-heart-on"
29
return
30
31
saveid +=
+aid;
32
SetCookie(
,saveid,1);
33
34
35
36
{ //如果cookie中无记录,则记录
37
,aid,1);
38
39
40
myajax = new DedeAjax(taget_obj,
,
41
var url =
"{dede:global.cfg_phpurl/}/digg_ajax_list.php?action="
+ftype+
"&id="
42
myajax.SendGet2(url);
43
44
DedeXHTTP = null;
45
46
47
</script>
1
{dede:arclist row=
'6'
orderby=
'id'
titlelen=
'100'
2
3
<span
"diggNum[field:id/]"
> <a href=
"javascript:"
class=
" text-bbb text-16"
onclick=
"javascript:postDigg('good',[field:id/])"
><span
"digg[field:id/]"
"icon-heart2 "
> </span> </a>[field:goodpost/]
4
</span>
5
{/dede:arclist}
css
.icon-heart
background
:
url
(../images/bg-main.png)
-22px
5px
no-repeat
2:
hover{
2px
4px
6
7
.icon-heart-on{
8
9
然后在,plus中新建立一个digg_ajax_list.PHP文件,内容为
<?php
require_once
(dirname(
__FILE__
).
"/../include/common.inc.php"
$action
= isset(
) ? trim(
) :
$id
empty
)? 0 :
intval
(preg_replace(
"/[^\d]/"
));
< 1)
exit
();
$maintable
'archives'
==
'good'
)
$dsql
->ExecuteNoneQuery(
"Update `$maintable` set scores = scores + {$cfg_caicai_add},goodpost=goodpost+1,lastpost="
.time().
" where id='$id'"
'bad'
"Update `$maintable` set scores = scores - {$cfg_caicai_sub},badpost=badpost+1,lastpost="
$digg
$row
->GetOne(
"Select goodpost,badpost,scores From `$maintable` where id='$id' "
(!
is_array
))
[
'goodpost'
]+
'badpost'
] == 0)
'goodper'
] =
'badper'
] = 0;
] = number_format(
]/(
]),3)*100;
] = 100-
];
$formurl
'caicai'
] = trim(sprintf(
"%4.2f"
]));
'<a class=" text-bbb text-16"href="javascript:" onclick="javascript:postDigg(\'good\','
.
')"><span =id="digg'
'"class="icon-heart-on"> </span> </a>'
//点击后,如果从没有被赞过,则自动把新的点击次数重写入目标位置.
48
49
AjaxHead();
50
echo
51
52
?>