This commit is contained in:
杜恒 2021-02-19 18:09:26 +08:00
parent 36c52dfb47
commit f11b7c0afc
8 changed files with 10 additions and 411 deletions

View File

@ -1,84 +1 @@
class JoeOwO {
constructor(options) {
const defaultOption = {
contain: '.joe_owo__contain',
target: '.joe_owo__target',
seat: 'OωO',
api: '/usr/themes/Joe/assets/json/joe.owo.json'
};
this.options = Object.assign(defaultOption, options);
$.ajax({
url: this.options.api,
type: 'get',
dataType: 'json',
success: res => this.initHtml(res)
});
}
/* 初始化 */
initHtml(res) {
let barStr = '';
let scrollStr = '';
for (let key in res) {
barStr += `<div class="item" data-index="${res[key].index}">${key}</div>`;
scrollStr += `
<ul class="scroll" data-index="${res[key].index}">
${res[key].container.map(_ => `<li class="item" data-text="${_.data}">${_.icon}</li>`).join('')}
</ul>
`;
}
$(this.options.contain).html(`
<div class="seat">${this.options.seat}</div>
<div class="box">
${scrollStr}
<div class="bar">${barStr}</div>
</div>
`);
this.initEvent();
}
initEvent() {
/* 容器 */
const contain = this.options.contain;
/* 点击页面关闭 */
$(document).on('click', function () {
const box = contain + ' .box';
$(box).stop().slideUp('fast');
});
/* 点击占位符,显示表情弹窗 */
const seat = contain + ' .seat';
$(seat).on('click', function (e) {
e.stopPropagation();
$(this).siblings('.box').stop().slideToggle('fast');
});
/* 点击tab栏切换表情类型 */
const barItem = contain + ' .box .bar .item';
$(barItem).on('click', function (e) {
e.stopPropagation();
$(this).addClass('active').siblings().removeClass('active');
const scrollIndx = contain + ' .box .scroll[data-index="' + $(this).attr('data-index') + '"]';
$(scrollIndx).show().siblings('.scroll').hide();
});
/* 点击表情,向文本框插入内容 */
const items = contain + ' .scroll .item';
const textarea = $(this.options.target)[0];
$(items).on('click', function () {
const text = $(this).attr('data-text');
const cursorPos = textarea.selectionEnd;
const areaValue = textarea.value;
textarea.value = areaValue.slice(0, cursorPos) + text + areaValue.slice(cursorPos);
textarea.focus();
});
/* 默认激活第一个 */
$(barItem).first().click();
}
}
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = JoeOwO;
} else {
window.JoeOwO = JoeOwO;
}
function _instanceof(t,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](t):t instanceof n}function _classCallCheck(t,n){if(!_instanceof(t,n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function _createClass(t,n,e){return n&&_defineProperties(t.prototype,n),e&&_defineProperties(t,e),t}var JoeOwO=function(){"use strict";function t(n){var e=this;_classCallCheck(this,t);var i={contain:".joe_owo__contain",target:".joe_owo__target",seat:"OωO",api:"https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/json/joe.owo.json"};this.options=Object.assign(i,n),$.ajax({url:this.options.api,type:"get",dataType:"json",success:function(t){return e.initHtml(t)}})}return _createClass(t,[{key:"initHtml",value:function(t){var n="",e="";for(var i in t)n+='<div class="item" data-index="'.concat(t[i].index,'">').concat(i,"</div>"),e+='\n <ul class="scroll" data-index="'.concat(t[i].index,'">\n ').concat(t[i].container.map(function(t){return'<li class="item" data-text="'.concat(t.data,'">').concat(t.icon,"</li>")}).join("")," \n </ul>\n ");$(this.options.contain).html('\n <div class="seat">'.concat(this.options.seat,'</div>\n <div class="box">\n ').concat(e,'\n <div class="bar">').concat(n,"</div>\n </div>\n ")),this.initEvent()}},{key:"initEvent",value:function(){var t=this.options.contain;$(document).on("click",function(){var n=t+" .box";$(n).stop().slideUp("fast")});var n=t+" .seat";$(n).on("click",function(t){t.stopPropagation(),$(this).siblings(".box").stop().slideToggle("fast")});var e=t+" .box .bar .item";$(e).on("click",function(n){n.stopPropagation(),$(this).addClass("active").siblings().removeClass("active");var e=t+' .box .scroll[data-index="'+$(this).attr("data-index")+'"]';$(e).show().siblings(".scroll").hide()});var i=t+" .scroll .item",o=$(this.options.target)[0];$(i).on("click",function(){var t=$(this).attr("data-text"),n=o.selectionEnd,e=o.value;o.value=e.slice(0,n)+t+e.slice(n),o.focus()}),$(e).first().click()}}]),t}();"undefined"!=typeof module&&void 0!==module.exports?module.exports=JoeOwO:window.JoeOwO=JoeOwO;

1
assets/js/joe.owo.min.js vendored Normal file
View File

@ -0,0 +1 @@
function _instanceof(t,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](t):t instanceof n}function _classCallCheck(t,n){if(!_instanceof(t,n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function _createClass(t,n,e){return n&&_defineProperties(t.prototype,n),e&&_defineProperties(t,e),t}var JoeOwO=function(){"use strict";function t(n){var e=this;_classCallCheck(this,t);var i={contain:".joe_owo__contain",target:".joe_owo__target",seat:"OωO",api:"https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/json/joe.owo.json"};this.options=Object.assign(i,n),$.ajax({url:this.options.api,type:"get",dataType:"json",success:function(t){return e.initHtml(t)}})}return _createClass(t,[{key:"initHtml",value:function(t){var n="",e="";for(var i in t)n+='<div class="item" data-index="'.concat(t[i].index,'">').concat(i,"</div>"),e+='\n <ul class="scroll" data-index="'.concat(t[i].index,'">\n ').concat(t[i].container.map(function(t){return'<li class="item" data-text="'.concat(t.data,'">').concat(t.icon,"</li>")}).join("")," \n </ul>\n ");$(this.options.contain).html('\n <div class="seat">'.concat(this.options.seat,'</div>\n <div class="box">\n ').concat(e,'\n <div class="bar">').concat(n,"</div>\n </div>\n ")),this.initEvent()}},{key:"initEvent",value:function(){var t=this.options.contain;$(document).on("click",function(){var n=t+" .box";$(n).stop().slideUp("fast")});var n=t+" .seat";$(n).on("click",function(t){t.stopPropagation(),$(this).siblings(".box").stop().slideToggle("fast")});var e=t+" .box .bar .item";$(e).on("click",function(n){n.stopPropagation(),$(this).addClass("active").siblings().removeClass("active");var e=t+' .box .scroll[data-index="'+$(this).attr("data-index")+'"]';$(e).show().siblings(".scroll").hide()});var i=t+" .scroll .item",o=$(this.options.target)[0];$(i).on("click",function(){var t=$(this).attr("data-text"),n=o.selectionEnd,e=o.value;o.value=e.slice(0,n)+t+e.slice(n),o.focus()}),$(e).first().click()}}]),t}();"undefined"!=typeof module&&void 0!==module.exports?module.exports=JoeOwO:window.JoeOwO=JoeOwO;

View File

@ -1,61 +1 @@
[
{
"name": "娱乐天地",
"list": [
{ "name": "星秀", "gameId": 1663 },
{ "name": "户外", "gameId": 2165 },
{ "name": "二次元", "gameId": 2633 },
{ "name": "一起看", "gameId": 2135 },
{ "name": "美食", "gameId": 2752 },
{ "name": "颜值", "gameId": 2168 },
{ "name": "交友", "gameId": 4079 },
{ "name": "音乐", "gameId": 3793 },
{ "name": "体育", "gameId": 2356 }
]
},
{
"name": "网游竞技",
"list": [
{ "name": "英雄联盟", "gameId": 1 },
{ "name": "LOL云顶之弈", "gameId": 5485 },
{ "name": "穿越火线", "gameId": 4 },
{ "name": "DNF", "gameId": 2 },
{ "name": "魔兽世界", "gameId": 8 },
{ "name": "炉石传说", "gameId": 393 },
{ "name": "DOTA2", "gameId": 7 },
{ "name": "坦克世界", "gameId": 802 },
{ "name": "CS:GO", "gameId": 862 },
{ "name": "魔兽争霸3", "gameId": 4615 },
{ "name": "问道", "gameId": 107 },
{ "name": "使命召唤", "gameId": 100137 }
]
},
{
"name": "单机热游",
"list": [
{ "name": "绝地求生", "gameId": 2793 },
{ "name": "主机游戏", "gameId": 100032 },
{ "name": "我的世界", "gameId": 1732 },
{ "name": "方舟", "gameId": 1997 },
{ "name": "怪物猎人", "gameId": 3519 },
{ "name": "逃离塔科夫", "gameId": 3493 },
{ "name": "怀旧游戏", "gameId": 100125 },
{ "name": "骑马与砍杀", "gameId": 4783 },
{ "name": "拾遗记", "gameId": 4913 }
]
},
{
"name": "手游休闲",
"list": [
{ "name": "王者荣耀", "gameId": 2336 },
{ "name": "和平精英", "gameId": 3203 },
{ "name": "综合手游", "gameId": 100029 },
{ "name": "狼人杀", "gameId": 100049 },
{ "name": "QQ飞车", "gameId": 2928 },
{ "name": "CF手游", "gameId": 2413 },
{ "name": "跑跑手游", "gameId": 2620 },
{ "name": "皇室战争", "gameId": 2439 },
{ "name": "火影手游", "gameId": 2429 }
]
}
]
[{"name":"娱乐天地","list":[{"name":"星秀","gameId":1663},{"name":"户外","gameId":2165},{"name":"二次元","gameId":2633},{"name":"一起看","gameId":2135},{"name":"美食","gameId":2752},{"name":"颜值","gameId":2168},{"name":"交友","gameId":4079},{"name":"音乐","gameId":3793},{"name":"体育","gameId":2356}]},{"name":"网游竞技","list":[{"name":"英雄联盟","gameId":1},{"name":"LOL云顶之弈","gameId":5485},{"name":"穿越火线","gameId":4},{"name":"DNF","gameId":2},{"name":"魔兽世界","gameId":8},{"name":"炉石传说","gameId":393},{"name":"DOTA2","gameId":7},{"name":"坦克世界","gameId":802},{"name":"CS:GO","gameId":862},{"name":"魔兽争霸3","gameId":4615},{"name":"问道","gameId":107},{"name":"使命召唤","gameId":100137}]},{"name":"单机热游","list":[{"name":"绝地求生","gameId":2793},{"name":"主机游戏","gameId":100032},{"name":"我的世界","gameId":1732},{"name":"方舟","gameId":1997},{"name":"怪物猎人","gameId":3519},{"name":"逃离塔科夫","gameId":3493},{"name":"怀旧游戏","gameId":100125},{"name":"骑马与砍杀","gameId":4783},{"name":"拾遗记","gameId":4913}]},{"name":"手游休闲","list":[{"name":"王者荣耀","gameId":2336},{"name":"和平精英","gameId":3203},{"name":"综合手游","gameId":100029},{"name":"狼人杀","gameId":100049},{"name":"QQ飞车","gameId":2928},{"name":"CF手游","gameId":2413},{"name":"跑跑手游","gameId":2620},{"name":"皇室战争","gameId":2439},{"name":"火影手游","gameId":2429}]}]

File diff suppressed because one or more lines are too long

View File

@ -32,7 +32,7 @@
<head>
<?php $this->need('public/include.php'); ?>
<!-- 首页所使用到的CSS以及JS -->
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.index.css?v=217'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.index.css'); ?>">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@5.4.5/css/swiper.min.css" />
<script src="https://cdn.jsdelivr.net/npm/swiper@5.4.5/js/swiper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/wowjs@1.1.3/dist/wow.min.js"></script>

View File

@ -52,8 +52,8 @@
<!-- 全局公用CSS静态资源放在了CDN上如果你的服务器带宽不够请不要修改成本地cdn采用jsdelivr放心不会失效 -->
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.mode.css'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.normalize.css'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.global.css?v=686'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.responsive.css?v=686'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.global.css'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.responsive.css'); ?>">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/qmsg/qmsg.css" />
<link rel="stylesheet" href="https://apip.weatherdt.com/standard/static/css/weather-standard.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />
@ -66,8 +66,8 @@
<script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/sketchpad/joe.sketchpad.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/qmsg/qmsg.js"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.owo.js?v=686'); ?>"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.global.js?v=965'); ?>"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.owo.js'); ?>"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.global.js'); ?>"></script>
<!-- 异步加载的JS -->
<script async src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/smooth/joe.smooth.js"></script>
<?php if ($this->options->JCursorEffects && $this->options->JCursorEffects !== 'off') : ?>

View File

@ -15,7 +15,7 @@
<head>
<?php $this->need('public/include.php'); ?>
<!-- 视频页面需要用到的CSS及JS -->
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.video.css?v=3434'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.video.css'); ?>">
<script src="<?php $this->options->themeUrl('assets/js/joe.video.js'); ?>"></script>
</head>

View File

@ -14,7 +14,6 @@
<head>
<?php $this->need('public/include.php'); ?>
<!-- 壁纸页面需要用到的CSS及JS -->
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.wallpaper.css'); ?>">
<script src="<?php $this->options->themeUrl('assets/js/joe.wallpaper.js'); ?>"></script>
</head>