MediaWiki:Emotion.js

来自Mooncell - 玩家共同构筑的FGO中文Wiki
跳到导航 跳到搜索

注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:前往菜单 → 历史(Mac为Opera → Preferences),或按Ctrl-Shift-Del,然后清除浏览数据 → 勾选“已缓存的图片和文件” → 清除数据
/*
总之已经废弃了 换成了https://fgo.wiki/w/MediaWiki:Gadget-Emotion.js
*/
$('head').append('<style>.emos{width: 1.5em; pointer-events: none;}</style>');
$('head').append('<style>.emolist{overflow-x: auto; position: absolute; left: 20px; bottom: 20px; width: 180px; max-height: 75px; background: #fff; box-shadow: 0 1px 4px 0 rgba(0,0,0,0.2); border-radius: 3px; transition: all 0.3s ease-out;}</style>');
$('head').append('<style>.flowthread-btn.plus{display: inline-block; width: auto; padding: 2px; font-family: inherit;}</style>');
$('head').append('<style>.flowthread-btn-emoticon{font-family: inherit;}</style>');
//需自定义部分 开始
function addToTextArea(n) {
    var text= $(".comment-body textarea").val();
    text+='<img class="emos" style="width: 3.0em; pointer-events: none;" src="//media.fgo.wiki/emoji/emoji' + n + '.png" />';
    $(".comment-body textarea").val(text);
}

function emoticons() {
    for (i=1; i<5; ++i) {
        $(".emolist").prepend('<button class="flowthread-btn plus" id="25" onclick="addToTextArea(' + i + ')"><img class="emos" src="//media.fgo.wiki/emoji/emoji' + i + '.png" /></button>');
    }
}
//需自定义部分结束
$(".comment-toolbar").append('<button class="flowthread-btn flowthread-btn-emoticon" title="表情"><i class="far fa-laugh-wink" style="color:#555;"></i></button>');
$(".flowthread-btn-emoticon").click(function(){
    $(this).toggleClass("on");
    if ($(this).hasClass("on")) {
        $(this).after('<div class="emolist"></div>');
        emoticons();
    } else {
        $(".emolist").hide(300);
    }
    $("button.flowthread-btn-wikitext").addClass("on");
});