表情UBB网页插件

@Ta 2018-09-04 216点击

复制以下代码至个人中心->网页插件

更新日志

[2018-05-10] 调用insertText函数实现把表情插入到光标处。感谢@拒绝柳岩99次 (帖子)编写了这个函数。

<script src="//cdn.bootcss.com/jquery/2.1.0/jquery.min.js"></script>
<script type="text/javascript">
function insertText(obj, str) {  
    if (document.selection) {  
        var sel = document.selection.createRange();  
        sel.text = str;  
    } else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {  
        var startPos = obj.selectionStart,  
            endPos = obj.selectionEnd,  
            cursorPos = startPos,  
            tmpStr = obj.value;  
        obj.value = tmpStr.substring(0, startPos) + str + tmpStr.substring(endPos, tmpStr.length);  
        cursorPos += str.length;  
        obj.selectionStart = obj.selectionEnd = cursorPos;  
    } else {  
        obj.value += str;  
    }  
}
$(document).ready(function () {
    $("#content").after('<p id="face"><img title="冷" src="/tpl/classic/img/face/e586b7.gif" /><img title="勉强" src="/tpl/classic/img/face/e58b89e5bcba.gif" /><img title="吐舌" src="/tpl/classic/img/face/e59090e8888c.gif" /><img title="吐" src="/tpl/classic/img/face/e59090.gif" /><img title="呵呵" src="/tpl/classic/img/face/e591b5e591b5.gif" /><img title="呼" src="/tpl/classic/img/face/e591bc.gif" /><img title="咦" src="/tpl/classic/img/face/e592a6.gif" /><img title="哈哈" src="/tpl/classic/img/face/e59388e59388.gif" /><img title="啊" src="/tpl/classic/img/face/e5958a.gif" /><img title="喷" src="/tpl/classic/img/face/e596b7.gif" /><img title="太开心" src="/tpl/classic/img/face/e5a4aae5bc80e5bf83.gif" /><img title="委屈" src="/tpl/classic/img/face/e5a794e5b188.gif" /><img title="开心" src="/tpl/classic/img/face/e5bc80e5bf83.gif" /><img title="怒" src="/tpl/classic/img/face/e68092.gif" /><img title="惊哭" src="/tpl/classic/img/face/e6838ae593ad.gif" /><img title="惊讶" src="/tpl/classic/img/face/e6838ae8aeb6.gif" /><img title="汗" src="/tpl/classic/img/face/e6b197.gif" /><img title="泪" src="/tpl/classic/img/face/e6b3aa.gif" /><img title="滑稽" src="/tpl/classic/img/face/e6bb91e7a8bd.gif" /><img title="狂汗" src="/tpl/classic/img/face/e78b82e6b197.gif" /><img title="疑问" src="/tpl/classic/img/face/e79691e997ae.gif" /><img title="真棒" src="/tpl/classic/img/face/e79c9fe6a392.gif" /><img title="睡觉" src="/tpl/classic/img/face/e79da1e8a789.gif" /><img title="笑眼" src="/tpl/classic/img/face/e7ac91e79cbc.gif" /><img title="花心" src="/tpl/classic/img/face/e88ab1e5bf83.gif" /><img title="鄙视" src="/tpl/classic/img/face/e98499e8a786.gif" /><img title="酷" src="/tpl/classic/img/face/e985b7.gif" /><img title="钱" src="/tpl/classic/img/face/e992b1.gif" /><img title="阴险" src="/tpl/classic/img/face/e998b4e999a9.gif" /><img title="黑线" src="/tpl/classic/img/face/e9bb91e7babf.gif" /></p>');
    $('#face img').click(function () {
    var face = "{" +  $(this).attr("title") + "}";
    insertText(document.getElementById("content"), face);
  });
});
</script>
[/code]
下面这个第二套管理网页插件 集合表情,常用ubb
<style>
#bar_f{background-color:#FFF;border:solid 1px #08C; padding:0px; margin:0px;position:fixed;top:0px;left:0px;z-index:101;}
#bar_title{background-color:#08C;cursor:move;height:5px;}
#tr1,#tr2{ padding:0px; margin:3px;}
#bar_f a:hover {color:#FFF;background-color:#08C;}
</style>
<div id="bar_f" >
<div id="bar_title"></div>
<a href="javascript:scroll(0,0)" title="回顶↑">TOP</a> - <a href="#" title="表情" onclick="Show_Hidden(tr1);return false">Face</a> - <a href="#"  title="更多" onclick="Show_Hidden(tr2);return false">More</a>
<div id="tr1" style="display:none;">
<a href="#" onclick="bar_write('{不高兴}');return false"><img title="不高兴" src="/tpl/classic/img/face/e4b88de9ab98e585b4.gif" /></a>
<a href="#" onclick="bar_write('{乖}');return false"><img title="乖" src="/tpl/classic/img/face/e4b996.gif" /></a>
<a href="#" onclick="bar_write('{冷}');return false"><img title="冷" src="/tpl/classic/img/face/e586b7.gif" /></a>
<a href="#" onclick="bar_write('{勉强}');return false"><img title="勉强" src="/tpl/classic/img/face/e58b89e5bcba.gif" /></a>
<a href="#" onclick="bar_write('{吐舌}');return false"><img title="吐舌" src="/tpl/classic/img/face/e59090e8888c.gif" /></a>
<a href="#" onclick="bar_write('{吐}');return false"><img title="吐" src="/tpl/classic/img/face/e59090.gif" /></a>
<a href="#" onclick="bar_write('{呵呵}');return false"><img title="呵呵" src="/tpl/classic/img/face/e591b5e591b5.gif" /></a>
<a href="#" onclick="bar_write('{呼}');return false"><img title="呼" src="/tpl/classic/img/face/e591bc.gif" /></a>
<br /><a href="#" onclick="bar_write('{咦}');return false"><img title="咦" src="/tpl/classic/img/face/e592a6.gif" /></a>
<a href="#" onclick="bar_write('{哈哈}');return false"><img title="哈哈" src="/tpl/classic/img/face/e59388e59388.gif" /></a>
<a href="#" onclick="bar_write('{啊}');return false"><img title="啊" src="/tpl/classic/img/face/e5958a.gif" /></a>
<a href="#" onclick="bar_write('{喷}');return false"><img title="喷" src="/tpl/classic/img/face/e596b7.gif" /></a>
<a href="#" onclick="bar_write('{太开心}');return false"><img title="太开心" src="/tpl/classic/img/face/e5a4aae5bc80e5bf83.gif" /></a>
<a href="#" onclick="bar_write('{委屈}');return false"><img title="委屈" src="/tpl/classic/img/face/e5a794e5b188.gif" /></a>
<a href="#" onclick="bar_write('{开心}');return false"><img title="开心" src="/tpl/classic/img/face/e5bc80e5bf83.gif" /></a>
<a href="#" onclick="bar_write('{怒}');return false"><img title="怒" src="/tpl/classic/img/face/e68092.gif" /></a>
<br /><a href="#" onclick="bar_write('{惊哭}');return false"><img title="惊哭" src="/tpl/classic/img/face/e6838ae593ad.gif" /></a>
<a href="#" onclick="bar_write('{惊讶}');return false"><img title="惊讶" src="/tpl/classic/img/face/e6838ae8aeb6.gif" /></a>
<a href="#" onclick="bar_write('{汗}');return false"><img title="汗" src="/tpl/classic/img/face/e6b197.gif" /></a>
<a href="#" onclick="bar_write('{泪}');return false"><img title="泪" src="/tpl/classic/img/face/e6b3aa.gif" /></a>
<a href="#" onclick="bar_write('{滑稽}');return false"><img title="滑稽" src="/tpl/classic/img/face/e6bb91e7a8bd.gif" /></a>
<a href="#" onclick="bar_write('{狂汗}');return false"><img title="狂汗" src="/tpl/classic/img/face/e78b82e6b197.gif" /></a>
<a href="#" onclick="bar_write('{疑问}');return false"><img title="疑问" src="/tpl/classic/img/face/e79691e997ae.gif" /></a>
<a href="#" onclick="bar_write('{真棒}');return false"><img title="真棒" src="/tpl/classic/img/face/e79c9fe6a392.gif" /></a>
<br /><a href="#" onclick="bar_write('{睡觉}');return false"><img title="睡觉" src="/tpl/classic/img/face/e79da1e8a789.gif" /></a>
<a href="#" onclick="bar_write('{笑眼}');return false"><img title="笑眼" src="/tpl/classic/img/face/e7ac91e79cbc.gif" /></a>
<a href="#" onclick="bar_write('{花心}');return false"><img title="花心" src="/tpl/classic/img/face/e88ab1e5bf83.gif" /></a>
<a href="#" onclick="bar_write('{鄙视}');return false"><img title="鄙视" src="/tpl/classic/img/face/e98499e8a786.gif" /></a>
<a href="#" onclick="bar_write('{酷}');return false"><img title="酷" src="/tpl/classic/img/face/e985b7.gif" /></a>
<a href="#" onclick="bar_write('{钱}');return false"><img title="钱" src="/tpl/classic/img/face/e992b1.gif" /></a>
<a href="#" onclick="bar_write('{阴险}');return false"><img title="阴险" src="/tpl/classic/img/face/e998b4e999a9.gif" /></a>
<a href="#" onclick="bar_write('{黑线}');return false"><img title="黑线" src="/tpl/classic/img/face/e9bb91e7babf.gif" /></a>
</div>
<div id="tr2" style="display:none;">
<a href="#" title="链接" onclick="bar_write('[url][/url]');return false">Url</a>
<a href="#" title="图片" onclick="bar_write('[img][/img]');return false">Img</a>
<a href="#" title="div块" onclick="bar_write('[div=color:#FFF;background-color:#000;][/div]');return false">Div</a>
<a href="#" title="span行" onclick="bar_write('[span=color:#FFF;background-color:#000;][/span]');return false">Span</a>
<a href="#" title="高亮代码" onclick="bar_write('[code][/code]');return false">Code</a>
<a href="#" title="字体加粗" onclick="bar_write('[b][/b]');return false">B</a>
<a href="#" title="上传文件或者图片" onclick="bar_upload();return false">附件</a>
<a href="/q.php/bbs.topic.80645.html" target="_blank" title="UBB说明">UBB说明</a>
<a href="/q.php/addin.webplug.html" title="网页插件">网页插件</a>
</div>
</div>
<div style="height:30px !important;"></div>
<script src="//apps.bdimg.com/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
    (function ($) {
        $.getUrlParam = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return decodeURIComponent(r[2]); return null;
        }
    })(jQuery);

    window.onload=function(){
        var file = $.getUrlParam("file");
        var ext = $.getUrlParam("ext");
        if(file != null){
            if(ext == "jpg" || ext == "gif" || ext == "png" || ext == "jpeg" || ext == "bmp"){
                $("#content").val( window.sessionStorage.bar_content + "\r\n[img]" + file + "[/img]");
            }else{
                $("#content").val( window.sessionStorage.bar_content + "\r\n[color=green]附件:[/color][url=" + file + "]下载[/url]");
            }
            window.sessionStorage.bar_content = null;
        }
    }

    var posX;
    var posY;
    var fdiv = document.getElementById("bar_f");

    if (window.localStorage.bar_pos) {
        fdiv.style.left = window.localStorage.bar_left;
        fdiv.style.top = window.localStorage.bar_top;
    }

        function bar_write(id) {
        var nr = document.getElementById("content");
        nr.value += ""+id+"";
    }

        function bar_upload() {
                window.sessionStorage.bar_content = $("#content").val();
                document.location = 'https://www.xinby.cn/hu60_upload.php';
        }

    document.getElementById("bar_title").onmousedown=function(e)
    {
        if(!e) e = window.event;  //IE
        posX = e.clientX - parseInt(fdiv.style.left);
        posY = e.clientY - parseInt(fdiv.style.top);
        document.onmousemove = bar_mousemove;
        document.onmouseup = bar_mouseup;
    }

    function bar_mousemove(ev)
    {
        if(ev==null) ev = window.event;//IE
        fdiv.style.left = (ev.clientX - posX) + "px";
        fdiv.style.top = (ev.clientY - posY) + "px";
    }
    function bar_mouseup(ev)
    {
        if(ev==null) ev = window.event;//IE
        window.localStorage.bar_pos = true;
        window.localStorage.bar_left = fdiv.style.left;
        window.localStorage.bar_top = fdiv.style.top;
        document.onmousemove = null;
        document.onmouseup = null;
    }
function Show_Hidden(trid){
    if(trid.style.display=="block"){
        trid.style.display='none';
    }else{
        trid.style.display='block';
    }
}</script>

回复列表(0)
帖子没有回复
添加新回复
回复需要登录
[聊天-微语]胖罗:学校固然是很大一部分影响因素,但是自己的…