随笔-文章点击喜欢与不喜欢表情,马上会+1
2014-12-18 15:11
204 查看
***********************************js对象
Cms.upf = function(base, feelingcountid, origValue, upId, type) {
var updown = $.cookie("_cms_up_" + feelingcountid);
if (updown) { //当前cookie是否存在,存在就已经发布过了, 不存在就没有发表
alert("-_- !,您已经发表过了哦~~");
return false;
}
$.cookie("_cms_up_" + feelingcountid, "1");
$.get(base + "/feelingcount_up.jspx", { //数据库+1
"feelingcountid" : feelingcountid,
"type" : type
}, function(data) {
var high = origValue + 1;
var top = 70 - high;
$("#moodc" + upId).html(high);
if(high<70){
$("#moodh" + upId).css("height",high);
$("#moodh" + upId).css("margin-top",top);
}else{
$("#moodh" + upId).css("height",high);
$("#moodh" + upId).css("margin-top",10);
}
});
return true;
};
************************************页面加载就查找库,当前文章的开心数
$.ajax({
type : "post",
url : "${base}/feelingcount_list.jspx",
data:"id=${content.id}",
dataType : "text",
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
success : function(json){
json = decodeURI(json); //js解码
json = eval("("+json+")"); //转换为json对象
$(json).each(function(index) {
var val = json[index];
if(val.dic_id == 16 ){ //点击当前文章的点击数+1;前提是库中点击数添加成功以后,才能+1
$(".like_unlike").append("<a onclick=\"Cms.upf('${base}',"
+val.content_id+","+val.click_count+","+val.id+","+val.dic_id+");\" class=\"like\"><span>喜欢<em id=\"moodc"+val.id+"\">"
+val.click_count+"</em></span></a>"
);
}else if(val.dic_id == 17){
$(".like_unlike").append("<a onclick=\"Cms.upf('${base}',"
+val.content_id+","+val.click_count+","+val.id+","+val.dic_id+");\" class=\"unlike\"><span>不喜欢<em id=\"moodc"+val.id+"\">"
+val.click_count+"</em></span></a>"
);
}
});
},
error:function(json){
}
});
***********************************html
<!--心情状态-->
<div class="like_unlike">
<div class="clr"></div>
</div>
Cms.upf = function(base, feelingcountid, origValue, upId, type) {
var updown = $.cookie("_cms_up_" + feelingcountid);
if (updown) { //当前cookie是否存在,存在就已经发布过了, 不存在就没有发表
alert("-_- !,您已经发表过了哦~~");
return false;
}
$.cookie("_cms_up_" + feelingcountid, "1");
$.get(base + "/feelingcount_up.jspx", { //数据库+1
"feelingcountid" : feelingcountid,
"type" : type
}, function(data) {
var high = origValue + 1;
var top = 70 - high;
$("#moodc" + upId).html(high);
if(high<70){
$("#moodh" + upId).css("height",high);
$("#moodh" + upId).css("margin-top",top);
}else{
$("#moodh" + upId).css("height",high);
$("#moodh" + upId).css("margin-top",10);
}
});
return true;
};
************************************页面加载就查找库,当前文章的开心数
$.ajax({
type : "post",
url : "${base}/feelingcount_list.jspx",
data:"id=${content.id}",
dataType : "text",
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
success : function(json){
json = decodeURI(json); //js解码
json = eval("("+json+")"); //转换为json对象
$(json).each(function(index) {
var val = json[index];
if(val.dic_id == 16 ){ //点击当前文章的点击数+1;前提是库中点击数添加成功以后,才能+1
$(".like_unlike").append("<a onclick=\"Cms.upf('${base}',"
+val.content_id+","+val.click_count+","+val.id+","+val.dic_id+");\" class=\"like\"><span>喜欢<em id=\"moodc"+val.id+"\">"
+val.click_count+"</em></span></a>"
);
}else if(val.dic_id == 17){
$(".like_unlike").append("<a onclick=\"Cms.upf('${base}',"
+val.content_id+","+val.click_count+","+val.id+","+val.dic_id+");\" class=\"unlike\"><span>不喜欢<em id=\"moodc"+val.id+"\">"
+val.click_count+"</em></span></a>"
);
}
});
},
error:function(json){
}
});
***********************************html
<!--心情状态-->
<div class="like_unlike">
<div class="clr"></div>
</div>
相关文章推荐
- 如果喜欢我的文章就请点击里面的链接, 投我一票!
- 点击文章,动态改变页面的标题为当前文章的标题〔title〕
- android 项目学习随笔十三(ListView实现ITEM点击事件)
- CCS bug 之2: 点击blog中有文章的"月"的存档或"天",结果显示空页面
- 如何写好一篇让搜索引擎跟用户都喜欢的原创文章
- yiqicms点击文章或产品让发布时间自动更新的解决办法
- 随笔 - 58 文章 - 61 评论 - 7 STM32 端口复用&重映射(USART Remap) 下面跟大家说一下STM32单片机的端口重映射,因为是以
- wp-postviews——wordpress文章点击排行插件
- 听自己喜欢的文章-【睿读】
- Textview加入Intent、表情,点击跳转Activity
- 用正则替换文章中的表情(例如微博)
- c#评论文章时加入表情
- WORDPRESS博客文章点击统计插件 WP-POSTVIEWS安装使用详细介绍
- CSDN的这个新的写文章界面我特别的喜欢!想注册一个域名
- 处理19万随笔文章的结果
- IOS 开发解决环信聊天点击表情崩溃
- 博客园首页新随笔联系管理订阅 随笔- 216 文章- 1 评论- 2 Java ConcurrentModificationException异常原因和解决方法
- 在个人博客中添加文章点击次数
- 听挺喜欢这篇文章的