xiu主题给评论添加签到按钮

Author: 陌小雨Date: 2016-02-19View: 57

之前就说过分享xiu主题的评论签到功能,前段时间折腾就忘了这事了。

1、修改comments.php,添加下面代码到相应位置

<span data-event="comment-qiandao" class="muted comt-qiandao"><a href="javascript:SIMPALED.Editor.daka()"><i class="glyphicon glyphicon-pencil"></i> 签到</a></span>

陌小雨是添加在下面代码上面的

<?php include(TEMPLATEPATH . '/smiley.php'); ?>

如果你找不到该串代码,请参考这篇文章:https://dedewp.com/1222.html

2、添加js代码

jQuery(document).ready(function($) {

  function addEditor(a, b, c) {
    if (document.selection) {
      a.focus();
      sel = document.selection.createRange();
      c  sel.text = b + sel.text + c: sel.text = b;
      a.focus()
    } else if (a.selectionStart || a.selectionStart == '0') {
      var d = a.selectionStart;
      var e = a.selectionEnd;
      var f = e;
      c  a.value = a.value.substring(0, d) + b + a.value.substring(d, e) + c + a.value.substring(e, a.value.length) : a.value = a.value.substring(0, d) + b + a.value.substring(e, a.value.length);
      c  f += b.length + c.length: f += b.length - e + d;
      if (d == e && c) f -= c.length;
      a.focus();
      a.selectionStart = f;
      a.selectionEnd = f
    } else {
      a.value += b + c;
      a.focus()
    }
  }

  var myDate = new Date();
var mytime=myDate.toLocaleTimeString()

  var g = document.getElementById('comment') || 0;
  var h = {
    strong: function() {
      addEditor(g, '<strong>', '</strong>')
    },
    daka: function() {
      addEditor(g, '签到成功!签到时间:' + mytime, ',陌小雨,你很棒!一起加油哦哦~')
    },

  };
  window['SIMPALED'] = {};
  window['SIMPALED']['Editor'] = h

  $body = (window.opera)  (document.compatMode == "CSS1Compat"  $('html') : $('body')) : $('html,body');
  ;

  var wait = 15,
  submit_val = $submit.val();

  function isie6() {
    if ($.browser.msie) {
      if ($.browser.version == "6.0") return true;
    }
    return false;
  }

3、自动提交

 submit.click();

将这个动作添加到第二步中下面代码后面

 addEditor(g, '签到成功!签到时间:' + mytime, ',陌小雨,你很棒!一起加油哦哦~')