From c14e3278893b9dd1022aa488cee53a888c2a4c7e Mon Sep 17 00:00:00 2001
From: inleft <inleft@qq.com>
Date: Tue, 16 Aug 2022 19:34:48 +0800
Subject: [PATCH] 表情组件优化

---
 /dev/null                             |  148 -------------
 src/assets/md.less                    |    6 
 src/components/common/OwO.vue         |   65 +++++
 src/components/mini/box12-comment.vue |   24 +
 src/components/mini/box13-reply.vue   |  202 ++----------------
 src/js/myOwO.js                       |  165 +++++++++++++++
 public/OWO2.json                      |    0 
 src/assets/OwO.json                   |   11 +
 src/components/layouts/baseLayout.vue |    2 
 9 files changed, 290 insertions(+), 333 deletions(-)

diff --git a/public/OWO.js b/public/OWO.js
deleted file mode 100644
index b94f3bd..0000000
--- a/public/OWO.js
+++ /dev/null
@@ -1,148 +0,0 @@
-;(() => {
-    class OwO {
-        constructor(option) {
-            const defaultOption = {
-                container: document.getElementsByClassName('OwO')[0],
-                target: document.getElementsByTagName('textarea')[0],
-                position: 'down',
-                width: '100%',
-                maxHeight: '250px',
-                api: 'https://api.anotherhome.net/OwO/OwO.json'
-            }
-            for (let defaultKey in defaultOption) {
-                if (defaultOption.hasOwnProperty(defaultKey) && !option.hasOwnProperty(defaultKey)) {
-                    option[defaultKey] = defaultOption[defaultKey]
-                }
-            }
-            this.container = option.container
-            this.target = option.target
-            if (option.position === 'up') {
-                this.container.classList.add('OwO-up')
-            }
-            const xhr = new XMLHttpRequest()
-            xhr.onreadystatechange = () => {
-                if (xhr.readyState === 4) {
-                    if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
-                        this.odata = JSON.parse(xhr.responseText)
-                        this.init(option)
-                    } else {
-                        console.log('OwO data request was unsuccessful: ' + xhr.status)
-                    }
-                }
-            }
-            xhr.open('get', option.api, true)
-            xhr.send(null)
-        }
-
-        init(option) {
-            this.area = option.target
-            this.packages = Object.keys(this.odata)
-
-            // fill in HTML
-            let html = `
-            <div class="OwO-logo"><span>OωO</span></div>
-            <div class="OwO-body" style="width: ${option.width}"><div class="OwO-jio"></div>`
-
-            for (let i = 0; i < this.packages.length; i++) {
-                html += `
-                <ul class="OwO-items OwO-items-${this.odata[this.packages[i]].type}" style="max-height: ${parseInt(option.maxHeight) - 53 + 'px'};">`
-                var type = this.odata[this.packages[i]].type
-                let opackage = this.odata[this.packages[i]].container
-                for (let i = 0; i < opackage.length; i++) {
-                    if (type == 'image') {
-                        html += `
-                    <li class="OwO-item" data-id="${opackage[i].data}" title="${opackage[i].text}"><img class="biaoqing ${opackage[i].css}" src="${Config.themeUrl+opackage[i].icon}"></li>`
-                    } else {
-                        html += `
-                    <li class="OwO-item" data-id="not-given" title="${opackage[i].text}">${opackage[i].icon}</li>`
-                    } 
-                }
-
-                html += `
-                </ul>`
-            }
-
-            html += `
-                <div class="OwO-bar">
-                    <ul class="OwO-packages">`
-
-            for (let i = 0; i < this.packages.length; i++) {
-                html += `
-                        <li><span>${this.packages[i]}</span></li>`
-            }
-
-            html += `
-                    </ul>
-                </div>
-            </div>
-            `
-            this.container.innerHTML = html
-
-            // bind event
-            this.logo = document.getElementsByClassName('OwO-logo')[0]
-            this.logo.addEventListener('click', e => {
-                e.stopPropagation()
-                this.toggle()
-            })
-
-            this.container.getElementsByClassName('OwO-body')[0].addEventListener('click', e => {
-                let target = null
-                if (e.target.classList.contains('OwO-item')) {
-                    target = e.target
-                } else if (e.target.parentNode.classList.contains('OwO-item')) {
-                    target = e.target.parentNode
-                }
-                if (target) {
-                    const cursorPos = this.area.selectionEnd
-                    let areaValue = this.area.value
-                    //this.area.value = areaValue.slice(0, cursorPos) + target.innerHTML + areaValue.slice(cursorPos);
-                    if (target.dataset.id == 'not-given') {
-                        this.area.value = areaValue.slice(0, cursorPos) + target.innerHTML + areaValue.slice(cursorPos)
-                    } else {
-                        this.area.value = areaValue.slice(0, cursorPos) + target.dataset.id + areaValue.slice(cursorPos)
-                    }
-                    this.area.focus()
-                    this.toggle()
-                }
-            })
-            this.packagesEle = this.container.getElementsByClassName('OwO-packages')[0]
-            for (let i = 0; i < this.packagesEle.children.length; i++) {
-                ;(index => {
-                    this.packagesEle.children[i].addEventListener('click', e => {
-                        e.stopPropagation()
-                        this.tab(index)
-                    })
-                })(i)
-            }
-            this.tab(0)
-        }
-
-        toggle() {
-            if (this.container.classList.contains('OwO-open')) {
-                this.container.classList.remove('OwO-open')
-            } else {
-                this.container.classList.add('OwO-open')
-            }
-        }
-
-        tab(index) {
-            const itemsShow = this.container.getElementsByClassName('OwO-items-show')[0]
-            if (itemsShow) {
-                itemsShow.classList.remove('OwO-items-show')
-            }
-            this.container.getElementsByClassName('OwO-items')[index].classList.add('OwO-items-show')
-
-            const packageActive = this.container.getElementsByClassName('OwO-package-active')[0]
-            if (packageActive) {
-                packageActive.classList.remove('OwO-package-active')
-            }
-            this.packagesEle.getElementsByTagName('li')[index].classList.add('OwO-package-active')
-        }
-    }
-
-    if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
-        module.exports = OwO
-    } else {
-        window.OwO = OwO
-    }
-})()
\ No newline at end of file
diff --git a/public/OWO.json b/public/OWO2.json
similarity index 100%
rename from public/OWO.json
rename to public/OWO2.json
diff --git a/src/assets/OwO.json b/src/assets/OwO.json
new file mode 100644
index 0000000..18bcc17
--- /dev/null
+++ b/src/assets/OwO.json
@@ -0,0 +1,11 @@
+{
+	"蛆音娘": {
+		"type": "image",
+		"container": [{
+			"icon": "http://t.inleft.com/share/media_photo/biaoqing/E89B86E99FB3E5A898_E6918AE6898B.png",
+			"css": "quyin",
+			"data": ":&(蛆音娘_摊手)",
+			"text": "蛆音娘_摊手"
+		}]
+	}
+}
diff --git a/src/assets/md.less b/src/assets/md.less
index 13112e0..88ef58d 100644
--- a/src/assets/md.less
+++ b/src/assets/md.less
@@ -15,6 +15,12 @@
 	 
 	img{
 		 max-width: -webkit-fill-available;
+		 display: inline;
+		 box-shadow: 0 0 4px rgba(0,0,0,0.5);
+		 overflow: visible;
+		 border-radius: 12px;
+		 -webkit-filter: drop-shadow(4px 4px 10px rgba(0,0,0,.5));
+		 filter: drop-shadow(4px 4px 10px rgba(0,0,0,.5));
 	}
 	h1, h2, h3, h4 {
 	    color: #111111;
diff --git a/src/components/common/OwO.vue b/src/components/common/OwO.vue
new file mode 100644
index 0000000..54f5e34
--- /dev/null
+++ b/src/components/common/OwO.vue
@@ -0,0 +1,65 @@
+<template>
+	<div id="area">
+		<a-form-item>
+			<a-textarea ref="targetArea" :rows="4" v-model="visitorContent" :placeholder="this.$attrs.replyHolder"
+				class="OwO-textarea" />
+		</a-form-item>
+		<span class="myTip fadeIn" v-if="showTip">现在你可以发送表情啦</span>
+		<div ref="container" class="OwO fadeIn" v-show="init || visitorContent.length>0"></div>
+	</div>
+</template>
+
+<script>
+	import 'owo/dist/OwO.min.css';
+	import OWO from '../../js/myOwO.js'
+	import OwOjsonConfig from '../../assets/OwO.json'
+
+	export default {
+		props: {
+			content: String
+		},
+		data() {
+			return {
+				init: false,
+				showTip: false,
+				visitorContent: '',
+			}
+		},
+		watch: {
+			visitorContent: function(newValue, oldValue) {
+				if (newValue.length > 0) {
+					this.init = true;
+					this.initOwO();
+					if (!this.showTip) {
+						this.showTip = true;
+						setTimeout(() => {
+							this.showTip = false;
+						}, 5000);
+					}
+				}
+				this.$emit("update:content", newValue)
+			},
+		},
+		methods: {
+			initOwO() {
+				var OwO_demo = new OwO({
+					logo: 'OωO表情',
+					// container: document.getElementsByClassName('OwO')[0],
+					// target: document.getElementsByClassName('OwO-textarea')[0],
+					container: this.$refs.container,
+					target: this.$refs.targetArea.$el,
+					// api: './OwO.json',
+					// api: 'http://diygod.github.io/OwO/demo/OwO.json',
+					jsonText: OwOjsonConfig,
+					position: 'down',
+					width: '100%',
+					maxHeight: '250px'
+				});
+			}
+		}
+	}
+</script>
+
+<style>
+
+</style>
diff --git a/src/components/layouts/baseLayout.vue b/src/components/layouts/baseLayout.vue
index af50842..91552a4 100644
--- a/src/components/layouts/baseLayout.vue
+++ b/src/components/layouts/baseLayout.vue
@@ -151,6 +151,8 @@
 		-webkit-animation-duration: 2s;
 		-webkit-animation-iteration-count: 1;
 	}
+	
+	 
 
 	.fadeInLeft {
 		-webkit-animation-name: "fadeInLeft";
diff --git a/src/components/mini/box12-comment.vue b/src/components/mini/box12-comment.vue
index f3b4792..9e748ed 100644
--- a/src/components/mini/box12-comment.vue
+++ b/src/components/mini/box12-comment.vue
@@ -6,12 +6,13 @@
 			</a-collapse-panel>
 		</a-collapse>
 		<div v-else>
-			<replyBox ref="commentBoxId" v-bind="$attrs" @sendMsg="sendMsg()"></replyBox>
+			<replyBox ref="commentBoxId" v-bind="$attrs" @sendMsg="sendMsg()" ></replyBox>
 		</div>
 
 		<a-modal v-model="visible" :title="replyTaget" :footer="null"
-			:bodyStyle="{'overflow':'overlay','maxHeight': '550px','scrollbarWidth': 'none'}">
-			<replyBox ref="replyBoxId" v-bind="$attrs" @sendMsg="sendMsg()"></replyBox>
+			:bodyStyle="{'overflow':'overlay','height': '700px','scrollbarWidth': 'none'}">
+			<replyBox ref="replyBoxId" v-bind="$attrs" @sendMsg="sendMsg()" :parseContent="parseContent"
+				:visible="visible"></replyBox>
 		</a-modal>
 
 		<div class="mySecret" style="max-height:250px ;" v-if="commentListData.length==0">
@@ -41,7 +42,7 @@
 						<div class="samllPadding">:</div>
 					</div>
 
-					<p :id="temp.id" slot="content" v-html="temp.commentContent" class="myContent"></p>
+					<p :id="temp.id" slot="content" v-html="parseContent(temp.commentContent)" class="myContent"></p>
 
 					<a-comment v-for="tempData in temp.replyList">
 						<div slot="actions" key="comment-nested-reply-to" class="actionList">
@@ -75,7 +76,7 @@
 								</a-tooltip>
 							</div>
 						</div>
-						<p :id="tempData.id" slot="content">{{tempData.commentContent}}</p>
+						<p :id="tempData.id" slot="content" v-html="parseContent(tempData.commentContent)"></p>
 					</a-comment>
 				</a-comment>
 
@@ -98,15 +99,15 @@
 
 <script>
 	import replyBox from "./box13-reply.vue"
-
 	import {
 		queryBlogCommentList,
 		queryBlogCommentSubList
 	} from '../../api/blogArticleComment.js'
+	import OwOjsonConfig from '../../assets/OwO.json'
 
 	export default {
 		components: {
-			replyBox
+			replyBox,
 		},
 		props: {
 			"foldReply": {
@@ -114,6 +115,13 @@
 			},
 		},
 		methods: {
+			parseContent(content) {
+				let  tempStrArray=content.match("\:\&\(.*\)");
+				
+				console.log(OwOjsonConfig);
+				console.log(333);
+				return content;
+			},
 			updateCommentList(articleId) {
 				queryBlogCommentList({
 					pageNo: this.page.current,
@@ -183,7 +191,7 @@
 	.myContent img {
 		margin-bottom: -0.125rem;
 		img min-height: 3.5rem;
-		height: 3em;
+		height: 2em;
 	}
 
 	.samllPadding {
diff --git a/src/components/mini/box13-reply.vue b/src/components/mini/box13-reply.vue
index 23e3380..7809b0b 100644
--- a/src/components/mini/box13-reply.vue
+++ b/src/components/mini/box13-reply.vue
@@ -28,17 +28,12 @@
 				{{msgInfo.useName}}<span style="padding: 0px 3px;"> : </span>
 			</div>
 			<div>
-				<span v-html="msgInfo.userComment.replace(/\n/g, '<br>')"></span>
+				<span v-html="parseContent(msgInfo.userComment).replace(/\n/g, '<br>')"></span>
 			</div>
 		</div>
 		<a-comment>
 			<div slot="content">
-				<a-form-item>
-					<a-textarea :rows="4" v-model="form.visitorContent" :placeholder="replyHolder"
-						class="OwO-textarea" />
-				</a-form-item>
-				<div class="OwO"></div>
-
+				<MyOwO :content.sync="form.visitorContent" :replyHolder="replyHolder"></MyOwO>
 				<div>
 					<a-button html-type="submit" type="primary" @click="send()" v-if="!showReplyMsgInfo"
 						:disabled="isSending || $attrs.isAllowedComment==0">
@@ -71,27 +66,23 @@
 	} from '../../api/blogArticleComment.js'
 	import md5 from 'js-md5';
 
-	import 'owo/dist/OwO.min.css';
-	// import OwO from 'owo/dist/OwO.min.js';
-	// import OwO from '/public/OWO.js';
-
-
-	const VisitorDataKey = "visitorData.inleft.com"
+	import MyOwO from '../common/OwO.vue'
+	import myConstant from "../../config/myConstant.js"
 
 	export default {
-		mounted() {
-			var OwO_demo = new OwO({
-				logo: 'OωO表情',
-				container: document.getElementsByClassName('OwO')[0],
-				target: document.getElementsByClassName('OwO-textarea')[0],
-				api: './OwO.json',
-				// api: 'http://diygod.github.io/OwO/demo/OwO.json',
-				position: 'down',
-				width: '100%',
-				maxHeight: '250px'
-			});
+		components: {
+			MyOwO
+		},
+		props: {
+			parseContent: {
+				type: Function,
+				default: null
+			}
 		},
 		methods: {
+			// getTargetArea() {
+			// 	return this.$refs.targetArea;
+			// },
 			getMsgInfo(param) {
 				this.msgInfo = param;
 				this.showReplyMsgInfo = true;
@@ -126,7 +117,7 @@
 
 				if (this.form.nickName == 'inleft' || this.form.nickName == '笔墨' || this.form.nickName == '阿墨') {
 					if (this.form.authCode == null || this.form.authCode == "") {
-						this.$message.info("不要成为我,你就是真的自己..")
+						this.$message.info("此名称在这里使用需要正确的授权码..")
 						return
 					}
 				}
@@ -148,7 +139,7 @@
 					this.form.visitorId = year + (month > 10 ? month : '0' + month) + date + num
 				}
 
-				localStorage.setItem(VisitorDataKey, JSON.stringify(this.form))
+				localStorage.setItem(this.VisitorDataKey, JSON.stringify(this.form))
 
 				this.isSending = true;
 				blogCommentAdd({
@@ -190,7 +181,7 @@
 		},
 
 		data() {
-			let tempVisitorData = localStorage.getItem(VisitorDataKey);
+			let tempVisitorData = localStorage.getItem(this.VisitorDataKey);
 			let vistorData = {
 				nickName: "",
 				eMail: "",
@@ -216,6 +207,7 @@
 			}
 
 			return {
+				VisitorDataKey: myConstant.VisitorDataKey,
 				isSending: false,
 				replyHolder: "",
 				msgInfo: {
@@ -264,159 +256,15 @@
 			}
 		}
 	}
-	
-	;(() => {
-	    class OwO {
-	        constructor(option) {
-	            const defaultOption = {
-	                container: document.getElementsByClassName('OwO')[0],
-	                target: document.getElementsByTagName('textarea')[0],
-	                position: 'down',
-	                width: '100%',
-	                maxHeight: '250px',
-	                api: 'https://api.anotherhome.net/OwO/OwO.json'
-	            }
-	            for (let defaultKey in defaultOption) {
-	                if (defaultOption.hasOwnProperty(defaultKey) && !option.hasOwnProperty(defaultKey)) {
-	                    option[defaultKey] = defaultOption[defaultKey]
-	                }
-	            }
-	            this.container = option.container
-	            this.target = option.target
-	            if (option.position === 'up') {
-	                this.container.classList.add('OwO-up')
-	            }
-	            const xhr = new XMLHttpRequest()
-	            xhr.onreadystatechange = () => {
-	                if (xhr.readyState === 4) {
-	                    if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
-	                        this.odata = JSON.parse(xhr.responseText)
-	                        this.init(option)
-	                    } else {
-	                        console.log('OwO data request was unsuccessful: ' + xhr.status)
-	                    }
-	                }
-	            }
-	            xhr.open('get', option.api, true)
-	            xhr.send(null)
-	        }
-	
-	        init(option) {
-	            this.area = option.target
-	            this.packages = Object.keys(this.odata)
-	
-	            // fill in HTML
-	            let html = `
-	            <div class="OwO-logo"><span>OωO</span></div>
-	            <div class="OwO-body" style="width: ${option.width}"><div class="OwO-jio"></div>`
-	
-	            for (let i = 0; i < this.packages.length; i++) {
-	                html += `
-	                <ul class="OwO-items OwO-items-${this.odata[this.packages[i]].type}" style="max-height: ${parseInt(option.maxHeight) - 53 + 'px'};">`
-	                var type = this.odata[this.packages[i]].type
-	                let opackage = this.odata[this.packages[i]].container
-	                for (let i = 0; i < opackage.length; i++) {
-	                    if (type == 'image') {
-	                        html += `
-	                    <li class="OwO-item" data-id="${opackage[i].data}" title="${opackage[i].text}"><img class="biaoqing ${opackage[i].css}" src="${opackage[i].icon}"></li>`
-	                    } else {
-	                        html += `
-	                    <li class="OwO-item" data-id="not-given" title="${opackage[i].text}">${opackage[i].icon}</li>`
-	                    } 
-	                }
-	
-	                html += `
-	                </ul>`
-	            }
-	
-	            html += `
-	                <div class="OwO-bar">
-	                    <ul class="OwO-packages">`
-	
-	            for (let i = 0; i < this.packages.length; i++) {
-	                html += `
-	                        <li><span>${this.packages[i]}</span></li>`
-	            }
-	
-	            html += `
-	                    </ul>
-	                </div>
-	            </div>
-	            `
-	            this.container.innerHTML = html
-	
-	            // bind event
-	            this.logo = document.getElementsByClassName('OwO-logo')[0]
-	            this.logo.addEventListener('click', e => {
-	                e.stopPropagation()
-	                this.toggle()
-	            })
-	
-	            this.container.getElementsByClassName('OwO-body')[0].addEventListener('click', e => {
-	                let target = null
-	                if (e.target.classList.contains('OwO-item')) {
-	                    target = e.target
-	                } else if (e.target.parentNode.classList.contains('OwO-item')) {
-	                    target = e.target.parentNode
-	                }
-	                if (target) {
-	                    const cursorPos = this.area.selectionEnd
-	                    let areaValue = this.area.value
-	                    //this.area.value = areaValue.slice(0, cursorPos) + target.innerHTML + areaValue.slice(cursorPos);
-	                    if (target.dataset.id == 'not-given') {
-	                        this.area.value = areaValue.slice(0, cursorPos) + target.innerHTML + areaValue.slice(cursorPos)
-	                    } else {
-	                        this.area.value = areaValue.slice(0, cursorPos) + target.dataset.id + areaValue.slice(cursorPos)
-	                    }
-	                    this.area.focus()
-	                    this.toggle()
-	                }
-	            })
-	            this.packagesEle = this.container.getElementsByClassName('OwO-packages')[0]
-	            for (let i = 0; i < this.packagesEle.children.length; i++) {
-	                ;(index => {
-	                    this.packagesEle.children[i].addEventListener('click', e => {
-	                        e.stopPropagation()
-	                        this.tab(index)
-	                    })
-	                })(i)
-	            }
-	            this.tab(0)
-	        }
-	
-	        toggle() {
-	            if (this.container.classList.contains('OwO-open')) {
-	                this.container.classList.remove('OwO-open')
-	            } else {
-	                this.container.classList.add('OwO-open')
-	            }
-	        }
-	
-	        tab(index) {
-	            const itemsShow = this.container.getElementsByClassName('OwO-items-show')[0]
-	            if (itemsShow) {
-	                itemsShow.classList.remove('OwO-items-show')
-	            }
-	            this.container.getElementsByClassName('OwO-items')[index].classList.add('OwO-items-show')
-	
-	            const packageActive = this.container.getElementsByClassName('OwO-package-active')[0]
-	            if (packageActive) {
-	                packageActive.classList.remove('OwO-package-active')
-	            }
-	            this.packagesEle.getElementsByTagName('li')[index].classList.add('OwO-package-active')
-	        }
-	    }
-	
-	    if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
-	        module.exports = OwO
-	    } else {
-	        window.OwO = OwO
-	    }
-	})()
-	
 </script>
 
 <style lang="less">
+	.replyMsgInfo img {
+		margin-bottom: -0.125rem;
+		img min-height: 3.5rem;
+		height: 2em;
+	}
+
 	.replyMsgInfo {
 		display: flex;
 		flex-direction: column;
diff --git a/src/js/myOwO.js b/src/js/myOwO.js
new file mode 100644
index 0000000..db9c905
--- /dev/null
+++ b/src/js/myOwO.js
@@ -0,0 +1,165 @@
+export default (() => {
+	//此js已经被魔改,和原作者的OwO.js有所不同,CVer谨慎使用.. by inleft
+	class OwO {
+		constructor(option) {
+			const defaultOption = {
+				container: document.getElementsByClassName('OwO')[0],
+				target: document.getElementsByTagName('textarea')[0],
+				position: 'down',
+				width: '100%',
+				maxHeight: '250px',
+				api: 'https://api.anotherhome.net/OwO/OwO.json'
+			}
+			for (let defaultKey in defaultOption) {
+				if (defaultOption.hasOwnProperty(defaultKey) && !option.hasOwnProperty(defaultKey)) {
+					option[defaultKey] = defaultOption[defaultKey]
+				}
+			}
+			this.container = option.container
+			this.target = option.target
+			if (option.position === 'up') {
+				this.container.classList.add('OwO-up')
+			}
+			if (option.jsonText != null && option.jsonText != undefined && option.jsonText != '') {
+				this.odata = option.jsonText
+				this.init(option)
+			} else {
+				const xhr = new XMLHttpRequest()
+				xhr.onreadystatechange = () => {
+					if (xhr.readyState === 4) {
+						if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
+							this.odata = JSON.parse(xhr.responseText)
+							this.init(option)
+						} else {
+							console.log('OwO data request was unsuccessful: ' + xhr.status)
+						}
+					}
+				}
+				xhr.open('get', option.api, true)
+				xhr.send(null)
+			}
+
+		}
+
+		init(option) {
+			this.area = option.target
+			this.packages = Object.keys(this.odata)
+
+			// fill in HTML
+			let html = `
+		            <div class="OwO-logo"><span>OωO表情</span></div>
+		            <div class="OwO-body" style="width: ${option.width}"><div class="OwO-jio"></div>`
+
+			for (let i = 0; i < this.packages.length; i++) {
+				html +=
+					`
+		                <ul class="OwO-items OwO-items-${this.odata[this.packages[i]].type}" style="max-height: ${parseInt(option.maxHeight) - 53 + 'px'};">`
+				var type = this.odata[this.packages[i]].type
+				let opackage = this.odata[this.packages[i]].container
+				for (let i = 0; i < opackage.length; i++) {
+					if (type == 'image') {
+						html +=
+							`
+		                    <li class="OwO-item" data-id="${opackage[i].data}" title="${opackage[i].text}"><img loading="lazy" class="biaoqing ${opackage[i].css}" src="${opackage[i].icon}"></li>`
+					} else {
+						html += `
+		                    <li class="OwO-item" data-id="not-given" title="${opackage[i].text}">${opackage[i].icon}</li>`
+					}
+				}
+
+				html += `
+		                </ul>`
+			}
+
+			html += `
+		                <div class="OwO-bar">
+		                    <ul class="OwO-packages">`
+
+			for (let i = 0; i < this.packages.length; i++) {
+				html += `
+		                        <li><span>${this.packages[i]}</span></li>`
+			}
+
+			html += `
+		                    </ul>
+		                </div>
+		            </div>
+		            `
+			this.container.innerHTML = html
+
+			// bind event
+			//this.logo = document.getElementsByClassName('OwO-logo')[0]
+
+			//多个logo,获取当前容器下的子节点 by inleft
+			this.logo = this.container.getElementsByClassName("OwO-logo")[0];
+
+			this.logo.addEventListener('click', e => {
+				e.stopPropagation()
+				this.toggle()
+			})
+
+			this.container.getElementsByClassName('OwO-body')[0].addEventListener('click', e => {
+				let target = null
+				if (e.target.classList.contains('OwO-item')) {
+					target = e.target
+				} else if (e.target.parentNode.classList.contains('OwO-item')) {
+					target = e.target.parentNode
+				}
+				if (target) {
+					const cursorPos = this.area.selectionEnd
+					let areaValue = this.area.value
+					//this.area.value = areaValue.slice(0, cursorPos) + target.innerHTML + areaValue.slice(cursorPos);
+					if (target.dataset.id == 'not-given') {
+						this.area.value = areaValue.slice(0, cursorPos) + target.innerHTML + areaValue
+							.slice(
+								cursorPos)
+					} else {
+						this.area.value = areaValue.slice(0, cursorPos) + target.dataset.id + areaValue
+							.slice(
+								cursorPos)
+					}
+					this.area.focus()
+					this.toggle()
+				}
+			})
+			this.packagesEle = this.container.getElementsByClassName('OwO-packages')[0]
+			for (let i = 0; i < this.packagesEle.children.length; i++) {
+				;
+				(index => {
+					this.packagesEle.children[i].addEventListener('click', e => {
+						e.stopPropagation()
+						this.tab(index)
+					})
+				})(i)
+			}
+			this.tab(0)
+		}
+
+		toggle() {
+			if (this.container.classList.contains('OwO-open')) {
+				this.container.classList.remove('OwO-open')
+			} else {
+				this.container.classList.add('OwO-open')
+			}
+		}
+
+		tab(index) {
+			const itemsShow = this.container.getElementsByClassName('OwO-items-show')[0]
+			if (itemsShow) {
+				itemsShow.classList.remove('OwO-items-show')
+			}
+			this.container.getElementsByClassName('OwO-items')[index].classList.add('OwO-items-show')
+
+			const packageActive = this.container.getElementsByClassName('OwO-package-active')[0]
+			if (packageActive) {
+				packageActive.classList.remove('OwO-package-active')
+			}
+			this.packagesEle.getElementsByTagName('li')[index].classList.add('OwO-package-active')
+		}
+	}
+	if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
+		module.exports = OwO
+	} else {
+		window.OwO = OwO
+	}
+})()

--
Gitblit v1.9.1