var a = false, blog_url = "https://blog.dmyhm.net/"; function insertSmile2(id) { $('textarea[name=comment],textarea[name=reply]').parseHtml2(id) } function bqover(a){ var img='
'+a.title+'
'; $("#yulan").html(img); var x=$(a).position().left+$(a).width(); var y=$(a).position().top-$("#yulan").height()-20; $("#yulan").css({"left":x,"top":y}); //$(a).fadeTo("fast",0.5); $("#yulan").show(); //alert(x+":"+y); } function bqout(a){ $("#yulan").hide(); } $(function(){ $("textarea[name=comment],textarea[name=reply]").focus(function() { if (!a) { var bq = document.createElement('div'); $(bq).attr('id', 'biaoqing'); smiles2='[牛][稀饭][愤怒][无语][哭][汗][哈哈][得意][戳][鸡冻][拥抱][微笑][帅哥][上吊][抽烟][飞吻][委屈][!][大骂][晕][财迷][思考][超人][心碎][握手][安慰][礼物][石头][剪刀][布][?][鄙视][可爱][害羞][鼓掌][囧]'; $(bq).html(smiles2); $('textarea[name=comment],textarea[name=reply]').before($(bq)); //将带有表情的层添加到 conten 之上; var bq2 = document.createElement('div'); $(bq2).attr('id', 'yulan'); $('textarea[name=comment],textarea[name=reply]').before($(bq2)); $(bq).css({"width":$('textarea[name=comment],textarea[name=reply]').width()}); $(bq).fadeIn("slow"); $.fn.extend({ parseHtml2: function(myValue) { var $t = $(this)[0]; if (document.selection) { this.focus(); sel = document.selection.createRange(); sel.text = myValue; this.focus() } else if ($t.selectionStart || $t.selectionStart == '0') { var startPos = $t.selectionStart; var endPos = $t.selectionEnd; var scrollTop = $t.scrollTop; $t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos, $t.value.length); this.focus() $t.selectionStart = startPos + myValue.length; $t.selectionEnd = startPos + myValue.length; $t.scrollTop = scrollTop } else { this.value += myValue; this.focus() } } }); a = true; } }); });