$(function() { // 回顶部 $(window).scroll( function() { if($(this).scrolltop() >= 100 ){ $("#scrolltop").show(); } else { $("#scrolltop").hide(); } } ); if($(window).scrolltop() >= 100 ){ $("#scrolltop").show(); } else { $("#scrolltop").hide(); } $("#scrolltop").click(function(){$(window).scrolltop(0);return false;}); // 回车绑定查询按钮 $('[name="search_header"]').on('keydown', function (e) { var key = e.which; if (key == 13 ) { e.preventdefault(); search_form.action = jflyfox.base_path + "front/tags/"+ $('[name="search_header"]').val(); search_form.submit(); } }); $('#search_btn').on('click', function (e) { var sb = document.getelementbyid("dsd").value; if(sb == "" ||(sb.length>0 && sb.trim().length == 0)){ alert("请输入搜索内容"); return false; } search_form.action = jflyfox.base_path + "front/tags/"+ $('[name="search_header"]').val(); search_form.submit(); }); $("#ntcpsearch_btn").click(function(){alert(00);}); /*$('#ntcpsearch_btn').on('click', function (e) { alert(00); search_form.action = jflyfox.base_path + "front/ntcpsearch/"+ $('[name="search_header"]').val(); search_form.submit(); });*/ // 评论数获取 comment.count(); }); /** * 评论 */ comment = { /** * 删除评论 * * @param comment_id */ oper_del:function(comment_id,article_id){ if(window.confirm('你确定要删除该评论吗?')){ jquery.ajax({ type:'post', url:jflyfox.base_path + 'front/comment/del', data:"model.id=" + comment_id + "&model.article_id=" + article_id, success:function(data){ if(data.status==1){ $('#comment_'+comment_id+'_'+article_id).remove(); var count = parseint($('[name="count_comment"]').val()); $('[name="count_comment"]').val(count - 1); $('#count_comment_show').html("评论(" + (count - 1) + ")"); } else { alert('删除失败:'+data.msg); } $('[name="comment"]').val(''); }, error:function(html){ var flag = (typeof console != 'undefined'); if(flag) console.log("服务器忙,提交数据失败,代码:" +html.status+ ",请联系管理员!"); alert("服务器忙,提交数据失败,请联系管理员!"); } }); } } /** * 保存评论: 内容 文章id 回复人id 文章创建人id 文章题目 */ ,oper_save:function(comment_content,article_id,reply_userid,create_id , article_title){ article_title = article_title || ''; var urlparams = "model.content=" + comment_content + "&model.article_id=" + article_id + "&model.reply_userid=" + reply_userid+ "&model.create_id=" + create_id; jquery.ajax({ type:'post', url:jflyfox.base_path + 'front/comment/save', data:urlparams, success:function(data){ if(data.status==1){ var createtime = data.create_time; var comment_id = data.comment_id; var title_url = data.title_url||''; var username = data.create_name; var reply_username = data.reply_username; title_url = (title_url=='')?(jflyfox.base_path + 'static/images/user/user.png'):title_url; var htmltext = '
  • '; htmltext += ''; htmltext += '
    '; // 回复头 htmltext += '
    '; if(article_title != ''){ htmltext += ''+article_title+''; htmltext += '文章中'; } htmltext += ''+username+''; if(reply_userid > 0 ) { htmltext += '回复'; htmltext += '' + reply_username + ''; } htmltext += '
    '; // 回复内容 htmltext += '
    '+comment_content+'
    '; // 回复底部 htmltext += '
    '; htmltext += ''+createtime+''; htmltext += '
    '; htmltext += ' 删除'; htmltext += '
  • '; $('.comment-reply-list').prepend(htmltext); var count = parseint($('[name="count_comment"]').val()); $('[name="count_comment"]').val(count + 1); $('#count_comment_show').html("评论(" + (count + 1) + ")"); } else { alert('保存失败:'+data.msg); } $('[name="comment"]').val(''); }, error:function(html){ var flag = (typeof console != 'undefined'); if(flag) console.log("服务器忙,提交数据失败,代码:" +html.status+ ",请联系管理员!"); alert("服务器忙,提交数据失败,请联系管理员!"); } }); } ,count:function(){ if ($("#mymessage").length <= 0){ return; } jquery.ajax({ type:'post', url:jflyfox.base_path + 'front/comment/count', success:function(data){ if(data.status==1){ if(data.count > 0 ){ $('#mymessage').hide(); $('#mymessage').html('我的消息('+data.count+')'); $('#mymessage').css('font-weight','bold'); $('#mymessage').css('color','green'); $('#mymessage').show(500); } else { // 如果已经读过,那么恢复初始化 if($('#mymessage').text() != '我的消息') { $('#mymessage').text('我的消息'); $('#mymessage').css('font-weight',''); $('#mymessage').css('color','#454545'); } } } else { console_log('获取评论失败:'+data.msg); } }, error:function(html){ var flag = (typeof console != 'undefined'); if(flag) console.log("服务器忙,提交数据失败,代码:" +html.status+ ",请联系管理员!"); // alert("服务器忙,提交数据失败,请联系管理员!"); } }); // 压力太大了就改大点 window.settimeout('comment.count()',600*1000); } }; /** * 文章喜欢 */ articlelike = { click:function(article_id){ if($('#articlelike_'+article_id).hasclass('glyphicon-heart-empty')){ articlelike.yes(article_id); } else { articlelike.no(article_id); } } /** * 喜欢 * * @param article_id */ ,yes:function(article_id){ jquery.ajax({ type:'post', url:jflyfox.base_path + 'front/articlelike/yes/'+article_id, success:function(data){ if(data.status==1){ $('#articlelike_'+article_id).removeclass('glyphicon-heart-empty').addclass('glyphicon-heart'); $('#articlelike_'+article_id).attr("title","取消喜欢"); } else { alert('失败:'+data.msg); } }, error:function(html){ var flag = (typeof console != 'undefined'); if(flag) console.log("服务器忙,提交数据失败,代码:" +html.status+ ",请联系管理员!"); alert("服务器忙,提交数据失败,请联系管理员!"); } }); } /** * 取消喜欢 * * @param article_id */ ,no:function(article_id){ jquery.ajax({ type:'post', url:jflyfox.base_path + 'front/articlelike/no/'+article_id, success:function(data){ if(data.status==1){ $('#articlelike_'+article_id).removeclass('glyphicon-heart').addclass('glyphicon-heart-empty'); $('#articlelike_'+article_id).attr("title","喜欢"); } else { alert('失败:'+data.msg); } }, error:function(html){ var flag = (typeof console != 'undefined'); if(flag) console.log("服务器忙,提交数据失败,代码:" +html.status+ ",请联系管理员!"); alert("服务器忙,提交数据失败,请联系管理员!"); } }); } }; function delblog(id) { var url = jflyfox.base_path + 'front/person/delblog/'+id; var title = '确认要删除该博文?'; confirm(title, function() { form1.action = url; form1.submit(); }); }