diff --git a/dist/Pandora.min.js b/dist/Pandora.min.js deleted file mode 100644 index b0be1db..0000000 --- a/dist/Pandora.min.js +++ /dev/null @@ -1,91 +0,0 @@ -/* - * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). - * This devtool is neither made for production nor for readable output files. - * It uses "eval()" calls to create a separate source file in the browser devtools. - * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) - * or disable the default devtool with "devtool: false". - * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). - */ -/******/ (() => { // webpackBootstrap -/******/ var __webpack_modules__ = ({ - -/***/ "./Pandora.js": -/*!********************!*\ - !*** ./Pandora.js ***! - \********************/ -/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { - -eval(";(w => {\r\n 'use strict'\r\n const OSSBase64 = __webpack_require__(/*! ./src/base64.js */ \"./src/base64.js\")\r\n const icoConfig = __webpack_require__(/*! ./src/icoConfig.json */ \"./src/icoConfig.json\")\r\n // 缺省字段\r\n const Alphabet = ['active', 'local', 'localhost', 'pandorajs.com', '127.0.0.1', '192.168', 'inherit', '提示', '错误', '警告']\r\n // 弹框集合\r\n w.pdDialogs = []\r\n\r\n // 兼容处理&&基础方法\r\n //requestAnimationFrame\r\n if (!w.requestAnimationFrame) {\r\n let lastTime, reqId\r\n w.requestAnimationFrame = callback => {\r\n const currTime = new Date().getTime(),\r\n timeToCall = Math.max(0, 16 - (currTime - lastTime)),\r\n reqId = setTimeout(() => {\r\n callback(currTime + timeToCall)\r\n }, timeToCall)\r\n lastTime = currTime + timeToCall\r\n return reqId\r\n }\r\n\r\n w.cancelAnimationFrame = reqId => {\r\n clearTimeout(reqId)\r\n }\r\n }\r\n\r\n ;(function () {\r\n //获取CSS变量\r\n const getRoot = name => {\r\n return w.getComputedStyle(document.documentElement).getPropertyValue(`--${name}`)\r\n }\r\n\r\n // 添加alert、confirm皮肤样式\r\n let rootText = ''\r\n if (!getRoot('alertTheme')) rootText += `/*alert背景*/--alertTheme:${Alphabet[6]};`\r\n if (!getRoot('alertBg')) rootText += `/*alert遮罩*/--alertBg:${Alphabet[6]};`\r\n if (!getRoot('alertFontSize')) rootText += '/*alert字体大小*/--alertFontSize:1rem;'\r\n if (!getRoot('alertColor')) rootText += '/*alert字体颜色*/--alertColor:#000;'\r\n\r\n if (!getRoot('confirmTheme')) rootText += `/*confirm背景*/--confirmTheme:#fff;`\r\n if (!getRoot('confirmBg')) rootText += `/*confirm遮罩*/--confirmBg:${Alphabet[6]};`\r\n if (!getRoot('confirmBtnBg')) rootText += '/*confirm按钮背景*/--confirmBtnBg:#fafafa;'\r\n if (!getRoot('confirmFontSize')) rootText += '/*confirm字体大小*/--confirmFontSize:1rem;'\r\n if (!getRoot('confirmColor')) rootText += '/*confirm字体颜色*/--confirmColor:#636363;'\r\n if (!getRoot('confirmBtnColor')) rootText += '/*confirm按钮字体颜色*/--confirmBtnColor:#636363;'\r\n if (!getRoot('confirmBtnBorder')) rootText += '/*confirm按钮边框颜色*/--confirmBtnBorder:#f1f1f1;'\r\n\r\n const style = document.createElement('style')\r\n style.innerText = `:root{${rootText}}`\r\n document.querySelector('head').appendChild(style)\r\n\r\n //是否已经显示遮罩\r\n let isMaskShow = !1\r\n const setGlobalCSS = (mask, maskBg, blur, plan) => {\r\n mask.style.cssText = `\r\n position:fixed;\r\n inset:0;\r\n top:0;\r\n left:0;\r\n right:0;\r\n bottom:0;\r\n z-index:999999999;\r\n width:100%;\r\n height:100%;\r\n display:flex;\r\n justify-content:center;\r\n background:${Alphabet[6]};\r\n background:${maskBg}`\r\n mask.className = 'Pd_Mask'\r\n blur.style.cssText = plan.style.cssText = `position:absolute;inset:0;top:0;left:0;right:0;bottom:0;`\r\n plan.style.cssText += `background:${Alphabet[6]};filter:blur(10px) saturate(2)`\r\n\r\n if (maskBg) plan.style.cssText += `background:rgba(255,255,255,.66)`\r\n }\r\n\r\n //修改原生alert\r\n if (w.resetAlert == undefined) {\r\n w.resetAlert = !0\r\n }\r\n if (w.resetAlert) {\r\n w.alert = (content, speed = 800) => {\r\n let timeout,\r\n mask = document.createElement(`div`),\r\n maskBg = !isMaskShow ? getRoot(`alertBg`) : null,\r\n div = document.createElement(`div`),\r\n msg = document.createElement(`p`),\r\n blur = document.createElement(`div`),\r\n plan = document.createElement(`div`),\r\n Theme = getRoot(`alertTheme`),\r\n fontSize = getRoot(`alertFontSize`),\r\n color = getRoot(`alertColor`)\r\n\r\n setGlobalCSS(mask, maskBg, blur, plan)\r\n mask.style.cssText += `align-items:flex-end`\r\n div.style.cssText = `\r\n background:${Alphabet[6]};\r\n background:${Theme};\r\n text-align:center;\r\n color:${color};\r\n font-size:${fontSize};\r\n padding:.5em 1.5em;\r\n line-height:1.3;\r\n transition:opacity .4s ease-out;\r\n margin-bottom:5vh;\r\n box-shadow:0 8px 16px rgba(0,0,0,.25);\r\n border-radius:6px;\r\n position:relative;\r\n overflow:hidden`\r\n div.id = 'Pd_alert'\r\n msg.style.cssText = `margin:0;position:relative`\r\n\r\n msg.innerText = content ? content + '' : ''\r\n div.appendChild(blur)\r\n div.appendChild(plan)\r\n div.appendChild(msg)\r\n mask.appendChild(div)\r\n document.body.appendChild(mask)\r\n\r\n mask.onclick = () => {\r\n clearTimeout(timeout)\r\n document.body.removeChild(mask)\r\n mask = div = timeout = color = null\r\n }\r\n\r\n clearTimeout(timeout)\r\n timeout = setTimeout(() => {\r\n div.style.opacity = 0\r\n div.addEventListener('transitionend', () => {\r\n document.body.removeChild(mask)\r\n mask = div = timeout = color = null\r\n })\r\n }, speed)\r\n }\r\n }\r\n\r\n //修改原生confirm\r\n if (w.resetConfirm == undefined) {\r\n w.resetConfirm = !0\r\n }\r\n if (w.resetConfirm) {\r\n w.confirm = config => {\r\n let title = config.title || '',\r\n content,\r\n confirmText,\r\n cancelText,\r\n mask = document.createElement(`div`),\r\n div = document.createElement(`div`),\r\n blur = document.createElement(`div`),\r\n plan = document.createElement(`div`),\r\n titleCon = document.createElement(`h2`),\r\n msg = document.createElement(`p`),\r\n confirm = document.createElement(`button`),\r\n cancel = document.createElement(`button`),\r\n maskBg = !isMaskShow ? getRoot(`confirmBg`) : null,\r\n btnBg = getRoot(`confirmBtnBg`),\r\n Theme = getRoot(`confirmTheme`),\r\n fontSize = getRoot(`confirmFontSize`),\r\n color = getRoot(`confirmColor`),\r\n btnColor = getRoot(`confirmBtnColor`),\r\n btnBorder = getRoot(`confirmBtnBorder`)\r\n const showConfirm = config.showConfirm == undefined ? !0 : config.showConfirm,\r\n showCancel = config.showCancel == undefined ? !0 : config.showCancel\r\n confirmText = config.confirmText ? config.confirmText.toString() : '确认'\r\n cancelText = config.cancelText ? config.cancelText.toString() : '取消'\r\n\r\n setGlobalCSS(mask, maskBg, blur, plan)\r\n mask.style.cssText += 'align-items:center;'\r\n div.style.cssText = `\r\n background:${Alphabet[6]};\r\n background:${Theme};\r\n text-align:center;\r\n color:${color};\r\n font-size:${fontSize};\r\n max-width:75vw;\r\n min-width:20em;\r\n box-shadow:0px 35px 35px -10px rgba(0,0,0,.33);\r\n border-radius:10px;\r\n position:relative;\r\n white-space: break-spaces;\r\n word-break: break-all;\r\n overflow:hidden`\r\n div.id = 'Pd_confirm'\r\n\r\n titleCon.style.cssText = `position:relative;font-size:1.3em;min-height:1em;background:${btnBg};color:${btnColor};margin:0;padding:.5em 0`\r\n msg.style.cssText = `position:relative;border-top:1px solid ${btnBorder};width:100%;max-height:70vh;border-bottom:1px solid ${btnBorder};margin:0 auto;box-sizing:border-box;padding:2em 10%;line-height:1.4;overflow:auto`\r\n const buttonCSS = `position: relative;width:${\r\n showConfirm && showCancel ? '50%' : '100%'\r\n };font-size:1em;appearance:none;background:${btnBg};color:${btnColor};border:none;border-right:1px solid ${btnBorder};padding:1em 0;cursor:pointer;outline:none`\r\n confirm.style.cssText = cancel.style.cssText = buttonCSS\r\n\r\n const removeConfirm = () => {\r\n document.body.removeChild(mask)\r\n isMaskShow = !1\r\n }\r\n\r\n if (!config.content) {\r\n content = config + ''\r\n } else {\r\n content = config.content.toString()\r\n }\r\n\r\n titleCon.innerText = title ? title.toString() : ''\r\n msg.innerText = content ? content.toString() : ''\r\n div.appendChild(blur)\r\n div.appendChild(plan)\r\n div.appendChild(titleCon)\r\n div.appendChild(msg)\r\n\r\n if (showConfirm) {\r\n confirm.innerText = confirmText\r\n div.appendChild(confirm)\r\n }\r\n if (showCancel) {\r\n cancel.innerText = cancelText\r\n div.appendChild(cancel)\r\n }\r\n\r\n mask.appendChild(div)\r\n document.body.appendChild(mask)\r\n isMaskShow = !0\r\n\r\n return new Promise((ok, no) => {\r\n if (showConfirm) {\r\n confirm.onclick = () => {\r\n removeConfirm()\r\n ok()\r\n }\r\n }\r\n\r\n if (showCancel) {\r\n cancel.onclick = () => {\r\n removeConfirm()\r\n no()\r\n }\r\n }\r\n })\r\n }\r\n }\r\n\r\n //loading遮罩\r\n const LoadingName = 'Pd_loader'\r\n let mask\r\n w.showLoading = (progress = null) => {\r\n if (document.getElementById(LoadingName)) {\r\n document.getElementById(LoadingName) && document.body.removeChild(document.getElementById(LoadingName))\r\n }\r\n mask = document.createElement('div')\r\n const svg = new Image(),\r\n em = document.createElement('em')\r\n\r\n svg.src = icoConfig.load\r\n mask.id = LoadingName\r\n mask.style.cssText =\r\n 'font-size:1rem;width:100%;height:100%;position:fixed;z-index:999999999;inset:0;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.65);display:flex;align-items:center;justify-content:center;flex-direction:column'\r\n svg.style.width = svg.style.height = '3em'\r\n mask.appendChild(svg)\r\n\r\n if (progress !== null) {\r\n em.style.cssText = 'font-style:normal;font-size:1em;color:#fff;margin-top:.5em;'\r\n em.innerText = progress\r\n mask.appendChild(em)\r\n }\r\n document.body.appendChild(mask)\r\n }\r\n w.hideLoading = () => {\r\n if (document.getElementById(LoadingName)) {\r\n document.body.removeChild(mask)\r\n }\r\n }\r\n })()\r\n\r\n //内置方法\r\n class PandoraEX {\r\n constructor(input = null) {\r\n this.getInput = obj => {\r\n if (Array.isArray(obj)) return obj\r\n if (['[object Window]', '[object HTMLDocument]'].includes(obj + '')) return w\r\n\r\n if (document.querySelectorAll(obj)) {\r\n if (document.querySelectorAll(obj).length > 1) {\r\n return document.querySelectorAll(obj)\r\n } else {\r\n if (obj) {\r\n return document.querySelector(obj)\r\n } else {\r\n return null\r\n }\r\n }\r\n } else {\r\n return console.error(`[${Alphabet[8]}] 未找到 ${obj}`)\r\n }\r\n }\r\n this.get = this.getInput(input)\r\n this.getLength = () => {\r\n if (this.get) {\r\n const { length } = this.get\r\n if (length) {\r\n return length\r\n } else {\r\n return 1\r\n }\r\n }\r\n }\r\n this.length = this.getLength()\r\n this.guid = () => {\r\n const S4 = () => {\r\n return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)\r\n }\r\n return `PandoraEX_${S4()}${S4()}-${S4()}-${S4()}-${S4()}-${S4()}${S4()}${S4()}`\r\n }\r\n //生成GUID\r\n this.pid = this.guid()\r\n //默认参数赋值\r\n this.extend = (config, options) => {\r\n if (!options) {\r\n options = config\r\n } else {\r\n Object.keys(config).forEach(e => {\r\n if (typeof options[e] === undefined || typeof options[e] === undefined + '') options[e] = config[e]\r\n })\r\n }\r\n return options\r\n }\r\n //选择指定下标元素\r\n this.eq = index => {\r\n try {\r\n if (this.getInput(input).length) {\r\n this.get = this.getInput(input)[index]\r\n } else {\r\n this.get = this.getInput(input)\r\n }\r\n } catch (err) {\r\n console.error(`[${Alphabet[8]}] 未找到该下标`, err)\r\n }\r\n return this\r\n }\r\n //选择子级元素\r\n this.child = name => {\r\n const ele = this.get\r\n try {\r\n if (ele.querySelectorAll(name).length > 1) {\r\n this.get = ele.querySelectorAll(name)\r\n } else {\r\n this.get = ele.querySelectorAll(name)[0]\r\n }\r\n } catch (err) {\r\n console.error(`[${Alphabet[8]}] 未找到该子级`, err)\r\n }\r\n return this\r\n }\r\n //查找子级元素\r\n this.find = name => {\r\n const ele = this.get\r\n try {\r\n this.get = ele.querySelectorAll(name)\r\n } catch (err) {\r\n console.error(`[${Alphabet[8]}] 未找到该子级`, err)\r\n }\r\n return this\r\n }\r\n //选择父级\r\n this.parent = () => {\r\n const ele = this.get\r\n try {\r\n this.get = ele.parentElement\r\n } catch (err) {\r\n console.error(`[${Alphabet[8]}] 未找到该父级`, err)\r\n }\r\n return this\r\n }\r\n //选择其他同级元素\r\n this.siblings = name => {\r\n const ele = this.get,\r\n parent = this.parent()\r\n let siblingArr = []\r\n\r\n for (let e of parent.child(name).get) {\r\n if (ele != e) siblingArr.push(e)\r\n }\r\n this.get = siblingArr\r\n return this\r\n }\r\n //选择上一个同级元素\r\n this.prev = () => {\r\n const ele = this.get\r\n this.get = ele.previousElementSibling\r\n return this\r\n }\r\n //选择下一个同级元素\r\n this.next = () => {\r\n const ele = this.get\r\n this.get = ele.nextElementSibling\r\n return this\r\n }\r\n //选择第一个元素\r\n this.first = () => {\r\n return this.eq(0)\r\n }\r\n //选择最后一个元素\r\n this.last = () => {\r\n const ele = this.get\r\n if (ele.length) {\r\n return this.eq(ele.length - 1)\r\n } else {\r\n return this.first()\r\n }\r\n }\r\n //遍历元素集\r\n this.each = fn => {\r\n const ele = this.get\r\n if (ele.length) {\r\n for (let i = 0; i < ele.length; i++) {\r\n fn && fn(this.eq(i), i)\r\n }\r\n } else {\r\n fn && fn(this.first(), 0)\r\n }\r\n return this\r\n }\r\n //获取或修改样式\r\n this.css = name => {\r\n const ele = this.get\r\n let style = []\r\n style = name\r\n if (style) {\r\n if (typeof style === 'string') {\r\n if (ele.length) {\r\n return w.getComputedStyle(ele[0]).getPropertyValue(style)\r\n } else {\r\n return w.getComputedStyle(ele).getPropertyValue(style)\r\n }\r\n } else {\r\n if (ele.length) {\r\n for (let the of ele) {\r\n Object.keys(style).forEach(e => {\r\n the.style[e] = style[e]\r\n })\r\n }\r\n } else {\r\n Object.keys(style).forEach(e => {\r\n ele.style[e] = style[e]\r\n })\r\n }\r\n }\r\n } else {\r\n return w.getComputedStyle(ele).getPropertyValue('*')\r\n }\r\n }\r\n //获取布局信息\r\n this.offset = () => {\r\n const ele = this.get\r\n if (ele.length) {\r\n return ele[0].getBoundingClientRect()\r\n } else {\r\n return ele.getBoundingClientRect()\r\n }\r\n }\r\n //获取或设置宽度\r\n this.width = (width = null) => {\r\n const ele = this.get\r\n if (width) {\r\n if (ele.length) {\r\n for (let the of ele) the.style.width = width\r\n } else {\r\n ele.style.width = width\r\n }\r\n } else {\r\n if (ele.length) {\r\n return ele[0].offsetWidth\r\n } else {\r\n return ele.offsetWidth\r\n }\r\n }\r\n }\r\n //获取或设置高度\r\n this.height = (height = null) => {\r\n const ele = this.get\r\n if (height) {\r\n if (ele.length) {\r\n for (let the of ele) the.style.height = height\r\n } else {\r\n ele.style.height = height\r\n }\r\n } else {\r\n if (ele.length) {\r\n return ele[0].offsetHeight\r\n } else {\r\n return ele.offsetHeight\r\n }\r\n }\r\n }\r\n //获取或插入文本\r\n this.text = str => {\r\n const ele = this.get\r\n if (str != undefined) {\r\n if (ele.length) {\r\n for (let the of ele) the.innerText = str + ''\r\n } else {\r\n ele.innerText = str + ''\r\n }\r\n } else {\r\n if (ele.length) {\r\n return ele[0].innerText\r\n } else {\r\n return ele.innerText\r\n }\r\n }\r\n return this\r\n }\r\n //获取或插入HTML\r\n this.html = content => {\r\n const ele = this.get\r\n if (content) {\r\n this.empty()\r\n if (ele.length) {\r\n for (let the of ele) the.innerHTML = content\r\n } else {\r\n ele.innerHTML = content\r\n }\r\n } else {\r\n if (ele.length) {\r\n return ele[0].innerHTML\r\n } else {\r\n return ele.innerHTML\r\n }\r\n }\r\n return this\r\n }\r\n //获取或插入值\r\n this.val = value => {\r\n const ele = this.get\r\n if (ele.nodeName.toLowerCase() == 'select') {\r\n if (value != null && value != undefined) {\r\n for (let the of ele) the.options[the.selectedIndex].value = value\r\n } else {\r\n return ele.options[ele.selectedIndex].value\r\n }\r\n } else {\r\n if (ele.length) {\r\n if (value != null && value != undefined) {\r\n for (let the of ele) the.value = value\r\n } else {\r\n return ele[0].value\r\n }\r\n } else {\r\n if (value != null && value != undefined) {\r\n ele.value = value\r\n } else {\r\n return ele.value\r\n }\r\n }\r\n }\r\n return this\r\n }\r\n //插入元素\r\n this.prepend = target => {\r\n const ele = this.get\r\n if (ele.length > 1) {\r\n if (ele.nodeName.toLowerCase() == 'select') {\r\n if (typeof target == 'object') {\r\n ele.insertBefore(target, ele.firstChild)\r\n } else {\r\n const div = document.createElement('div')\r\n div.innerHTML = target\r\n for (const dom of div.childNodes) ele.insertBefore(dom, ele.firstChild)\r\n }\r\n } else {\r\n for (let the of ele) {\r\n if (typeof target == 'object') {\r\n the.insertBefore(target, the.firstChild)\r\n } else {\r\n const div = document.createElement('div')\r\n div.innerHTML = target\r\n for (const dom of div.childNodes) the.insertBefore(dom, the.firstChild)\r\n }\r\n }\r\n }\r\n } else {\r\n if (typeof target == 'object') {\r\n ele.insertBefore(target, ele.firstChild)\r\n } else {\r\n const div = document.createElement('div')\r\n div.innerHTML = target\r\n for (const dom of div.childNodes) ele.insertBefore(dom, ele.firstChild)\r\n }\r\n }\r\n return this\r\n }\r\n this.append = target => {\r\n const ele = this.get\r\n\r\n if (ele.length > 1) {\r\n if (ele.nodeName.toLowerCase() == 'select') {\r\n if (typeof target == 'object') {\r\n ele.appendChild(target)\r\n } else {\r\n const template = document.createElement('template')\r\n template.innerHTML = target\r\n ele.appendChild(document.importNode(template.content, !0))\r\n }\r\n } else {\r\n for (let the of ele) {\r\n if (typeof target == 'object') {\r\n the.appendChild(target)\r\n } else {\r\n const template = document.createElement('template')\r\n template.innerHTML = target\r\n the.appendChild(document.importNode(template.content, !0))\r\n }\r\n }\r\n }\r\n } else {\r\n if (typeof target == 'object') {\r\n ele.appendChild(target)\r\n } else {\r\n const template = document.createElement('template')\r\n template.innerHTML = target\r\n ele.appendChild(document.importNode(template.content, !0))\r\n }\r\n }\r\n return this\r\n }\r\n //清空容器\r\n this.empty = () => {\r\n const ele = this.get\r\n if (ele.length) {\r\n for (let the of ele) {\r\n while (the.firstChild) {\r\n the.removeChild(the.firstChild)\r\n }\r\n }\r\n } else {\r\n while (ele.firstChild) {\r\n ele.removeChild(ele.firstChild)\r\n }\r\n }\r\n return this\r\n }\r\n //移除元素\r\n this.remove = () => {\r\n const ele = this.get\r\n if (ele.length) {\r\n for (let the of ele) {\r\n try {\r\n the.parentElement.removeChild(the)\r\n } catch (err) {\r\n console.error(`[${Alphabet[8]}] 未找到元素`, err)\r\n }\r\n }\r\n } else {\r\n try {\r\n ele.parentElement.removeChild(ele)\r\n } catch (err) {\r\n console.error(`[${Alphabet[8]}] 未找到元素`, err)\r\n }\r\n }\r\n return this\r\n }\r\n //添加class\r\n this.addClass = name => {\r\n const ele = this.get,\r\n addThat = the => {\r\n const beforeClass = the.classList.value\r\n if (beforeClass) {\r\n if (beforeClass.indexOf(name) < 0) the.className = `${beforeClass} ${name.trim()}`\r\n } else {\r\n the.className = name.trim()\r\n }\r\n }\r\n if (ele.length) {\r\n for (let the of ele) addThat(the)\r\n } else {\r\n addThat(ele)\r\n }\r\n return this\r\n }\r\n //移除class\r\n this.removeClass = name => {\r\n const ele = this.get,\r\n removeThat = the => {\r\n if (the.classList.value) {\r\n let beforeClass = the.classList.value.split(' '),\r\n afterClass\r\n beforeClass.map((cur, idx) => {\r\n if (cur === name) beforeClass.splice(idx, 1)\r\n })\r\n afterClass = beforeClass.join(' ')\r\n the.className = afterClass\r\n }\r\n }\r\n\r\n if (ele.length) {\r\n for (let the of ele) removeThat(the)\r\n } else {\r\n removeThat(ele)\r\n }\r\n return this\r\n }\r\n //是否拥有class名\r\n this.hasClass = name => {\r\n const ele = this.get,\r\n classlist = ele.classList.value.indexOf(' ') > -1 ? ele.classList.value.split(' ') : ele.classList.value\r\n if (classlist.indexOf(name) > -1) {\r\n return !0\r\n } else {\r\n return !1\r\n }\r\n }\r\n //添加属性\r\n this.attr = (inject, val) => {\r\n const ele = this.get\r\n if (ele.length) {\r\n if (typeof inject == 'object') {\r\n for (let the of ele) {\r\n for (let keyName in inject) the.setAttribute(keyName, inject[keyName])\r\n }\r\n return this\r\n } else {\r\n if (val) {\r\n for (let the of ele) the.setAttribute(inject, val)\r\n return this\r\n } else {\r\n return ele[0].getAttribute(inject)\r\n }\r\n }\r\n } else {\r\n if (typeof inject == 'object') {\r\n for (let keyName in inject) ele.setAttribute(keyName, inject[keyName])\r\n return this\r\n } else {\r\n if (val) {\r\n ele.setAttribute(inject, val)\r\n return this\r\n } else {\r\n return ele.getAttribute(inject)\r\n }\r\n }\r\n }\r\n }\r\n //移除属性\r\n this.removeAttr = name => {\r\n const ele = this.get\r\n if (ele.length) {\r\n for (let the of ele) the.removeAttribute(name)\r\n } else {\r\n ele.removeAttribute(name)\r\n }\r\n return this\r\n }\r\n //绑定事件\r\n this.bind = (eventName, fn, options = {}, bool = !1) => {\r\n const ele = this.get\r\n const capture = options.capture || !1,\r\n once = options.once || !1,\r\n passive = options.passive || !1\r\n\r\n if (ele.length) {\r\n let eleIndex = 0\r\n for (let the of ele) {\r\n the.addEventListener(eventName, fn, { capture, once, passive }, bool)\r\n the.index = eleIndex++\r\n the.eventList = []\r\n the.eventList.push({ name: eventName, callback: fn })\r\n }\r\n } else {\r\n ele.addEventListener(eventName, fn, { capture, once, passive }, bool)\r\n ele.eventList = []\r\n ele.eventList.push({ name: eventName, callback: fn })\r\n }\r\n return this\r\n }\r\n //解绑事件\r\n this.unbind = eventName => {\r\n const ele = this.get\r\n if (ele.length) {\r\n for (let the of ele) {\r\n if (the.eventList) {\r\n the.eventList.map((e, i) => {\r\n if (e.name === eventName) {\r\n the.removeEventListener(eventName, e.callback)\r\n the.eventList.splice(i, 1)\r\n }\r\n })\r\n }\r\n }\r\n } else {\r\n if (ele.eventList) {\r\n ele.eventList.map((e, i) => {\r\n if (e.name === eventName) {\r\n ele.removeEventListener(eventName, e.callback)\r\n ele.eventList.splice(i, 1)\r\n }\r\n })\r\n }\r\n }\r\n return this\r\n }\r\n //获取焦点\r\n this.focus = () => {\r\n const ele = this.get\r\n if (ele.length) {\r\n for (let the of ele) {\r\n the.focus()\r\n }\r\n } else {\r\n ele.focus()\r\n }\r\n return this\r\n }\r\n //移除焦点\r\n this.blur = () => {\r\n const ele = this.get\r\n if (ele.length) {\r\n for (let the of ele) {\r\n the.blur()\r\n }\r\n } else {\r\n ele.blur()\r\n }\r\n return this\r\n }\r\n //点击&触摸点击事件\r\n this.click = fn => {\r\n const ele = this.get\r\n if (ele.length) {\r\n for (let a = 0; a < ele.length; a++) {\r\n if (w.ontouchstart) {\r\n ele[a].ontouchstart = () => {\r\n this.get = ele[a]\r\n fn(this, a)\r\n }\r\n } else {\r\n ele[a].onclick = () => {\r\n this.get = ele[a]\r\n fn(this, a)\r\n }\r\n }\r\n }\r\n } else {\r\n if (w.ontouchstart) {\r\n ele.ontouchstart = () => {\r\n fn(this, null)\r\n }\r\n } else {\r\n ele.onclick = () => {\r\n fn(this, null)\r\n }\r\n }\r\n }\r\n return this\r\n }\r\n //双击事件\r\n this.dblclick = fn => {\r\n const ele = this.get\r\n if (ele.length) {\r\n for (let a = 0; a < ele.length; a++) {\r\n ele[a].ondblclick = () => {\r\n this.get = ele[a]\r\n fn(this, a)\r\n }\r\n }\r\n } else {\r\n ele.ondblclick = () => {\r\n fn(this, null)\r\n }\r\n }\r\n return this\r\n }\r\n //主动触发事件\r\n this.trigger = eventName => {\r\n const ele = this.get\r\n const event = new Event(eventName)\r\n if (ele.length) {\r\n for (let the of ele) {\r\n the.dispatchEvent(event)\r\n }\r\n } else {\r\n ele.dispatchEvent(event)\r\n }\r\n return this\r\n }\r\n //长按事件\r\n this.taping = (fn, cb) => {\r\n const ele = this.get\r\n let infiniteFrame\r\n const infiniteFn = () => {\r\n fn && fn(ele)\r\n infiniteFrame = requestAnimationFrame(infiniteFn)\r\n }\r\n\r\n if (w.ontouchstart) {\r\n ele.ontouchstart = event => {\r\n event.preventDefault()\r\n cancelAnimationFrame(infiniteFn)\r\n infiniteFn()\r\n }\r\n ele.ontouchend = () => {\r\n cb && cb(ele)\r\n cancelAnimationFrame(infiniteFrame)\r\n }\r\n } else {\r\n ele.onmousedown = () => {\r\n cancelAnimationFrame(infiniteFn)\r\n infiniteFn()\r\n }\r\n ele.onmouseup = () => {\r\n cb && cb(ele)\r\n cancelAnimationFrame(infiniteFrame)\r\n }\r\n }\r\n\r\n return this\r\n }\r\n //显示\r\n this.show = callback => {\r\n this.attr(`beforeHide`) ? this.css({ display: this.attr(`beforeHide`) }) : this.css({ display: 'block' })\r\n callback && setTimeout(callback)\r\n return this\r\n }\r\n //隐藏\r\n this.hide = callback => {\r\n if (!this.attr(`beforeHide`)) this.attr('beforeHide', this.css(`display`) == 'none' ? 'block' : this.css(`display`))\r\n this.css({ display: 'none' })\r\n callback && setTimeout(callback)\r\n return this\r\n }\r\n // 淡入\r\n this.fadeIn = (speed = 'fast', callback) => {\r\n const that = this\r\n let opacity = 0,\r\n req\r\n\r\n const fade = () => {\r\n if (opacity < 100) {\r\n switch (speed) {\r\n case 'fast':\r\n opacity += 5\r\n break\r\n case 'slow':\r\n opacity++\r\n break\r\n default:\r\n opacity += speed\r\n break\r\n }\r\n req = requestAnimationFrame(fade)\r\n } else {\r\n callback && callback()\r\n cancelAnimationFrame(req)\r\n }\r\n that.css({ opacity: opacity / 100 })\r\n }\r\n that.show(() => {\r\n that.css({ opacity: 0 })\r\n fade()\r\n })\r\n\r\n return this\r\n }\r\n // 淡出\r\n this.fadeOut = (speed = 'fast', callback) => {\r\n const that = this\r\n let opacity = 100,\r\n req\r\n\r\n const fade = () => {\r\n if (opacity > 0) {\r\n switch (speed) {\r\n case 'fast':\r\n opacity -= 5\r\n break\r\n case 'slow':\r\n opacity--\r\n break\r\n default:\r\n opacity -= speed\r\n break\r\n }\r\n req = requestAnimationFrame(fade)\r\n } else {\r\n that.hide(() => {\r\n callback && callback()\r\n cancelAnimationFrame(req)\r\n })\r\n }\r\n that.css({ opacity: opacity / 100 })\r\n }\r\n fade()\r\n return this\r\n }\r\n //ajax\r\n this.ajax = options => {\r\n let config = {\r\n //接口地址(类型:字符串)\r\n url: null,\r\n //请求类型(类型:字符串;可选参数:post、get)\r\n type: 'get',\r\n //是否同步请求(类型:布尔)\r\n async: !1,\r\n //设置请求头(类型:对象)\r\n headers: { 'Content-type': 'application/x-www-form-urlencoded' },\r\n //发送数据类型(类型:字符串;可选参数:json、form)\r\n dataType: 'json',\r\n //返回体类型(类型:字符串)\r\n responseType: 'json',\r\n //发送数据(类型:json或form;格式必须和发送数据类型保持一致)\r\n data: null,\r\n //加载中回调方法(类型:方法)\r\n progress: null,\r\n //成功回调方法(类型:方法)\r\n success: null,\r\n //失败回调方法(类型:方法)\r\n error: null,\r\n }\r\n config = this.extend(config, options)\r\n const http = new XMLHttpRequest(),\r\n { url, type, async, headers, dataType, data, progress, success, error, responseType } = config\r\n let params\r\n if (dataType == 'json') {\r\n if (data)\r\n params = Object.keys(data)\r\n .map(key => {\r\n return `${encodeURIComponent(key)}=${encodeURIComponent(data[key])}`\r\n })\r\n .join(`&`)\r\n } else {\r\n params = data\r\n }\r\n\r\n if (async) {\r\n http.responseType = responseType\r\n }\r\n\r\n try {\r\n // 监听加载中\r\n http.upload.onprogress = event => {\r\n if (event.lengthComputable) {\r\n progress && progress(Math.floor((event.loaded / event.total) * 100))\r\n }\r\n }\r\n } catch (e) {}\r\n\r\n // 向全局添加取消请求方法\r\n w.cancelAjax = () => {\r\n http.abort()\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n http.onreadystatechange = () => {\r\n if (http.status === 200 && http.readyState === 4 && http.response) {\r\n if (async) {\r\n resolve(http.response)\r\n success && success(http.response)\r\n } else {\r\n resolve(JSON.parse(http.response))\r\n success && success(JSON.parse(http.response))\r\n }\r\n }\r\n }\r\n\r\n http.onerror = err => {\r\n reject(err)\r\n error && error(err)\r\n }\r\n\r\n http.open(type.toUpperCase(), url, async)\r\n\r\n if (headers) {\r\n // 如果data是formdata类型,不设置请求头\r\n if (data && data.constructor !== FormData) {\r\n for (let keys in headers) http.setRequestHeader(keys, headers[keys])\r\n }\r\n }\r\n\r\n http.send(params)\r\n })\r\n }\r\n //fetch\r\n this.fetch = options => {\r\n let config = {\r\n //接口地址(类型:字符串)\r\n url: null,\r\n //设置请求头(类型:对象)\r\n headers: { 'Content-type': 'application/x-www-form-urlencoded' },\r\n //请求类型(类型:字符串;可选参数:post、get)\r\n type: 'get',\r\n //发送数据(类型:JSON)\r\n data: null,\r\n //返回数据格式化(类型:方法)\r\n returnData(res) {\r\n return res.json()\r\n },\r\n }\r\n config = this.extend(config, options)\r\n const { url, data, headers, type, returnData } = config\r\n\r\n return new Promise((resolve, reject) => {\r\n if (data) {\r\n fetch(url, { body: JSON.stringify(data), headers, method: type.toLocaleUpperCase() })\r\n .then(res => {\r\n if (res.ok) {\r\n return returnData(res)\r\n } else {\r\n console.error(`[${Alphabet[8]}] 请求错误`, res)\r\n }\r\n })\r\n .then(resolve)\r\n .catch(reject)\r\n } else {\r\n fetch(url, { headers, method: type.toLocaleUpperCase() })\r\n .then(res => {\r\n if (res.ok) {\r\n return returnData(res)\r\n } else {\r\n console.error(`[${Alphabet[8]}] 请求错误`, res)\r\n }\r\n })\r\n .then(resolve)\r\n .catch(reject)\r\n }\r\n })\r\n }\r\n //表单序列化\r\n this.serialize = () => {\r\n const ele = this.get\r\n let obj = {}\r\n for (let e of ele.querySelectorAll(`*`)) {\r\n if (e.getAttribute(`name`)) {\r\n const keyName = e.getAttribute(`name`)\r\n\r\n if (keyName) {\r\n switch (e.type) {\r\n case 'radio':\r\n if (e.checked) obj[keyName] = e.value\r\n break\r\n case 'checkbox':\r\n if (e.checked) {\r\n obj[keyName] = e.value\r\n } else {\r\n obj[keyName] = !1\r\n }\r\n break\r\n default:\r\n obj[keyName] = e.value\r\n break\r\n }\r\n }\r\n }\r\n }\r\n return obj\r\n }\r\n //NEW设置表单\r\n this.setForm = (obj = null) => {\r\n if (obj) {\r\n const ele = this.get,\r\n formChilds = ele.querySelectorAll(`[name]`)\r\n\r\n formChilds.forEach(e => {\r\n const keyName = e.getAttribute(`name`)\r\n if (obj[keyName]) {\r\n if (e.readOnly) return console.error(`[${Alphabet[8]}] 该元素为只读,无法设置值`)\r\n switch (e.type) {\r\n case 'radio':\r\n if (e.value == obj[keyName]) {\r\n e.checked = !0\r\n } else {\r\n e.checked = !1\r\n }\r\n break\r\n case 'checkbox':\r\n if (obj[keyName]) e.checked = !0\r\n break\r\n case 'file':\r\n e.files = obj[keyName]\r\n break\r\n case 'select':\r\n e.value = obj[keyName]\r\n break\r\n default:\r\n e.value = obj[keyName]\r\n break\r\n }\r\n }\r\n })\r\n } else {\r\n console.error(`[${Alphabet[8]}] 无可设置的表单数据`)\r\n }\r\n return this\r\n }\r\n //渲染变量\r\n this.globalData = {}\r\n //设置渲染变量\r\n this.setData = obj => {\r\n return new Promise((success, fail) => {\r\n for (let key in obj) {\r\n try {\r\n this.globalData[key] = obj[key]\r\n } catch (err) {\r\n console.error(`[${Alphabet[8]} - Mush] 变量修改失败`, err)\r\n fail(err)\r\n }\r\n }\r\n success()\r\n })\r\n }\r\n //获取渲染变量\r\n this.getData = key => {\r\n if (this.globalData[key]) {\r\n return this.globalData[key]\r\n } else {\r\n console.error(`[${Alphabet[8]} - Mush] 获取的变量不存在!`)\r\n return null\r\n }\r\n }\r\n //模板渲染\r\n this.template = (route, container) => {\r\n return new Promise((success, fail) => {\r\n const temp = (() => {\r\n let cur\r\n const template = document.querySelectorAll(`template`)\r\n for (let a = 0; a < template.length; a++) {\r\n if (template[a].getAttribute(`route`) == route) cur = template[a]\r\n }\r\n return cur\r\n })()\r\n\r\n if (temp) {\r\n this.empty()\r\n let url = temp.getAttribute('src')\r\n const that = this\r\n\r\n if (url) {\r\n that\r\n .fetch({\r\n url,\r\n headers: { 'Content-type': 'text/html' },\r\n returnData(res) {\r\n return res.text()\r\n },\r\n })\r\n .then(res => {\r\n const node = document.createElement(`template`)\r\n node.innerHTML = res\r\n if (node.content.querySelectorAll(`link`)) {\r\n let linkArr = []\r\n for (let link of node.content.querySelectorAll(`link`)) {\r\n linkArr.push(\r\n that.fetch({\r\n url: link.href,\r\n headers: { 'Content-type': 'text/html' },\r\n returnData(res) {\r\n return res.text()\r\n },\r\n })\r\n )\r\n node.content.removeChild(link)\r\n }\r\n Promise.all(linkArr).then(res => {\r\n res.map(the => {\r\n const style = document.createElement('style')\r\n style.innerHTML = the\r\n node.content.appendChild(style)\r\n })\r\n insertHTML()\r\n })\r\n } else {\r\n insertHTML()\r\n }\r\n\r\n //插入HTML\r\n function insertHTML() {\r\n container.appendChild(document.importNode(node.content, !0))\r\n for (let script of node.content.querySelectorAll(`script`)) {\r\n if (script.getAttribute('src')) {\r\n that\r\n .fetch({\r\n url: script.src,\r\n headers: { 'Content-type': 'text/html' },\r\n returnData(res) {\r\n return res.text()\r\n },\r\n })\r\n .then(res => {\r\n eval(res)\r\n })\r\n } else {\r\n eval(script.innerHTML)\r\n }\r\n }\r\n success()\r\n }\r\n })\r\n .catch(err => {\r\n console.error(`[${Alphabet[8]} - Router] 不存在以下路由:${err.target.responseURL}`)\r\n fail(`${route}`)\r\n })\r\n } else {\r\n container.appendChild(document.importNode(temp.content, !0))\r\n success()\r\n }\r\n } else {\r\n console.error(`[${Alphabet[8]} - Router] 不存在以下路由:${route}`)\r\n fail(`${route}`)\r\n }\r\n })\r\n }\r\n //获取url参数并转换成对象\r\n this.getParams = () => {\r\n const url = location.href.split(`?`)\r\n if (location.href.indexOf(`?`) > -1) {\r\n let obj = {}\r\n if (url[1].split(`&`)) {\r\n const params = url[1].split(`&`)\r\n params.map(v => {\r\n obj[v.split(`=`)[0]] = v.split(`=`)[1]\r\n })\r\n } else {\r\n obj[url[1].split(`=`)[0]] = obj[url[1].split(`=`)[1]]\r\n }\r\n return obj\r\n } else {\r\n return null\r\n }\r\n }\r\n // HASH改变\r\n this.hashChange = (callback, routes) => {\r\n const getRoutePath = () => {\r\n if (location.hash.indexOf(`#`) > -1) {\r\n return location.hash.match(/#(\\S*)\\?/) === null ? location.hash.match(/#(\\S*)/).input.replace(`#`, ``) : location.hash.match(/#(\\S*)\\?/).input.replace(`#`, ``)\r\n } else {\r\n return !1\r\n }\r\n }\r\n const routePath = getRoutePath() || routes[0].path\r\n callback(routePath)\r\n }\r\n // 数组相关方法\r\n this.Array = {\r\n // 原始数组\r\n originals: this.get,\r\n // 随机打乱数组\r\n Random() {\r\n let originals = this.originals\r\n for (let i = 0; i < originals.length; i++) originals[i] = originals[i]\r\n originals.sort(() => {\r\n return 0.5 - Math.random()\r\n })\r\n return originals\r\n },\r\n // 判断是否存在重复\r\n hasRepeat() {\r\n const originals = this.originals\r\n let hash = {}\r\n for (let i in originals) {\r\n if (hash[originals[i]]) {\r\n return !0\r\n }\r\n hash[originals[i]] = !0\r\n }\r\n return !1\r\n },\r\n // 数组求和\r\n Sum() {\r\n const arr = this.originals\r\n let s = 0\r\n for (let i = arr.length - 1; i >= 0; i--) s += arr[i]\r\n return s\r\n },\r\n }\r\n }\r\n }\r\n //拓展方法\r\n const PandoraJs = SuperClass => {\r\n return class extends SuperClass {\r\n constructor(obj) {\r\n super(obj)\r\n }\r\n //Mustache渲染\r\n Mush(options) {\r\n let config = {\r\n //渲染数据(类型:对象)\r\n data: null,\r\n //生命周期-首次渲染完成(类型:方法;返回初始渲染数据)\r\n Init: null,\r\n // 生命周期-每次更新渲染完成(类型:方法;返回最新渲染数据)\r\n Update: null,\r\n }\r\n config = this.extend(config, options)\r\n let Html = this.html(),\r\n bHtml = Html,\r\n matchValue\r\n const that = this,\r\n { data, Init, Update } = config,\r\n pattern = new RegExp('{{.*?}}', 'g'),\r\n patterns = new RegExp('{{.*?}}')\r\n\r\n // 重构渲染数据\r\n const getObj = res => {\r\n let newObj = {}\r\n for (let keyName of Object.keys(res)) newObj[keyName] = res[keyName]\r\n return newObj\r\n }\r\n\r\n // 获取所有MUSH变量\r\n const getMush = () => {\r\n let r = []\r\n Html.match(pattern).forEach((e, index) => {\r\n r[index] = e.split(`{{`)[1].split(`}}`)[0]\r\n })\r\n return r\r\n }\r\n matchValue = getMush()\r\n\r\n //渲染html\r\n const renderHtml = () => {\r\n return new Promise(next => {\r\n Html = bHtml\r\n for (let value of matchValue) {\r\n for (let keyName in data) {\r\n if (value === keyName) {\r\n Html = Html.replace(patterns, data[value] + '' || '')\r\n }\r\n }\r\n }\r\n that.html(Html)\r\n next()\r\n })\r\n }\r\n\r\n // 返回所有唯一变量\r\n const unique = array => {\r\n let r = []\r\n for (let i = 0, l = array.length; i < l; i++) {\r\n for (let j = i + 1; j < l; j++) {\r\n if (array[i] == array[j]) {\r\n j == ++i\r\n }\r\n }\r\n r.push(array[i])\r\n }\r\n return r\r\n }\r\n\r\n //遍历变量是否被动态修改\r\n unique(matchValue).forEach(e => {\r\n Object.defineProperty(that.globalData, e, {\r\n set(value) {\r\n data[e] = value\r\n renderHtml()\r\n .then(() => {\r\n Update && Update(getObj(that.globalData))\r\n })\r\n .catch(err => {\r\n console.error(`[${Alphabet[8]} - Mush] 变量更新失败`, err)\r\n })\r\n },\r\n get() {\r\n return data[e]\r\n },\r\n enumerable: !0,\r\n })\r\n })\r\n\r\n renderHtml()\r\n .then(() => {\r\n Init && Init(getObj(that.globalData))\r\n })\r\n .catch(err => {\r\n console.error(`[${Alphabet[8]} - Mush] 初始渲染失败`, err)\r\n })\r\n\r\n return this\r\n }\r\n // TODO: 静态路由 (二级目录;DOM虚拟化;完善生命周期;)\r\n Router(options) {\r\n let config = {\r\n // 路由路径集合(类型:数组)\r\n routes: null,\r\n }\r\n config = this.extend(config, options)\r\n const { routes } = config\r\n // 把路由路径集合中的path放入数组\r\n let routePath = []\r\n for (let route of routes) routePath.push(route.path)\r\n\r\n // 渲染路由\r\n const render = path => {\r\n // 创建影子节点\r\n const shadow = document.createElement('div')\r\n // 当前路由集合\r\n const { component, callback } = routes[routePath.indexOf(path)]\r\n shadow.attachShadow({ mode: 'open', serializable: true })\r\n // 读取页面\r\n fetch(component)\r\n .then(res => {\r\n return res.text()\r\n })\r\n .then(html => {\r\n shadow.innerHTML = html\r\n this.empty()\r\n // 把影子节点转换为真实节点,并插入到容器中\r\n this.append(shadow.getHTML())\r\n\r\n // 覆写影子节点下A标签\r\n const a = shadow.querySelectorAll('a')\r\n for (let e of a) {\r\n e.onclick = e => {\r\n const href = e.target.getAttribute('href')\r\n if (href) {\r\n if (!/http|https|ftp|ftps|mailto|javascript/.test(href) && href.indexOf('#') < 0) {\r\n // 阻止默认事件\r\n e.preventDefault()\r\n this.to(href)\r\n }\r\n }\r\n }\r\n }\r\n\r\n callback && callback(w.history.state)\r\n })\r\n }\r\n\r\n // 路由切换\r\n this.to = path => {\r\n // 判断路由是否带有参数\r\n let query = null\r\n if (path.indexOf('?') > -1) {\r\n query = path.split('?')[1]\r\n path = path.split('?')[0]\r\n\r\n // 把参数转换为对象\r\n let obj = {}\r\n query.split('&').map(e => {\r\n obj[e.split('=')[0]] = e.split('=')[1]\r\n })\r\n query = obj\r\n }\r\n\r\n if (routePath.includes(path)) {\r\n if (query) {\r\n // 把参数转换为字符串\r\n const queryStr = Object.keys(query).map(key => {\r\n return `${key}=${query[key]}`\r\n })\r\n w.history.replaceState(query, null, `${path}?${queryStr.join('&')}`)\r\n } else {\r\n w.history.pushState(query, null, path)\r\n }\r\n\r\n render(path)\r\n } else {\r\n console.error(`[${Alphabet[8]} - Router] ${path} 路由不存在!`)\r\n }\r\n }\r\n\r\n this.to(w.location.href.split(w.location.origin)[1])\r\n return this\r\n }\r\n //轮播切换\r\n Switcher(options) {\r\n let config = {\r\n //过渡速度/秒(类型:数字)\r\n Speed: 1,\r\n //动画曲线(类型:字符串;参考css3动画曲线)\r\n Curve: 'ease',\r\n //切换效果(类型:字符串;可选参数:slider、fade)\r\n Effect: 'slider',\r\n //方向(类型:字符串;可选参数:horizontal、vertical)\r\n Direction: 'horizontal',\r\n //惯性回弹(类型:布尔)\r\n Inertia: !0,\r\n //滑动比例(类型:数字)\r\n Distance: 3,\r\n //自动切换间隔/秒(类型:数字;为0时不自动切换)\r\n AutoSpeed: 0,\r\n //分页器(类型:布尔)\r\n Pagination: !1,\r\n //悬浮停止(类型:布尔)\r\n Hover: !1,\r\n //滚轮滚动(类型:布尔)\r\n Scroll: !1,\r\n //初始坐标(类型:数字)\r\n InitPage: 0,\r\n //循环(类型:布尔)\r\n Loop: !1,\r\n //切换状态变化(类型:方法)\r\n onChange: null,\r\n //是否窗口大小改变时自动调整(类型:布尔)\r\n AutoResize: !1,\r\n }\r\n config = this.extend(config, options)\r\n const { Speed, Curve, Effect, Direction, Inertia, Distance, AutoSpeed, Pagination, Hover, Scroll, InitPage, Loop, onChange, AutoResize } = config,\r\n childEle = this.get,\r\n parentEle = childEle[0].parentElement,\r\n total = childEle.length,\r\n transitionend = () => {\r\n if (isScrolling) {\r\n isScrolling = !1\r\n parentEle.removeEventListener('transitionend', transitionend)\r\n }\r\n }\r\n let currentPage = InitPage,\r\n childW = childEle[0].offsetWidth,\r\n childH = childEle[0].offsetHeight,\r\n AutoTimeout,\r\n isScrolling = !1,\r\n isFristTime = !0\r\n\r\n //切换\r\n const Swiper = (moveTo = null) => {\r\n if (typeof moveTo == 'number') currentPage = moveTo\r\n Pager(currentPage)\r\n if (!isFristTime) {\r\n onChange && onChange(currentPage)\r\n }\r\n switch (Effect) {\r\n case 'fade':\r\n for (let cur of childEle) {\r\n if (cur.className.indexOf('active') > -1) {\r\n cur.style.opacity = 1\r\n cur.style.zIndex = 2\r\n } else {\r\n cur.style.opacity = 0\r\n cur.style.zIndex = 1\r\n }\r\n }\r\n break\r\n default:\r\n switch (Direction) {\r\n case 'vertical':\r\n parentEle.style.transform = `translate3d(0,${-1 * (childH * currentPage)}px,0)`\r\n break\r\n case 'horizontal':\r\n default:\r\n parentEle.style.transform = `translate3d(${-1 * (childW * currentPage)}px,0,0)`\r\n break\r\n }\r\n break\r\n }\r\n if (Loop) {\r\n parentEle.addEventListener('transitionend', transitionend)\r\n } else {\r\n if (currentPage === 0 || currentPage === total - 1) {\r\n transitionend()\r\n } else {\r\n parentEle.addEventListener('transitionend', transitionend)\r\n }\r\n }\r\n }\r\n\r\n //分页器\r\n const Pager = current => {\r\n for (let e of childEle) e.className = e.className.replace(Alphabet[0], '').trim()\r\n if (childEle[currentPage].className) {\r\n childEle[currentPage].className += ` ${Alphabet[0]}`\r\n } else {\r\n childEle[currentPage].className += Alphabet[0]\r\n }\r\n if (Pagination) {\r\n parentEle.parentElement.querySelector(`.Pd-pagination`) && parentEle.parentElement.removeChild(parentEle.parentElement.querySelector(`.Pd-pagination`))\r\n const pager = document.createElement('div')\r\n pager.className = 'Pd-pagination'\r\n\r\n for (let a = 0; a < total; a++) {\r\n const pageChild = document.createElement('a'),\r\n textNode = childEle[a].getAttribute(`data-title`) ? document.createTextNode(childEle[a].getAttribute(`data-title`)) : document.createTextNode(a)\r\n pageChild.setAttribute('href', 'javascript:void 0')\r\n if (a === current) pageChild.className = Alphabet[0]\r\n pageChild.appendChild(textNode)\r\n pager.appendChild(pageChild)\r\n }\r\n parentEle.parentElement.insertBefore(pager, parentEle.nextElementSibling)\r\n\r\n for (let a = 0; a < parentEle.parentElement.querySelectorAll(`.Pd-pagination a`).length; a++) {\r\n const e = parentEle.parentElement.querySelectorAll(`.Pd-pagination a`)[a],\r\n idx = a\r\n e.onclick = () => {\r\n currentPage = idx\r\n Swiper()\r\n }\r\n }\r\n }\r\n }\r\n\r\n //上一个\r\n const Prev = () => {\r\n isFristTime = !1\r\n if (currentPage < total && currentPage > 0) {\r\n currentPage--\r\n } else if (currentPage === 0 && Loop) {\r\n currentPage = total - 1\r\n } else {\r\n isScrolling = !1\r\n }\r\n Swiper()\r\n }\r\n\r\n //下一个\r\n const Next = () => {\r\n isFristTime = !1\r\n if (currentPage < total - 1) {\r\n currentPage++\r\n } else if (currentPage === total - 1 && Loop) {\r\n currentPage = 0\r\n } else {\r\n currentPage = total - 1\r\n }\r\n Swiper()\r\n }\r\n\r\n let startX, startY, endX, endY, curX, curY\r\n //方法:滑动开始\r\n const touchStart = event => {\r\n clearTimeout(AutoTimeout)\r\n cancelAnimationFrame(AutoPlayFrame)\r\n const { pageX, pageY } = event.changedTouches[0]\r\n const { left, top } = parentEle.parentElement.getBoundingClientRect()\r\n\r\n switch (config.Direction) {\r\n case 'vertical':\r\n startY = pageY - top\r\n break\r\n case 'horizontal':\r\n default:\r\n startX = pageX - left\r\n break\r\n }\r\n parentEle.style.transition = null\r\n }\r\n\r\n //方法:滑动中\r\n const touchMove = event => {\r\n const { pageX, pageY } = event.changedTouches[0],\r\n { left, top } = parentEle.parentElement.getBoundingClientRect()\r\n curX = pageX - left\r\n curY = pageY - top\r\n\r\n switch (Effect) {\r\n case 'fade':\r\n for (let cur of childEle) cur.style.transition = `opacity ${Speed}s linear`\r\n break\r\n default:\r\n switch (Direction) {\r\n case 'vertical':\r\n if (startY > curY) {\r\n if (currentPage != total - 1) parentEle.style.transform = `translate3d(0,${-1 * (startY - curY + childH * currentPage)}px,0)`\r\n } else {\r\n if (currentPage != 0) parentEle.style.transform = `translate3d(0,${-1 * (childH * currentPage) + Math.abs(curY - startY)}px,0)`\r\n }\r\n break\r\n case 'horizontal':\r\n default:\r\n if (startX > curX) {\r\n parentEle.style.transform = `translate3d(${-1 * (startX - curX + childW * currentPage)}px,0,0)`\r\n } else {\r\n parentEle.style.transform = `translate3d(${-1 * (childW * currentPage) + Math.abs(curX - startX)}px,0,0)`\r\n }\r\n break\r\n }\r\n break\r\n }\r\n }\r\n\r\n //方法:滑动结束\r\n const touchEnd = event => {\r\n clearTimeout(AutoTimeout)\r\n AutoPlay()\r\n parentEle.style.transition = `transform ${Speed}s ${Curve}`\r\n const { pageX, pageY } = event.changedTouches[0],\r\n { left, top } = parentEle.parentElement.getBoundingClientRect()\r\n\r\n switch (Direction) {\r\n case 'vertical':\r\n endY = pageY - top\r\n switch (Effect) {\r\n case 'fade':\r\n if (startY - endY > childH / config.Distance && currentPage === total - 1) {\r\n currentPage = 0\r\n } else if (startY - endY > childH / config.Distance && currentPage < total - 1) {\r\n Next()\r\n } else if (endY - startY > childH / config.Distance) {\r\n Prev()\r\n }\r\n for (let cur of childEle) {\r\n cur.style.transition = `opacity ${config.Speed}s ${config.Curve}`\r\n cur.style.opacity = 0\r\n cur.style.zIndex = 1\r\n }\r\n childEle[currentPage].style.opacity = 1\r\n childEle[currentPage].style.zIndex = 2\r\n Swiper()\r\n break\r\n default:\r\n if (startY - endY > childH / config.Distance && currentPage < total - 1) Next()\r\n if (endY - startY > childH / config.Distance) Prev()\r\n parentEle.style.transform = `translate3d(0,${-1 * (childH * currentPage)}px,0)`\r\n break\r\n }\r\n break\r\n case 'horizontal':\r\n default:\r\n endX = pageX - left\r\n switch (Effect) {\r\n case 'fade':\r\n if (startX - endX > childW / Distance && currentPage === total - 1) {\r\n currentPage = 0\r\n } else if (startX - endX > childW / Distance && currentPage < total - 1) {\r\n Next()\r\n } else if (endX - startX > childW / Distance) {\r\n Prev()\r\n }\r\n for (let cur of childEle) {\r\n cur.style.transition = `opacity ${Speed}s ${Curve}`\r\n cur.style.opacity = 0\r\n cur.style.zIndex = 1\r\n }\r\n childEle[currentPage].style.opacity = 1\r\n childEle[currentPage].style.zIndex = 2\r\n Swiper()\r\n break\r\n default:\r\n if (startX - endX > childW / Distance && currentPage < total - 1) Next()\r\n if (endX - startX > childW / Distance) Prev()\r\n parentEle.style.transform = `translate3d(${-1 * (childW * currentPage)}px,0,0)`\r\n break\r\n }\r\n break\r\n }\r\n }\r\n\r\n //方法:滚动中\r\n const scrollMove = event => {\r\n event.preventDefault()\r\n if (event.deltaY > 20 && !isScrolling) {\r\n isScrolling = !0\r\n Next()\r\n }\r\n if (event.deltaY < -20 && !isScrolling) {\r\n isScrolling = !0\r\n Prev()\r\n }\r\n }\r\n\r\n //自动播放\r\n let AutoPlayFrame\r\n const AutoPlay = () => {\r\n if (AutoSpeed) {\r\n AutoTimeout = setTimeout(() => {\r\n Next()\r\n clearTimeout(AutoTimeout)\r\n AutoPlayFrame = requestAnimationFrame(AutoPlay)\r\n }, AutoSpeed * 1000)\r\n }\r\n }\r\n\r\n //初始化\r\n function Init() {\r\n const { width, height } = parentEle.parentElement.getBoundingClientRect()\r\n childW = width\r\n childH = height\r\n currentPage = InitPage\r\n return new Promise(next => {\r\n switch (Effect) {\r\n case 'fade':\r\n for (let cur of childEle) {\r\n cur.style.transition = `opacity ${Speed}s ${Curve}`\r\n cur.style.position = 'absolute'\r\n }\r\n parentEle.style.width = `${width}px`\r\n parentEle.style.height = `${height}px`\r\n break\r\n default:\r\n switch (Direction) {\r\n case 'vertical':\r\n parentEle.style.width = `${width}px`\r\n parentEle.style.height = `${height * total}px`\r\n parentEle.style.flexDirection = 'column'\r\n parentEle.style.cssText += 'touch-action: pan-x'\r\n break\r\n case 'horizontal':\r\n default:\r\n parentEle.style.width = `${width * total}px`\r\n parentEle.style.height = `${height}px`\r\n parentEle.style.flexDirection = 'row'\r\n parentEle.style.cssText += 'touch-action: pan-y'\r\n break\r\n }\r\n parentEle.style.display = 'flex'\r\n parentEle.style.transition = `transform ${Speed}s ${Curve}`\r\n break\r\n }\r\n\r\n //移除事件\r\n Swiper(InitPage)\r\n AutoPlay()\r\n Inertia && parentEle.removeEventListener('touchmove', touchMove)\r\n Scroll && parentEle.removeEventListener('mousewheel', scrollMove)\r\n parentEle.removeEventListener('touchstart', touchStart)\r\n parentEle.removeEventListener('touchend', touchEnd)\r\n\r\n //添加事件\r\n Inertia && parentEle.addEventListener('touchmove', touchMove)\r\n Scroll && parentEle.addEventListener('mousewheel', scrollMove)\r\n parentEle.addEventListener('touchstart', touchStart)\r\n parentEle.addEventListener('touchend', touchEnd)\r\n if (Hover) {\r\n parentEle.addEventListener('mouseover', () => {\r\n clearTimeout(AutoTimeout)\r\n cancelAnimationFrame(AutoPlayFrame)\r\n })\r\n parentEle.addEventListener('mouseout', AutoPlay)\r\n }\r\n next()\r\n })\r\n }\r\n\r\n this.prev = Prev\r\n this.next = Next\r\n this.direct = index => {\r\n isFristTime = !1\r\n Swiper(index)\r\n }\r\n this.disable = () => {\r\n Inertia && parentEle.removeEventListener('touchmove', touchMove)\r\n Scroll && parentEle.removeEventListener('mousewheel', scrollMove)\r\n parentEle.removeEventListener('touchstart', touchStart)\r\n parentEle.removeEventListener('touchend', touchEnd)\r\n clearTimeout(AutoTimeout)\r\n cancelAnimationFrame(AutoPlayFrame)\r\n }\r\n this.enable = () => {\r\n //添加事件\r\n Inertia && parentEle.addEventListener('touchmove', touchMove)\r\n Scroll && parentEle.addEventListener('mousewheel', scrollMove)\r\n parentEle.addEventListener('touchstart', touchStart)\r\n parentEle.addEventListener('touchend', touchEnd)\r\n if (Hover) {\r\n parentEle.addEventListener('mouseover', () => {\r\n clearTimeout(AutoTimeout)\r\n cancelAnimationFrame(AutoPlayFrame)\r\n })\r\n parentEle.addEventListener('mouseout', AutoPlay)\r\n }\r\n if (AutoSpeed) {\r\n AutoTimeout = setTimeout(() => {\r\n Next()\r\n clearTimeout(AutoTimeout)\r\n AutoPlayFrame = requestAnimationFrame(AutoPlay)\r\n }, AutoSpeed * 1000)\r\n }\r\n }\r\n Init()\r\n if (AutoResize) {\r\n let isResizing = !1\r\n let resizeTimer\r\n w.onresize = () => {\r\n clearTimeout(resizeTimer)\r\n resizeTimer = null\r\n if (!isResizing) {\r\n isResizing = !0\r\n resizeTimer = setTimeout(() => {\r\n Init()\r\n isResizing = !1\r\n }, 300)\r\n }\r\n }\r\n }\r\n return this\r\n }\r\n //页面&字体自适应\r\n AutoSize(options) {\r\n let config = {\r\n //固定尺寸(类型:字符串)\r\n PageSize: 'device-width',\r\n //初始缩放(类型:数字)\r\n InitScale: 1,\r\n //最小缩放(类型:数字)\r\n MinScale: 1,\r\n //最大缩放(类型:数字)\r\n MaxScale: 1,\r\n //DPI缩放(类型:数字;默认:window.devicePixelRatio)\r\n Ratio: null,\r\n //窗口变化重新计算(类型:布尔)\r\n Resize: !0,\r\n //是否缩放字体大小(类型:布尔)\r\n ScaleFont: !0,\r\n }\r\n config = this.extend(config, options)\r\n const meta = document.createElement(`meta`),\r\n { PageSize, InitScale, MinScale, MaxScale, Resize, ScaleFont } = config\r\n let Ratio = config.Ratio || w.devicePixelRatio\r\n meta.setAttribute('name', 'viewport')\r\n\r\n if (typeof PageSize !== 'number') {\r\n meta.setAttribute('content', `width=${PageSize},initial-scale=${InitScale},minimum-scale=${MinScale},maximum-scale=${MaxScale},user-scalable=no,viewport-fit=cover`)\r\n } else {\r\n meta.setAttribute('content', `width=${PageSize},user-scalable=no,viewport-fit=cover`)\r\n }\r\n\r\n if (document.querySelector(\"meta[name='viewport']\")) {\r\n document.querySelector(\"meta[name='viewport']\").remove()\r\n }\r\n\r\n document.head.appendChild(meta)\r\n\r\n if (ScaleFont) {\r\n //根据屏幕尺寸设置根元素字体大小\r\n const SetSize = () => {\r\n const { clientWidth: width, clientHeight: height } = document.documentElement\r\n document.documentElement.style.fontSize = `${(Math.min(width, height) / 10) * Ratio}px`\r\n }\r\n SetSize()\r\n if (Resize) w.onresize = SetSize\r\n }\r\n\r\n return this\r\n }\r\n //自定义弹框\r\n Dialog(options) {\r\n let config = {\r\n //是否显示遮罩\r\n mask: !0,\r\n //遮罩颜色(类型:字符串)\r\n maskColor: 'rgba(0,0,0,.85)',\r\n //点击遮罩退出(类型:布尔)\r\n maskOut: !0,\r\n //过渡速度/毫秒(类型:数字)\r\n Speed: 180,\r\n //过渡曲线(类型:字符串;参考CSS3可用曲线)\r\n Curve: 'ease-out',\r\n //进出方式(类型:字符串;none:无、zoom:缩放、top:从屏幕上方出现、bottom:从屏幕下方出现)\r\n Direction: 'zoom',\r\n //进入事件(类型:方法)\r\n In: null,\r\n //退出事件(类型:方法)\r\n Out: null,\r\n //确认事件\r\n Confirm: {\r\n //确定按钮(类型:字符串)\r\n btn: null,\r\n //回调(类型:方法;返回类型:对象)\r\n callback: null,\r\n },\r\n //取消事件\r\n Cancel: {\r\n //取消按钮(类型:字符串)\r\n btn: null,\r\n //回调(类型:方法;返回类型:对象)\r\n callback: null,\r\n },\r\n }\r\n config = this.extend(config, options)\r\n const masker = document.createElement(`div`),\r\n parent = this.get.parentElement,\r\n { mask, maskColor, maskOut, Speed, Curve, Direction, In, Out, Confirm, Cancel } = config\r\n masker.className = 'Pd-Mask'\r\n const confirmBtn = Confirm.btn ? new PandoraEX(Confirm.btn) : null,\r\n cancelBtn = Cancel.btn ? new PandoraEX(Cancel.btn) : null\r\n\r\n if (Direction !== 'none') this.css({ transition: `all ${Speed}ms ${Curve}` })\r\n\r\n //关闭弹框\r\n const closeDialog = () => {\r\n return new Promise(next => {\r\n if (this.css('display') == 'block' || this.css('display') == 'flex') {\r\n Effect(`out`)\r\n if (Direction === 'none') {\r\n try {\r\n mask && parent.removeChild(masker)\r\n } catch (err) {\r\n console.error(`[${Alphabet[8]} - Dialog]`, err)\r\n }\r\n this.css({ display: 'none' })\r\n next()\r\n } else {\r\n this.bind('transitionend', () => {\r\n try {\r\n mask && parent.removeChild(masker)\r\n } catch (err) {\r\n console.error(`[${Alphabet[8]} - Dialog]`, err)\r\n }\r\n this.css({ display: 'none' })\r\n this.unbind('transitionend')\r\n next()\r\n })\r\n }\r\n } else {\r\n next()\r\n }\r\n Confirm.btn && confirmBtn.unbind(`click`)\r\n Cancel.btn && cancelBtn.unbind(`click`)\r\n w.onresize = null\r\n })\r\n }\r\n\r\n //进入和退出效果\r\n const Effect = where => {\r\n if (mask && where === 'in') {\r\n parent.insertBefore(masker, this.get.nextElementSibling)\r\n document.querySelector(`.Pd-Mask`).style.cssText = `width:100vw;height:100vh;background:${maskColor};position:fixed;inset:0;top:0;left:0;right:0;bottom:0;z-index:998;`\r\n }\r\n\r\n switch (where) {\r\n case 'in':\r\n this.css({ display: 'block' })\r\n switch (Direction) {\r\n case 'none':\r\n this.css({ display: 'block' })\r\n break\r\n case 'top':\r\n this.css({ transform: 'translate3d(0,-100%,0)' })\r\n break\r\n case 'bottom':\r\n this.css({ transform: 'translate3d(0,100%,0)' })\r\n break\r\n case 'zoom':\r\n this.css({ transform: 'translate3d(0,0,0) scale(0)' })\r\n break\r\n }\r\n In && In()\r\n break\r\n case 'out':\r\n switch (Direction) {\r\n case 'none':\r\n this.css({ display: 'none' })\r\n break\r\n case 'top':\r\n this.css({ transform: 'translate3d(0,-100%,0)' })\r\n break\r\n case 'bottom':\r\n this.css({ transform: 'translate3d(0,100%,0)' })\r\n break\r\n case 'zoom':\r\n this.css({ transform: 'translate3d(0,0,0) scale(0)' })\r\n break\r\n }\r\n Out && Out()\r\n break\r\n }\r\n }\r\n\r\n //打开弹框\r\n const openDialog = param => {\r\n this.unbind('transitionend')\r\n for (let a of w.pdDialogs) {\r\n if (a != this) a.close()\r\n }\r\n Effect(`in`)\r\n\r\n return new Promise(next => {\r\n const calcDialog = () => {\r\n const top = parseInt(this.css(`height`)) / 2,\r\n left = parseInt(this.css(`width`)) / 2\r\n switch (Direction) {\r\n case 'none':\r\n this.css({ position: 'fixed', top: `calc(50% - ${top}px)`, left: `calc(50% - ${left}px)`, 'z-index': 999 })\r\n break\r\n case 'top':\r\n this.css({ position: 'fixed', top: 0, left: `calc(50% - ${left}px)`, 'z-index': 999, transform: 'translate3d(0,0,0) scale(1)' })\r\n break\r\n case 'bottom':\r\n this.css({ position: 'fixed', bottom: 0, left: `calc(50% - ${left}px)`, 'z-index': 999, transform: 'translate3d(0,0,0) scale(1)' })\r\n break\r\n case 'zoom':\r\n default:\r\n this.css({ position: 'fixed', top: `calc(50% - ${top}px)`, left: `calc(50% - ${left}px)`, 'z-index': 999, transform: 'translate3d(0,0,0) scale(1)' })\r\n break\r\n }\r\n }\r\n calcDialog()\r\n w.onresize = () => {\r\n this.bind('transitionend', calcDialog)\r\n }\r\n\r\n //遮罩被点击\r\n if (mask && maskOut) masker.onclick = closeDialog\r\n const { close } = this\r\n //确认按钮被点击\r\n Confirm.btn &&\r\n confirmBtn.bind('click', () => {\r\n Confirm.callback({ param: param || null, close })\r\n })\r\n //取消按钮被点击\r\n Cancel.btn &&\r\n cancelBtn.bind('click', () => {\r\n Cancel.callback({ param: param || null, close })\r\n })\r\n next()\r\n })\r\n }\r\n\r\n this.close = closeDialog\r\n this.open = openDialog\r\n\r\n w.pdDialogs.push(this)\r\n return this\r\n }\r\n //图片预加载\r\n ImgLoader(options) {\r\n let config = {\r\n //渐进式(类型:布尔)\r\n lazy: !0,\r\n //加载中(类型:方法;返回类型:数字)\r\n loading: null,\r\n //加载完成(类型:方法)\r\n callback: null,\r\n //加载错误(类型:方法)\r\n error(err) {\r\n console.error(`[${Alphabet[8]} - ImgLoader] 资源加载错误!\\n${err}`)\r\n alert('资源加载错误!')\r\n },\r\n }\r\n config = this.extend(config, options)\r\n const { lazy, loading, callback, error } = config\r\n let ImgArr = [],\r\n total = 0,\r\n cur = 0,\r\n step = 0,\r\n floatNum = 0\r\n\r\n // 类型检查\r\n const typeCheck = str => {\r\n if (str.indexOf(`url`) > -1 && str != 'none' && str.indexOf(`data:`) < 0 && str.indexOf(`blob:`) < 0) {\r\n return !0\r\n } else {\r\n return !1\r\n }\r\n }\r\n\r\n // 仅容器内获取\r\n const onlyContainer = (ele, callout) => {\r\n const pattern = new RegExp('\".*?\"', 'g'),\r\n pattern2 = new RegExp(/'.*?'/, 'g'),\r\n pattern3 = new RegExp(/\\(.*?\\)/, 'g')\r\n\r\n for (let e of ele.querySelectorAll('*')) {\r\n if (e.nodeName.toLowerCase() == 'img') {\r\n if (e.src) {\r\n ImgArr.push(e.src)\r\n }\r\n }\r\n const getBg = w.getComputedStyle(e).getPropertyValue(`background-image`)\r\n if (typeCheck(getBg)) {\r\n const url1 = getBg.match(pattern),\r\n url2 = getBg.match(pattern2),\r\n url3 = getBg.match(pattern3)\r\n\r\n url1 && ImgArr.push(url1[0].toString().replace(/\"/g, ''))\r\n url2 && ImgArr.push(url2[0].toString().replace(/'/g, ''))\r\n\r\n if (url3) {\r\n let src = url3[0].toString().replace(/\\(/, '').replace(/\\)/, '')\r\n if (src.match(pattern)) src = src.match(pattern)[0].toString().replace(/\"/g, '')\r\n if (src.match(pattern2)) src = src.match(pattern2)[0].toString().replace(/'/g, '')\r\n ImgArr.push(src)\r\n }\r\n }\r\n }\r\n callout()\r\n }\r\n\r\n // 全局获取\r\n const allResources = callout => {\r\n const pattern1 = new RegExp(`background-image: url(.*?)*`, 'g'),\r\n pattern2 = new RegExp(`background: url(.*?)*`, 'g')\r\n\r\n // 截取背景图\r\n const getThat = (type, str) => {\r\n let src\r\n switch (type) {\r\n case 1:\r\n src = str.split(`background-image: url(`)[1].split(`)`)[0]\r\n break\r\n case 2:\r\n src = str.split(`background: url(`)[1].split(`)`)[0]\r\n break\r\n }\r\n if (src.indexOf(`\"`) > -1) return src.replace(/\"/g, ``)\r\n if (src.indexOf(`'`) > -1) return src.replace(/'/g, ``)\r\n return src\r\n }\r\n\r\n document.querySelectorAll('link').forEach(css => {\r\n if (css.getAttribute('rel') == 'stylesheet') {\r\n this.ajax({\r\n url: css.getAttribute('href'),\r\n responseType: 'text',\r\n }).then(str => {\r\n if (str.match(pattern1)) {\r\n for (let a of str.match(pattern1)) {\r\n typeCheck(a) && ImgArr.push(getThat(1, a))\r\n }\r\n }\r\n if (str.match(pattern2)) {\r\n for (let a of str.match(pattern2)) {\r\n typeCheck(a) && ImgArr.push(getThat(2, a))\r\n }\r\n }\r\n })\r\n }\r\n })\r\n\r\n document.querySelectorAll('style').forEach(css => {\r\n const str = css.innerText\r\n if (str.match(pattern1)) {\r\n for (let a of str.match(pattern1)) {\r\n typeCheck(a) && ImgArr.push(getThat(1, a))\r\n }\r\n }\r\n if (str.match(pattern2)) {\r\n for (let a of str.match(pattern2)) {\r\n typeCheck(a) && ImgArr.push(getThat(2, a))\r\n }\r\n }\r\n })\r\n\r\n const bodyStr = document.body.innerHTML\r\n if (bodyStr.match(pattern1)) {\r\n for (let a of bodyStr.match(pattern1)) {\r\n typeCheck(a) && ImgArr.push(getThat(1, a))\r\n }\r\n }\r\n if (bodyStr.match(pattern2)) {\r\n for (let a of bodyStr.match(pattern2)) {\r\n typeCheck(a) && ImgArr.push(getThat(2, a))\r\n }\r\n }\r\n\r\n for (let e of document.querySelectorAll('img')) {\r\n e.src && ImgArr.push(e.src)\r\n }\r\n callout()\r\n }\r\n\r\n // 加载全部并回调\r\n const finalStep = () => {\r\n total = ImgArr.length\r\n\r\n const loader = src => {\r\n return new Promise((success, fail) => {\r\n const img = new Image()\r\n img.src = src\r\n img.onerror = fail\r\n\r\n if (img.complete) {\r\n cur++\r\n success()\r\n } else {\r\n img.onload = () => {\r\n cur++\r\n success()\r\n }\r\n }\r\n })\r\n }\r\n\r\n //加载中\r\n let loadStepFrame\r\n\r\n Promise.all(ImgArr.map(e => loader(e))).catch(err => {\r\n cancelAnimationFrame(loadStepFrame)\r\n error(err)\r\n console.error(`[${Alphabet[8]} - ImgLoader]`, err)\r\n })\r\n\r\n const loadStep = () => {\r\n step = Math.floor((cur / total) * 100)\r\n if (floatNum < 100) {\r\n if (floatNum < step) lazy ? floatNum++ : (floatNum = step)\r\n loading && loading(floatNum)\r\n if (floatNum === 100) {\r\n cancelAnimationFrame(loadStepFrame)\r\n if (lazy) {\r\n callback && callback()\r\n } else {\r\n setTimeout(callback)\r\n }\r\n } else {\r\n loadStepFrame = requestAnimationFrame(loadStep)\r\n }\r\n }\r\n }\r\n loadStep()\r\n }\r\n\r\n this.get ? onlyContainer(this.get, finalStep) : allResources(finalStep)\r\n\r\n return this\r\n }\r\n //图片上传\r\n ImgUpload(options) {\r\n let config = {\r\n //接口地址(类型:字符串)\r\n apiUrl: null,\r\n //格式限制(类型:字符串)\r\n Format: '*',\r\n //选择类型(可选参数:default、camera)\r\n type: 'default',\r\n //限制数量(类型:数字)\r\n Max: 1,\r\n //压缩比例(类型:数字)\r\n Quality: 100,\r\n //尺寸裁切\r\n Clip: {\r\n //宽度(类型:数字)\r\n width: null,\r\n //高度(类型:数字)\r\n height: null,\r\n },\r\n //是否总是覆盖\r\n alwaysCover: !1,\r\n //上传事件\r\n Events: {\r\n //超过限制(类型:方法)\r\n overMax: null,\r\n //开始上传(类型:方法)\r\n ready: null,\r\n //上传中(类型:方法;返回类型:数字)\r\n progress: null,\r\n //上传成功(类型:方法;返回类型:对象)\r\n success: null,\r\n //失败(类型:方法)\r\n fail() {\r\n console.error(`[${Alphabet[8]} - ImgUpload] 上传失败!`)\r\n },\r\n },\r\n //唯一id(类型:字符串;如果为null,则启用临时上传,请谨慎使用)\r\n Uid: null,\r\n }\r\n config = this.extend(config, options)\r\n const innerHtml = this.html(),\r\n { apiUrl, Format, type, Max, Quality, Clip, alwaysCover, Events, Uid } = config\r\n this.empty()\r\n this.get.insertAdjacentHTML('afterbegin', ``)\r\n\r\n const uploadBtn = document.createElement(`input`)\r\n let userId,\r\n total = 0,\r\n currentIndex = 0,\r\n stepsTotal = 0,\r\n stepsOnly = 0,\r\n finalTotal = 0\r\n\r\n if (Uid) {\r\n userId = Uid\r\n } else {\r\n userId = `${document.domain}_${this.pid}`\r\n }\r\n\r\n uploadBtn.type = 'file'\r\n uploadBtn.accept = `image/${Format}`\r\n uploadBtn.id = `Pd_imgUpload_${this.pid}`\r\n uploadBtn.setAttribute('capture', type)\r\n uploadBtn.hidden = !0\r\n\r\n if (Max > 1) uploadBtn.multiple = !0\r\n const label = this.get.querySelector(`label`)\r\n label.innerHTML = innerHtml\r\n label.append(uploadBtn)\r\n\r\n //上传图片\r\n const uploadPreview = obj => {\r\n const formData = new FormData()\r\n let waitUploadFile = obj\r\n if (alwaysCover) waitUploadFile = new File([obj], `cover.${obj.name.split('.')[1]}`, { type: obj.type })\r\n formData.append('images', waitUploadFile)\r\n formData.append('uid', userId)\r\n formData.append('width', Clip.width)\r\n formData.append('height', Clip.height)\r\n formData.append('quality', Quality)\r\n\r\n Events.ready && Events.ready()\r\n\r\n this.ajax({\r\n url: `${apiUrl}`,\r\n type: 'post',\r\n dataType: 'form',\r\n async: !0,\r\n headers: null,\r\n data: formData,\r\n progress(progress) {\r\n if (total > 1) {\r\n if (progress == 100) currentIndex++\r\n stepsTotal = Math.floor((currentIndex / total) * 100)\r\n Events.progress(stepsTotal)\r\n } else {\r\n stepsOnly = progress\r\n Events.progress(stepsOnly)\r\n }\r\n },\r\n })\r\n .then(res => {\r\n if (res) {\r\n if (total > 1) {\r\n finalTotal = stepsTotal\r\n } else {\r\n finalTotal = stepsOnly\r\n }\r\n uploadBtn.setAttribute('data-progress', finalTotal)\r\n if (finalTotal === 100) {\r\n const data = { src: res.images }\r\n Events.success && Events.success(data)\r\n }\r\n } else {\r\n alert('发生错误!')\r\n console.error(`[${Alphabet[8]} - ImgUpload] 服务端错误!`)\r\n }\r\n })\r\n .catch(Events.fail)\r\n }\r\n\r\n //获取选择文件\r\n const selectedFile = Files => {\r\n const files = Array.prototype.slice.call(Files)\r\n ;(total = 0), (currentIndex = 0), (stepsTotal = 0), (stepsOnly = 0), (finalTotal = 0)\r\n\r\n if (Max === 0 || files.length <= Max) {\r\n total = files.length\r\n\r\n if (total > 0) {\r\n files.forEach((file, idx) => {\r\n uploadPreview(Files[idx])\r\n })\r\n }\r\n } else {\r\n Events.overMax && Events.overMax()\r\n console.info(`[${Alphabet[7]} - ImgUpload] 超过最大数量:${Max}!`)\r\n }\r\n }\r\n\r\n //选择文件按钮事件\r\n uploadBtn.addEventListener('change', event => {\r\n event.preventDefault()\r\n selectedFile(event.target.files)\r\n })\r\n //拖动文件事件\r\n this.bind('dragover', event => {\r\n event.preventDefault()\r\n })\r\n this.bind('drop', event => {\r\n event.preventDefault()\r\n selectedFile(event.dataTransfer.files)\r\n })\r\n\r\n return this\r\n }\r\n //图片移动缩放\r\n ImgTransit(options) {\r\n let config = {\r\n //显示控制图标(类型:布尔)\r\n icon: !0,\r\n //控制图标大小(类型:数字)\r\n iconSize: 30,\r\n //显示边框(类型:布尔)\r\n border: !0,\r\n //开启多点触控(类型:布尔)\r\n Gesture: !1,\r\n //内边距(类型:数字)\r\n padding: 10,\r\n //缩放\r\n scale: {\r\n //是否启用(类型:布尔)\r\n enable: !0,\r\n //最小(类型:数字)\r\n min: 80,\r\n //最大(类型:数字)\r\n max: 150,\r\n //速率(类型:数字)\r\n rate: 1,\r\n },\r\n //旋转\r\n rotate: {\r\n //是否启用(类型:布尔)\r\n enable: !0,\r\n //速率(类型:数字)\r\n rate: 1,\r\n },\r\n //是否启用删除(类型:布尔)\r\n delete: !0,\r\n //边界限制(类型:布尔)\r\n bounds: !0,\r\n //边界可超出范围(类型:数字)\r\n outBounds: 0,\r\n //操作回调方法(类型:方法;返回类型:对象)\r\n callback: null,\r\n }\r\n config = this.extend(config, options)\r\n const that = this.get,\r\n btnAnimation = 'transition:opacity .2s ease-in',\r\n imgs = that.querySelectorAll('img')\r\n\r\n this.hide()\r\n // 创建容器\r\n if (!document.querySelector('.PD-TransitBox')) {\r\n that.insertAdjacentHTML('afterend', \"
\")\r\n document.querySelector('.PD-TransitBox').style.cssText = `position:relative;touch-action:none;`\r\n }\r\n const TransitBox = document.querySelector('.PD-TransitBox')\r\n for (let the of imgs) {\r\n TransitBox.appendChild(the)\r\n the.parentNode.removeChild(the)\r\n }\r\n\r\n //图标配置\r\n const iconStyle = option => {\r\n let positionConfig = { top: null, left: null, right: null, bottom: null, name: null }\r\n positionConfig = this.extend(positionConfig, option)\r\n return ``\r\n }\r\n\r\n const icon = {\r\n resize: iconStyle({ left: `-${config.iconSize / 2}`, bottom: `-${config.iconSize / 2}`, name: 'resize' }),\r\n rotate: iconStyle({ right: `-${config.iconSize / 2}`, top: `-${config.iconSize / 2}`, name: 'rotate' }),\r\n delete: iconStyle({ left: `-${config.iconSize / 2}`, top: `-${config.iconSize / 2}`, name: 'delete' }),\r\n }\r\n\r\n //设置参数\r\n const setConfig = (ele, eleConfig) => {\r\n for (let a of ele.querySelectorAll(`.Pd-ImgTransit-btn`)) a.style.transform = `scale(${1 / (eleConfig.scale / 100)}) rotate(${-1 * eleConfig.rotate}deg)`\r\n return (ele.style.transform = `translate3d(${eleConfig.translate}) scale(${eleConfig.scale / 100}) rotate(${eleConfig.rotate}deg)`)\r\n }\r\n\r\n //获取中心\r\n const getCenterPoint = ele => {\r\n return {\r\n x: ele.getBoundingClientRect().left + ele.offsetWidth / 2,\r\n y: ele.getBoundingClientRect().top + ele.offsetHeight / 2,\r\n }\r\n }\r\n\r\n // 获取两点距离\r\n const getDistance = (p1, p2) => {\r\n const x = p2.pageX - p1.pageX,\r\n y = p2.pageY - p1.pageY\r\n return Math.sqrt(x * x + y * y)\r\n }\r\n\r\n // 获取两点角度\r\n const getAngle = (p1, p2) => {\r\n const x = p1.pageX - p2.pageX,\r\n y = p1.pageY - p2.pageY\r\n return (Math.atan2(y, x) * 180) / Math.PI\r\n }\r\n\r\n // 多点触控\r\n const setGesture = el => {\r\n let obj = {} //定义一个对象\r\n let isTouch = !1\r\n let start = []\r\n el.addEventListener(\r\n 'touchstart',\r\n e => {\r\n if (e.touches.length >= 2) {\r\n //判断是否有两个点在屏幕上\r\n isTouch = !0\r\n start = e.touches //得到第一组两个点\r\n obj.gesturestart && obj.gesturestart.call(el) //执行gesturestart方法\r\n }\r\n },\r\n !1\r\n )\r\n document.addEventListener(\r\n 'touchmove',\r\n e => {\r\n e.preventDefault()\r\n if (e.touches.length >= 2 && isTouch) {\r\n const now = e.touches, //得到第二组两个点\r\n scale = getDistance(now[0], now[1]) / getDistance(start[0], start[1]), //得到缩放比例,getDistance是勾股定理的一个方法\r\n rotation = getAngle(now[0], now[1]) - getAngle(start[0], start[1]) //得到旋转角度,getAngle是得到夹角的一个方法\r\n\r\n e.scale = scale.toFixed(2)\r\n e.rotation = rotation.toFixed(2)\r\n obj.gesturemove && obj.gesturemove.call(el, e) //执行gesturemove方法\r\n }\r\n },\r\n !1\r\n )\r\n document.addEventListener(\r\n 'touchend',\r\n () => {\r\n if (isTouch) {\r\n isTouch = !1\r\n obj.gestureend && obj.gestureend.call(el) //执行gestureend方法\r\n }\r\n },\r\n !1\r\n )\r\n return obj\r\n }\r\n // 添加事件\r\n const addEvent = ele => {\r\n //添加容器事件\r\n let touchStart,\r\n touchEnd,\r\n touchMove,\r\n touchResize,\r\n touchRotate,\r\n touchDelete,\r\n centerPoint,\r\n prevAngle,\r\n touchX = 0,\r\n touchY = 0,\r\n startX = 0,\r\n startY = 0,\r\n prevScale = 100\r\n\r\n const eleReal = ele,\r\n eleConfig = { translate: `0,0,0`, scale: 100, rotate: 0 },\r\n w = eleReal.offsetWidth,\r\n h = eleReal.offsetHeight\r\n\r\n eleReal.style.width = `${w}px`\r\n eleReal.style.height = `${h}px`\r\n setConfig(eleReal, eleConfig)\r\n eleReal.style.position = 'absolute'\r\n eleReal.style.top = eleReal.style.left = '50%'\r\n eleReal.style.margin = `-${h / 2 + config.padding}px 0 0 -${w / 2 + config.padding}px`\r\n eleReal.style.padding = `${config.padding}px`\r\n\r\n //选中元素\r\n touchStart = event => {\r\n event.preventDefault()\r\n if (event.target.className.indexOf('pd_child') < 0) {\r\n startX = event.changedTouches[0].pageX - touchX\r\n startY = event.changedTouches[0].pageY - touchY\r\n event.target.style.transform = 'scale(1.04)'\r\n config.callback && config.callback({ type: 'choose', obj: event.target.parentElement })\r\n }\r\n }\r\n touchEnd = event => {\r\n if (event.target.className.indexOf('pd_child') < 0) event.target.style.transform = 'scale(1)'\r\n }\r\n //移动事件\r\n touchMove = event => {\r\n if (event.touches.length < 2 && event.target.className.indexOf('pd_child') < 0) {\r\n const nowX = event.changedTouches[0].pageX,\r\n nowY = event.changedTouches[0].pageY,\r\n w = event.target.getBoundingClientRect().width,\r\n h = event.target.getBoundingClientRect().height,\r\n icon = event.target.parentElement.querySelectorAll(`.Pd-ImgTransit-btn`)[0].getBoundingClientRect(),\r\n iconW = icon.width / 2,\r\n getBounding = event.target.parentElement.parentElement.getBoundingClientRect(),\r\n parentBox = {\r\n width: config.bounds ? getBounding.width + config.outBounds : getBounding.width,\r\n height: config.bounds ? getBounding.height + config.outBounds : getBounding.height,\r\n }\r\n\r\n touchX = nowX - startX\r\n touchY = nowY - startY\r\n if (config.bounds) {\r\n if (Math.abs(touchX) >= parentBox.width / 2 - w / 2 - iconW) {\r\n if (touchX < 0) {\r\n touchX = -1 * (parentBox.width / 2 - w / 2 - iconW)\r\n } else {\r\n touchX = parentBox.width / 2 - w / 2 - iconW\r\n }\r\n }\r\n if (Math.abs(touchY) >= parentBox.height / 2 - h / 2 - iconW) {\r\n if (touchY < 0) {\r\n touchY = -1 * (parentBox.height / 2 - h / 2 - iconW)\r\n } else {\r\n touchY = parentBox.height / 2 - h / 2 - iconW\r\n }\r\n }\r\n }\r\n eleConfig.translate = `${touchX}px,${touchY}px,0`\r\n setConfig(eleReal, eleConfig)\r\n config.callback && config.callback({ type: 'move', obj: eleReal })\r\n }\r\n }\r\n //缩放事件\r\n touchResize = event => {\r\n event.stopImmediatePropagation()\r\n event.preventDefault()\r\n const x = event.changedTouches[0].pageX - eleReal.getBoundingClientRect().left\r\n if (x > 0 && eleConfig.scale > config.scale.min) eleConfig.scale -= config.scale.rate\r\n if (x < 0 && eleConfig.scale < config.scale.max) eleConfig.scale += config.scale.rate\r\n if (event.touches.length >= 2) {\r\n if (config.scale.enable) {\r\n prevScale = event.scale * 100\r\n eleConfig.scale = prevScale\r\n }\r\n if (config.rotate.enable) eleConfig.rotate = event.rotation\r\n }\r\n setConfig(eleReal, eleConfig)\r\n config.callback && config.callback({ type: 'resize', obj: eleReal })\r\n }\r\n //旋转事件\r\n touchRotate = event => {\r\n event.stopImmediatePropagation()\r\n event.preventDefault()\r\n const angle = Math.atan2(event.changedTouches[0].pageY - centerPoint.y, event.changedTouches[0].pageX - centerPoint.x)\r\n eleConfig.rotate = Math.floor(((angle - prevAngle) * 180) / Math.PI) * config.rotate.rate\r\n setConfig(eleReal, eleConfig)\r\n config.callback && config.callback({ type: 'rotate', obj: eleReal })\r\n }\r\n //删除事件\r\n touchDelete = event => {\r\n event.stopImmediatePropagation()\r\n event.preventDefault()\r\n eleConfig.translate = '0,0,0'\r\n eleConfig.rotate = 0\r\n eleConfig.scale = 100\r\n setConfig(eleReal, eleConfig)\r\n eleReal.style.display = 'none'\r\n config.callback && config.callback({ type: 'delete', obj: eleReal })\r\n }\r\n //绑定所有操作\r\n eleReal.addEventListener('touchstart', touchStart)\r\n eleReal.addEventListener('touchend', touchEnd)\r\n eleReal.addEventListener('touchmove', touchMove)\r\n if (config.scale.enable && config.rotate.enable && config.Gesture) {\r\n setGesture(eleReal).gesturemove = e => {\r\n touchResize(e)\r\n touchRotate(e)\r\n }\r\n }\r\n if (config.icon && config.scale.enable) eleReal.querySelectorAll(`.Pd-resize`)[0].addEventListener('touchmove', touchResize)\r\n if (config.icon && config.rotate.enable) {\r\n eleReal.querySelectorAll(`.Pd-rotate`)[0].addEventListener('touchstart', event => {\r\n centerPoint = getCenterPoint(eleReal)\r\n prevAngle = Math.atan2(event.changedTouches[0].pageY - centerPoint.y, event.changedTouches[0].pageX - centerPoint.x) - (eleConfig.rotate * Math.PI) / 180\r\n })\r\n eleReal.querySelectorAll(`.Pd-rotate`)[0].addEventListener('touchmove', touchRotate)\r\n }\r\n if (config.icon && config.delete) eleReal.querySelectorAll(`.Pd-delete`)[0].addEventListener('touchstart', touchDelete)\r\n }\r\n\r\n //隐藏操作按钮\r\n const hideBtn = () => {\r\n const allCon = TransitBox.querySelectorAll(`.Pd-ImgTransit`),\r\n allBtn = TransitBox.querySelectorAll(`.Pd-ImgTransit-btn`)\r\n for (let a of allCon) {\r\n a.style.border = 'none'\r\n a.style.zIndex = 1\r\n }\r\n for (let a of allBtn) a.style.opacity = 0\r\n }\r\n\r\n //显示操作按钮\r\n const showBtn = tag => {\r\n const curBtn = tag.querySelectorAll(`.Pd-ImgTransit-btn`)\r\n for (let a of curBtn) {\r\n a.style.opacity = 1\r\n if (config.border) tag.style.border = '2px dashed white'\r\n tag.style.zIndex = 2\r\n }\r\n }\r\n\r\n // 初始化\r\n for (let the of imgs) {\r\n let btn = ''\r\n if (config.icon) {\r\n config.scale.enable && (btn += icon.resize)\r\n config.rotate.enable && (btn += icon.rotate)\r\n config.delete && (btn += icon.delete)\r\n }\r\n\r\n const TransitElement = document.createElement('div')\r\n TransitElement.className = `Pd-ImgTransit pd_child_${the.alt}`\r\n TransitElement.style.position = 'absolute'\r\n the.style.transition = 'transform .4s ease-in'\r\n TransitElement.innerHTML = btn\r\n TransitElement.appendChild(the)\r\n TransitBox.appendChild(TransitElement)\r\n addEvent(TransitElement)\r\n }\r\n\r\n hideBtn()\r\n //显示当前按钮\r\n TransitBox.addEventListener('touchstart', event => {\r\n hideBtn()\r\n if (event.target !== TransitBox && event.target.className.indexOf('pd_child') < 0) {\r\n config.icon ? showBtn(event.target.parentElement) : hideBtn()\r\n event.target.zIndex = 1\r\n }\r\n })\r\n\r\n return this\r\n }\r\n //微信SDK\r\n wxSDK(options) {\r\n let config = {\r\n //相关接口地址(类型:字符串)\r\n apiUrl: null,\r\n //分享sdk版本\r\n sdk: 'https://res.wx.qq.com/open/js/jweixin-1.6.0.js',\r\n //分享标题(类型:字符串或数组)\r\n title: ['分享至朋友圈', '分享至好友'],\r\n //分享描述(类型:字符串)\r\n desc: '万事皆虚,万物皆允',\r\n //分享图(类型:字符串或数组)\r\n shareIcon: `https://${Alphabet[3]}/share_ico.jpg`,\r\n //分享链接(类型:字符串或数组)\r\n shareLinks: w.location.href,\r\n //调试(类型:布尔)\r\n debug: !1,\r\n //微信jsApiList(类型:数组)\r\n jsApiList: null,\r\n //开放标签列表(类型:数组)\r\n openTagList: null,\r\n //回调方法\r\n callback: {\r\n //分享就绪(类型:方法)\r\n ready: null,\r\n //分享成功(类型:方法)\r\n success: null,\r\n //分享失败或取消(类型:方法)\r\n error: null,\r\n },\r\n }\r\n config = this.extend(config, options)\r\n const scriptTag = document.createElement('script')\r\n let { apiUrl, sdk, title, desc, shareLinks, debug, jsApiList, openTagList, callback, shareIcon } = config\r\n scriptTag.id = 'Pd_share'\r\n scriptTag.src = `${sdk}?${new Date().getTime()}`\r\n document.querySelector(`#Pd_share`) && document.querySelector(`#Pd_share`).remove()\r\n document.body.appendChild(scriptTag)\r\n let hasIcon = !1\r\n\r\n const isObj = con => {\r\n if (typeof con === 'object') {\r\n return !0\r\n } else {\r\n return !1\r\n }\r\n }\r\n\r\n document.querySelectorAll(`link`).forEach(tag => {\r\n if (tag.getAttribute(`rel`) == 'shortcut icon') {\r\n hasIcon = !0\r\n shareIcon = tag.href\r\n }\r\n })\r\n\r\n if (hasIcon) {\r\n const link = document.createElement(`link`)\r\n link.rel = 'shortcut icon'\r\n link.href = isObj(shareIcon) ? shareIcon[0] : shareIcon\r\n link.type = 'image/x-icon'\r\n document.querySelector(`head`).appendChild(link)\r\n }\r\n\r\n let jsApiLists = ['onMenuShareTimeline', 'onMenuShareAppMessage', 'updateTimelineShareData', 'updateAppMessageShareData']\r\n let openTagLists = ['wx-open-launch-app']\r\n if (jsApiList) {\r\n jsApiList.map(e => {\r\n jsApiLists.push(e)\r\n })\r\n }\r\n if (openTagList) {\r\n openTagList.map(e => {\r\n openTagLists.push(e)\r\n })\r\n }\r\n\r\n const timeLine = {\r\n title: isObj(title) ? title[0] : title,\r\n link: isObj(shareLinks) ? shareLinks[0] : shareLinks,\r\n imgUrl: isObj(shareIcon) ? shareIcon[0] : shareIcon,\r\n },\r\n friend = {\r\n title: isObj(title) ? title[1] : title,\r\n link: isObj(shareLinks) ? shareLinks[1] : shareLinks,\r\n imgUrl: isObj(shareIcon) ? shareIcon[1] : shareIcon,\r\n desc,\r\n }\r\n\r\n const success = res => {\r\n const { appId, timestamp, nonceStr, signature } = res\r\n wx.config({ debug, appId, timestamp, nonceStr, signature, jsApiList: jsApiLists, openTagList: openTagLists })\r\n wx.ready(() => {\r\n new Promise(next => {\r\n if (wx.onMenuShareTimeline) {\r\n const { title, link, imgUrl } = timeLine\r\n const { success, error } = callback\r\n wx.onMenuShareTimeline({ title, link, imgUrl, success, error })\r\n } else {\r\n const { title, link, imgUrl } = timeLine\r\n const { success, error } = callback\r\n wx.updateTimelineShareData({ title, link, imgUrl, success, error })\r\n }\r\n if (wx.onMenuShareAppMessage) {\r\n const { title, link, imgUrl, desc } = friend\r\n const { success, error } = callback\r\n wx.onMenuShareAppMessage({ title, desc, link, imgUrl, success, error })\r\n } else {\r\n const { title, link, imgUrl, desc } = friend\r\n const { success, error } = callback\r\n wx.updateAppMessageShareData({ title, desc, link, imgUrl, success, error })\r\n }\r\n next()\r\n })\r\n .then(callback.ready)\r\n .catch(err => {\r\n console.error(`[${Alphabet[8]} - wxSDK]`, err)\r\n })\r\n })\r\n }\r\n\r\n scriptTag.onload = () => {\r\n this.ajax({ url: `${apiUrl}${encodeURIComponent(w.location.href.split(`#`)[0])}` }).then(success)\r\n }\r\n\r\n return this\r\n }\r\n //懒加载\r\n LazyLoad(options) {\r\n let config = {\r\n //缺省尺寸\r\n width: 100,\r\n height: 100,\r\n //缺省图标(类型:字符串)\r\n icon: icoConfig.load,\r\n }\r\n config = this.extend(config, options)\r\n const imgArr = this.child(`img`).get,\r\n { width, height, icon } = config\r\n let cur = 0,\r\n lazyArr = []\r\n\r\n //遍历所有图片\r\n for (let img of imgArr) {\r\n if (img.dataset.src) {\r\n img.width = width\r\n img.height = height\r\n img.style.background = `url(\"${icon}\") no-repeat center,black`\r\n img.style.backgroundSize = `20%`\r\n lazyArr.push(img)\r\n }\r\n }\r\n\r\n //进入视图\r\n const inView = obj => {\r\n if (obj.getBoundingClientRect().y - w.innerHeight < 0) return obj\r\n return !1\r\n }\r\n\r\n //检测图片状态\r\n const checker = () => {\r\n lazyArr.forEach(img => {\r\n if (inView(img) && !img.src && img.complete) {\r\n img.src = inView(img).dataset.src\r\n img.style.transition = 'all .8s ease'\r\n\r\n img.onload = () => {\r\n let newWidth = Number(img.dataset.width) || img.naturalWidth,\r\n newHeight = Number(img.dataset.height) || img.naturalHeight\r\n\r\n if (img.dataset.width) newHeight = (newWidth / img.naturalWidth) * img.naturalHeight\r\n if (img.dataset.height) newWidth = (newHeight / img.naturalHeight) * img.naturalWidth\r\n\r\n img.width = newWidth\r\n img.height = newHeight\r\n img.removeAttribute('data-src')\r\n img.style.background = null\r\n img.dataset.width && img.removeAttribute('data-width')\r\n img.dataset.height && img.removeAttribute('data-height')\r\n cur++\r\n if (cur == lazyArr.length) w.removeEventListener('scroll', checker)\r\n\r\n img.addEventListener('transitionend', () => {\r\n img.style.transition = null\r\n })\r\n }\r\n\r\n img.onerror = () => {\r\n console.error(`[${Alphabet[8]} - LazyLoad] 发生错误:${img.src}!`)\r\n cur++\r\n }\r\n }\r\n })\r\n }\r\n\r\n //页面滚动事件\r\n w.addEventListener('scroll', checker)\r\n checker()\r\n\r\n return this\r\n }\r\n //上传OSS\r\n ossUpload(options) {\r\n let config = {\r\n // 阿里云账号AccessId(类型:字符串)\r\n AccessId: null,\r\n // 阿里云账号AccessKey(类型:字符串)\r\n AccessKey: null,\r\n // OSS Bucket 外网域名(类型:字符串)\r\n Endpoint: null,\r\n // 文件大小限制(类型:整数;单位:MB)\r\n maxSize: 2,\r\n }\r\n config = this.extend(config, options)\r\n const that = this\r\n const { AccessId, AccessKey, Endpoint, maxSize } = config\r\n\r\n // 引用检测\r\n try {\r\n Crypto\r\n } catch (err) {\r\n return console.error(`[${Alphabet[8]}] 缺少Crypto工具方法`, err)\r\n }\r\n if (!Crypto.HMAC) return console.error(`[${Alphabet[8]}] 缺少Crypto工具的HMAC方法`)\r\n if (!Crypto.SHA1) return console.error(`[${Alphabet[8]}] 缺少Crypto工具的SHA1方法`)\r\n\r\n // 配置检测\r\n if (!AccessId) return console.error(`[${Alphabet[8]}] 缺失阿里云账号AccessId`)\r\n if (!AccessKey) return console.error(`[${Alphabet[8]}] 缺失阿里云账号AccessKey`)\r\n if (!Endpoint) return console.error(`[${Alphabet[8]}] 缺失OSS Bucket 外网域名`)\r\n\r\n // 自动补零\r\n const padThat = str => {\r\n return str.toString().padStart(2, 0)\r\n }\r\n\r\n // 客户端签名\r\n const policyText = {\r\n // 获取失效时间\r\n expiration: (function () {\r\n let date\r\n const Year = new Date().getFullYear(),\r\n Month = new Date().getMonth() + 1,\r\n Day = new Date().getDate(),\r\n Hours = new Date().getHours()\r\n\r\n date = `${Year}-${padThat(Month)}-${padThat(Day)}T${padThat(Hours)}:00:00.000Z`\r\n return date\r\n })(),\r\n conditions: [\r\n ['content-length-range', 0, maxSize * 1024 * 1024], // 设置上传文件的大小限制\r\n ],\r\n }\r\n\r\n // 获取拓展名\r\n const getSuffix = filename => {\r\n return filename.substring(filename.lastIndexOf('.'))\r\n }\r\n\r\n // 上传文件\r\n const uploadFile = obj => {\r\n let {\r\n // 待上传文件(类型:二进制)\r\n fileObj = null,\r\n // 文件名(类型:字符串,默认生成随机文件名)\r\n fileName = that.guid(),\r\n // 上传目录名称(类型:字符串,默认根目录)\r\n dirName = '',\r\n // 上传请求头(类型:对象)\r\n headers = null,\r\n // 是否开启同步上传(类型:布尔值)\r\n async = !0,\r\n // 上传中回调(类型:方法;返回类型:数字)\r\n progress = null,\r\n } = obj\r\n\r\n const policyBase64 = OSSBase64.encode(JSON.stringify(policyText)),\r\n bytes = Crypto.HMAC(Crypto.SHA1, policyBase64, AccessKey, { asBytes: !0 }),\r\n signature = Crypto.util.bytesToBase64(bytes)\r\n\r\n return new Promise((resolve, reject) => {\r\n if (fileObj) {\r\n if (fileObj.size > maxSize * 1024 * 1024) {\r\n reject('overSize')\r\n return console.warn(`[${Alphabet[9]}] 文件大小超出最大限制`)\r\n } else {\r\n const formData = new FormData()\r\n formData.append('name', `${fileName}${getSuffix(fileObj.name)}`)\r\n const copyFile = new File([fileObj], `${fileName}${getSuffix(fileObj.name)}`, { type: fileObj.type })\r\n fileObj = copyFile\r\n formData.append('key', dirName ? `${dirName}/\\${filename\\}` : '${filename}')\r\n formData.append('policy', policyBase64)\r\n formData.append('OSSAccessKeyId', AccessId)\r\n formData.append('success_action_status', '200')\r\n formData.append('signature', signature)\r\n formData.append('file', fileObj)\r\n\r\n that\r\n .ajax({\r\n url: Endpoint,\r\n type: 'post',\r\n headers,\r\n async,\r\n dataType: 'form',\r\n data: formData,\r\n progress,\r\n })\r\n .then(() => {\r\n resolve({\r\n code: 200,\r\n msg: '上传成功',\r\n url: (function () {\r\n let url\r\n if (dirName != '') {\r\n url = `${Endpoint}/${dirName}/${fileObj.name}`\r\n } else {\r\n url = `${Endpoint}/${fileObj.name}`\r\n }\r\n return url\r\n })(),\r\n })\r\n })\r\n .catch(reject)\r\n }\r\n } else {\r\n reject('noFile')\r\n return console.warn(`[${Alphabet[9]}] 请选择需要上传的文件`)\r\n }\r\n })\r\n }\r\n\r\n this.start = uploadFile\r\n return this\r\n }\r\n }\r\n }\r\n\r\n const Pandora = class extends PandoraJs(PandoraEX) {\r\n constructor(obj = null) {\r\n super(obj)\r\n }\r\n }\r\n\r\n w.Pandora = Pandora\r\n // 判断是否引用了JQuery或者Zepto\r\n if (!w.$) {\r\n w.$ = obj => {\r\n return new Pandora(obj)\r\n }\r\n }\r\n})(window || __webpack_require__.g || self || this)\r\n\n\n//# sourceURL=webpack://pandora/./Pandora.js?"); - -/***/ }), - -/***/ "./src/base64.js": -/*!***********************!*\ - !*** ./src/base64.js ***! - \***********************/ -/***/ ((module) => { - -"use strict"; -eval("\r\n\r\nvar OSSBase64 = {\r\n // private property\r\n _keyStr: \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\",\r\n\r\n // public method for encoding\r\n encode: function (input) {\r\n var output = \"\";\r\n var chr1, chr2, chr3, enc1, enc2, enc3, enc4;\r\n var i = 0;\r\n\r\n input = OSSBase64._utf8_encode(input);\r\n\r\n while (i < input.length) {\r\n chr1 = input.charCodeAt(i++);\r\n chr2 = input.charCodeAt(i++);\r\n chr3 = input.charCodeAt(i++);\r\n\r\n enc1 = chr1 >> 2;\r\n enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\r\n enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\r\n enc4 = chr3 & 63;\r\n\r\n if (isNaN(chr2)) {\r\n enc3 = enc4 = 64;\r\n } else if (isNaN(chr3)) {\r\n enc4 = 64;\r\n }\r\n\r\n output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);\r\n }\r\n\r\n return output;\r\n },\r\n\r\n // private method for UTF-8 encoding\r\n _utf8_encode: function (string) {\r\n string = string.replace(/\\r\\n/g, \"\\n\");\r\n var utftext = \"\";\r\n\r\n for (var n = 0; n < string.length; n++) {\r\n var c = string.charCodeAt(n);\r\n\r\n if (c < 128) {\r\n utftext += String.fromCharCode(c);\r\n } else if (c > 127 && c < 2048) {\r\n utftext += String.fromCharCode((c >> 6) | 192);\r\n utftext += String.fromCharCode((c & 63) | 128);\r\n } else {\r\n utftext += String.fromCharCode((c >> 12) | 224);\r\n utftext += String.fromCharCode(((c >> 6) & 63) | 128);\r\n utftext += String.fromCharCode((c & 63) | 128);\r\n }\r\n }\r\n\r\n return utftext;\r\n },\r\n};\r\n\r\nmodule.exports = OSSBase64;\r\n\n\n//# sourceURL=webpack://pandora/./src/base64.js?"); - -/***/ }), - -/***/ "./src/icoConfig.json": -/*!****************************!*\ - !*** ./src/icoConfig.json ***! - \****************************/ -/***/ ((module) => { - -"use strict"; -eval("module.exports = JSON.parse('{\"load\":\"data:image/svg+xml;base64,PCEtLSBCeSBTYW0gSGVyYmVydCAoQHNoZXJiKSwgZm9yIGV2ZXJ5b25lLiBNb3JlIEAgaHR0cDovL2dvby5nbC83QUp6YkwgLS0+Cjxzdmcgd2lkdGg9IjM4IiBoZWlnaHQ9IjM4IiB2aWV3Qm94PSIwIDAgMzggMzgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmIj4KICAgIDxnIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMSAxKSIgc3Ryb2tlLXdpZHRoPSIyIj4KICAgICAgICAgICAgPGNpcmNsZSBzdHJva2Utb3BhY2l0eT0iLjUiIGN4PSIxOCIgY3k9IjE4IiByPSIxOCIvPgogICAgICAgICAgICA8cGF0aCBkPSJNMzYgMThjMC05Ljk0LTguMDYtMTgtMTgtMTgiPgogICAgICAgICAgICAgICAgPGFuaW1hdGVUcmFuc2Zvcm0KICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVOYW1lPSJ0cmFuc2Zvcm0iCiAgICAgICAgICAgICAgICAgICAgdHlwZT0icm90YXRlIgogICAgICAgICAgICAgICAgICAgIGZyb209IjAgMTggMTgiCiAgICAgICAgICAgICAgICAgICAgdG89IjM2MCAxOCAxOCIKICAgICAgICAgICAgICAgICAgICBkdXI9IjFzIgogICAgICAgICAgICAgICAgICAgIHJlcGVhdENvdW50PSJpbmRlZmluaXRlIi8+CiAgICAgICAgICAgIDwvcGF0aD4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPg==\",\"resize\":\"data:image/svg+xml;base64,PHN2ZyB0PSIxNTc1NzM0NTI0MDExIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9Ijg3MiIgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiPjxwYXRoIGQ9Ik00NDggNTU0LjY2NjY2NyAxNDkuMzMzMzMzIDU1NC42NjY2NjdjLTEyLjggMC0yMS4zMzMzMzMgOC41MzMzMzMtMjEuMzMzMzMzIDIxLjMzMzMzMyAwIDEyLjggOC41MzMzMzMgMjEuMzMzMzMzIDIxLjMzMzMzMyAyMS4zMzMzMzNsMjQ3LjQ2NjY2NyAwTDQ5LjA2NjY2NyA5NDUuMDY2NjY3QzQ0LjggOTQ5LjMzMzMzMyA0Mi42NjY2NjcgOTUzLjYgNDIuNjY2NjY3IDk2MGMwIDEyLjggOC41MzMzMzMgMjEuMzMzMzMzIDIxLjMzMzMzMyAyMS4zMzMzMzMgNi40IDAgMTAuNjY2NjY3LTIuMTMzMzMzIDE0LjkzMzMzMy02LjRMNDI2LjY2NjY2NyA2MjcuMiA0MjYuNjY2NjY3IDg3NC42NjY2NjdjMCAxMi44IDguNTMzMzMzIDIxLjMzMzMzMyAyMS4zMzMzMzMgMjEuMzMzMzMzczIxLjMzMzMzMy04LjUzMzMzMyAyMS4zMzMzMzMtMjEuMzMzMzMzTDQ2OS4zMzMzMzMgNTc2QzQ2OS4zMzMzMzMgNTYzLjIgNDYwLjggNTU0LjY2NjY2NyA0NDggNTU0LjY2NjY2N3pNOTgxLjMzMzMzMyA2NGMwLTEyLjgtOC41MzMzMzMtMjEuMzMzMzMzLTIxLjMzMzMzMy0yMS4zMzMzMzMtNi40IDAtMTAuNjY2NjY3IDIuMTMzMzMzLTE0LjkzMzMzMyA2LjRMNTk3LjMzMzMzMyAzOTYuOCA1OTcuMzMzMzMzIDE0OS4zMzMzMzNjMC0xMi44LTguNTMzMzMzLTIxLjMzMzMzMy0yMS4zMzMzMzMtMjEuMzMzMzMzcy0yMS4zMzMzMzMgOC41MzMzMzMtMjEuMzMzMzMzIDIxLjMzMzMzM2wwIDI5OC42NjY2NjdjMCAxMi44IDguNTMzMzMzIDIxLjMzMzMzMyAyMS4zMzMzMzMgMjEuMzMzMzMzbDI5OC42NjY2NjcgMGMxMi44IDAgMjEuMzMzMzMzLTguNTMzMzMzIDIxLjMzMzMzMy0yMS4zMzMzMzNzLTguNTMzMzMzLTIxLjMzMzMzMy0yMS4zMzMzMzMtMjEuMzMzMzMzTDYyNy4yIDQyNi42NjY2NjcgOTc0LjkzMzMzMyA3OC45MzMzMzNDOTc5LjIgNzQuNjY2NjY3IDk4MS4zMzMzMzMgNzAuNCA5ODEuMzMzMzMzIDY0eiIgcC1pZD0iODczIiBmaWxsPSIjMmMyYzJjIj48L3BhdGg+PC9zdmc+\",\"delete\":\"data:image/svg+xml;base64,PHN2ZyB0PSIxNTc2MzUwMTU3MzM4IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjE4ODQiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNNTcxLjczMzMzMyA1MTJsMjI2LjEzMzMzNC0yMjYuMTMzMzMzYzE3LjA2NjY2Ny0xNy4wNjY2NjcgMTcuMDY2NjY3LTQyLjY2NjY2NyAwLTU5LjczMzMzNHMtNDIuNjY2NjY3LTE3LjA2NjY2Ny01OS43MzMzMzQgMEw1MTIgNDUyLjI2NjY2NyAyODUuODY2NjY3IDIyNi4xMzMzMzNjLTE3LjA2NjY2Ny0xNy4wNjY2NjctNDIuNjY2NjY3LTE3LjA2NjY2Ny01OS43MzMzMzQgMHMtMTcuMDY2NjY3IDQyLjY2NjY2NyAwIDU5LjczMzMzNGwyMjYuMTMzMzM0IDIyNi4xMzMzMzMtMjI2LjEzMzMzNCAyMjYuMTMzMzMzYy0xNy4wNjY2NjcgMTcuMDY2NjY3LTE3LjA2NjY2NyA0Mi42NjY2NjcgMCA1OS43MzMzMzQgOC41MzMzMzMgOC41MzMzMzMgMTcuMDY2NjY3IDEyLjggMjkuODY2NjY3IDEyLjhzMjEuMzMzMzMzLTQuMjY2NjY3IDI5Ljg2NjY2Ny0xMi44bDIyNi4xMzMzMzMtMjI2LjEzMzMzNCAyMjYuMTMzMzMzIDIyNi4xMzMzMzRjOC41MzMzMzMgOC41MzMzMzMgMjEuMzMzMzMzIDEyLjggMjkuODY2NjY3IDEyLjhzMjEuMzMzMzMzLTQuMjY2NjY3IDI5Ljg2NjY2Ny0xMi44YzE3LjA2NjY2Ny0xNy4wNjY2NjcgMTcuMDY2NjY3LTQyLjY2NjY2NyAwLTU5LjczMzMzNEw1NzEuNzMzMzMzIDUxMnoiIHAtaWQ9IjE4ODUiIGZpbGw9IiMyYzJjMmMiPjwvcGF0aD48L3N2Zz4=\",\"rotate\":\"data:image/svg+xml;base64,PHN2ZyB0PSIxNTc1NzM0NTgyNzcwIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDExMTggMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjE4MTgiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMTY1LjIzODg5OSA1MDguMTc4NTA2QzE2NC40NTAzNjkgNDU2LjQ0MjY3NiAxNzEuNzY3Nzc5IDQwNC40ODU4NDIgMTg3LjI0NDU0MiAzNTMuODYzNjMxIDI2Ni4xMzg2MzIgOTUuODEyNjkyIDUzMy40MzYyMjUtNTEuMzUzMDI4IDc4NC4zODAyMjQgMjUuMzY4MjUxIDEwMzUuMzI0MjE5IDEwMi4wODk1MyAxMTc0LjYyOTk0IDM3My41NjYzNTkgMTA5NS43MzU4NTEgNjMxLjYxNzI5OCAxMDE2Ljg0MTc2IDg4OS42NjgyNCA3NDkuNTQ0MTY4IDEwMzYuODMzOTU5IDQ5OC42MDAxNzIgOTYwLjExMjY4IDQyNC4xMzQ3NDEgOTM3LjM0NjMxMyAzNTcuODM3ODMzIDg5Ni44NzA3ODggMzAzLjk3Mzg2OCA4NDIuMjc2NDM2IDI5MS4zMTAzMjggODI5LjQ0MTE3NiAyOTEuMzk2NTA2IDgwOC40OTU4MDIgMzA0LjE2NjM1NiA3OTUuNDkzNjI1IDMxNi45MzYyMDUgNzgyLjQ5MTQ1MiAzMzcuNTU0MDQyIDc4Mi4zNTYxMzYgMzUwLjIxNzU4MiA3OTUuMTkxMzk3IDM5Ni42NDA1ODcgODQyLjI0Mzg4OSA0NTMuNzMxMzcgODc3LjA5ODkwMSA1MTcuOTc1MDkxIDg5Ni43NDAxNzcgNzM0LjQzNjk2NiA5NjIuOTE5MjEzIDk2NS4zMjAzMzUgODM1LjgwMjAyOCAxMDMzLjU1NzczNyA2MTIuNjA3NTQxIDExMDEuNzk1MTM5IDM4OS40MTMwNTcgOTgxLjQ2NzE3OSAxNTQuOTE5NzkyIDc2NS4wMDUzMDUgODguNzQwNzU1IDU0OC41NDM0MjggMjIuNTYxNzE4IDMxNy42NjAwNTYgMTQ5LjY3ODkwNCAyNDkuNDIyNjU1IDM3Mi44NzMzODggMjM1LjU5NzE5OCA0MTguMDk0NDE4IDIyOS4yOTQ4NzEgNDY0LjQ2MTAzOSAyMzAuNDQwMyA1MTAuNTU5ODgxTDMxMS4yNDA5NzggNDI5Ljc1OTIwMkMzMjMuNTg0MDk0IDQxNy40MTYwODUgMzQzLjg5MjUxMyA0MTcuNzEyMzU3IDM1Ni42MDEwOTkgNDMwLjQyMDk0NiAzNjkuMzA5Njg2IDQ0My4xMjk1MzUgMzY5LjYwNTk1OSA0NjMuNDM3OTUyIDM1Ny4yNjI4NDIgNDc1Ljc4MTA2OEwyMzAuNzc4NzgyIDYwMi4yNjUxMjhDMjI5LjI3MzgyNiA2MDUuNzY5Njc5IDIyNy4wOTg4NzcgNjA5LjA0MTM5NiAyMjQuMjUxMTQ1IDYxMS44ODkxMjggMjExLjkwODAyOSA2MjQuMjMyMjQ1IDE5MS41OTk2MSA2MjMuOTM1OTc0IDE3OC44OTEwMjQgNjExLjIyNzM4NUw0MC44MjU0MjggNDczLjE2MTc5QzI4LjExNjg0IDQ2MC40NTMyMDYgMjcuODIwNTY5IDQ0MC4xNDQ3ODQgNDAuMTYzNjg1IDQyNy44MDE2NjggNTIuNTA2ODAxIDQxNS40NTg1NTEgNzIuODE1MjE4IDQxNS43NTQ4MjcgODUuNTIzODA2IDQyOC40NjM0MTFMMTY1LjIzODg5OSA1MDguMTc4NTA2WiIgcC1pZD0iMTgxOSIgZmlsbD0iIzJjMmMyYyI+PC9wYXRoPjwvc3ZnPg==\"}');\n\n//# sourceURL=webpack://pandora/./src/icoConfig.json?"); - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/global */ -/******/ (() => { -/******/ __webpack_require__.g = (function() { -/******/ if (typeof globalThis === 'object') return globalThis; -/******/ try { -/******/ return this || new Function('return this')(); -/******/ } catch (e) { -/******/ if (typeof window === 'object') return window; -/******/ } -/******/ })(); -/******/ })(); -/******/ -/************************************************************************/ -/******/ -/******/ // startup -/******/ // Load entry module and return exports -/******/ // This entry module is referenced by other modules so it can't be inlined -/******/ var __webpack_exports__ = __webpack_require__("./Pandora.js"); -/******/ -/******/ })() -; \ No newline at end of file diff --git a/dist/atom-one-light.css b/dist/atom-one-light.css deleted file mode 100644 index 4ae2c63..0000000 --- a/dist/atom-one-light.css +++ /dev/null @@ -1,94 +0,0 @@ -/* - -Atom One Light by Daniel Gamage -Original One Light Syntax theme from https://github.com/atom/one-light-syntax - -base: #fafafa -mono-1: #383a42 -mono-2: #686b77 -mono-3: #a0a1a7 -hue-1: #0184bb -hue-2: #4078f2 -hue-3: #a626a4 -hue-4: #50a14f -hue-5: #e45649 -hue-5-2: #c91243 -hue-6: #986801 -hue-6-2: #c18401 - -*/ - -.hljs { - color: #383a42; - background: #fafafa; -} - -.hljs-comment, -.hljs-quote { - color: #a0a1a7; - font-style: italic; -} - -.hljs-doctag, -.hljs-keyword, -.hljs-formula { - color: #a626a4; -} - -.hljs-section, -.hljs-name, -.hljs-selector-tag, -.hljs-deletion, -.hljs-subst { - color: #e45649; -} - -.hljs-literal { - color: #0184bb; -} - -.hljs-string, -.hljs-regexp, -.hljs-addition, -.hljs-attribute, -.hljs-meta .hljs-string { - color: #50a14f; -} - -.hljs-attr, -.hljs-variable, -.hljs-template-variable, -.hljs-type, -.hljs-selector-class, -.hljs-selector-attr, -.hljs-selector-pseudo, -.hljs-number { - color: #986801; -} - -.hljs-symbol, -.hljs-bullet, -.hljs-link, -.hljs-meta, -.hljs-selector-id, -.hljs-title { - color: #4078f2; -} - -.hljs-built_in, -.hljs-title.class_, -.hljs-class .hljs-title { - color: #c18401; -} - -.hljs-emphasis { - font-style: italic; -} - -.hljs-strong { - font-weight: bold; -} - -.hljs-link { - text-decoration: underline; -} diff --git a/dist/highlight.min.js b/dist/highlight.min.js deleted file mode 100644 index cf57240..0000000 --- a/dist/highlight.min.js +++ /dev/null @@ -1,1207 +0,0 @@ -/*! - Highlight.js v11.8.0 (git: 65687a907b) - (c) 2006-2023 undefined and other contributors - License: BSD-3-Clause - */ -var hljs=function(){"use strict";function e(n){ -return n instanceof Map?n.clear=n.delete=n.set=()=>{ -throw Error("map is read-only")}:n instanceof Set&&(n.add=n.clear=n.delete=()=>{ -throw Error("set is read-only") -}),Object.freeze(n),Object.getOwnPropertyNames(n).forEach((t=>{ -const a=n[t],i=typeof a;"object"!==i&&"function"!==i||Object.isFrozen(a)||e(a) -})),n}class n{constructor(e){ -void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1} -ignoreMatch(){this.isMatchIgnored=!0}}function t(e){ -return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'") -}function a(e,...n){const t=Object.create(null);for(const n in e)t[n]=e[n] -;return n.forEach((e=>{for(const n in e)t[n]=e[n]})),t}const i=e=>!!e.scope -;class r{constructor(e,n){ -this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){ -this.buffer+=t(e)}openNode(e){if(!i(e))return;const n=((e,{prefix:n})=>{ -if(e.startsWith("language:"))return e.replace("language:","language-") -;if(e.includes(".")){const t=e.split(".") -;return[`${n}${t.shift()}`,...t.map(((e,n)=>`${e}${"_".repeat(n+1)}`))].join(" ") -}return`${n}${e}`})(e.scope,{prefix:this.classPrefix});this.span(n)} -closeNode(e){i(e)&&(this.buffer+="")}value(){return this.buffer}span(e){ -this.buffer+=``}}const s=(e={})=>{const n={children:[]} -;return Object.assign(n,e),n};class o{constructor(){ -this.rootNode=s(),this.stack=[this.rootNode]}get top(){ -return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){ -this.top.children.push(e)}openNode(e){const n=s({scope:e}) -;this.add(n),this.stack.push(n)}closeNode(){ -if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){ -for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)} -walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){ -return"string"==typeof n?e.addText(n):n.children&&(e.openNode(n), -n.children.forEach((n=>this._walk(e,n))),e.closeNode(n)),e}static _collapse(e){ -"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{ -o._collapse(e)})))}}class l extends o{constructor(e){super(),this.options=e} -addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){ -this.closeNode()}__addSublanguage(e,n){const t=e.root -;n&&(t.scope="language:"+n),this.add(t)}toHTML(){ -return new r(this,this.options).value()}finalize(){ -return this.closeAllNodes(),!0}}function c(e){ -return e?"string"==typeof e?e:e.source:null}function d(e){return b("(?=",e,")")} -function g(e){return b("(?:",e,")*")}function u(e){return b("(?:",e,")?")} -function b(...e){return e.map((e=>c(e))).join("")}function m(...e){const n=(e=>{ -const n=e[e.length-1] -;return"object"==typeof n&&n.constructor===Object?(e.splice(e.length-1,1),n):{} -})(e);return"("+(n.capture?"":"?:")+e.map((e=>c(e))).join("|")+")"} -function p(e){return RegExp(e.toString()+"|").exec("").length-1} -const _=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./ -;function h(e,{joinWith:n}){let t=0;return e.map((e=>{t+=1;const n=t -;let a=c(e),i="";for(;a.length>0;){const e=_.exec(a);if(!e){i+=a;break} -i+=a.substring(0,e.index), -a=a.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?i+="\\"+(Number(e[1])+n):(i+=e[0], -"("===e[0]&&t++)}return i})).map((e=>`(${e})`)).join(n)} -const f="[a-zA-Z]\\w*",E="[a-zA-Z_]\\w*",y="\\b\\d+(\\.\\d+)?",N="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",w="\\b(0b[01]+)",v={ -begin:"\\\\[\\s\\S]",relevance:0},O={scope:"string",begin:"'",end:"'", -illegal:"\\n",contains:[v]},k={scope:"string",begin:'"',end:'"',illegal:"\\n", -contains:[v]},x=(e,n,t={})=>{const i=a({scope:"comment",begin:e,end:n, -contains:[]},t);i.contains.push({scope:"doctag", -begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)", -end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0}) -;const r=m("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/) -;return i.contains.push({begin:b(/[ ]+/,"(",r,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),i -},M=x("//","$"),S=x("/\\*","\\*/"),A=x("#","$");var C=Object.freeze({ -__proto__:null,MATCH_NOTHING_RE:/\b\B/,IDENT_RE:f,UNDERSCORE_IDENT_RE:E, -NUMBER_RE:y,C_NUMBER_RE:N,BINARY_NUMBER_RE:w, -RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~", -SHEBANG:(e={})=>{const n=/^#![ ]*\// -;return e.binary&&(e.begin=b(n,/.*\b/,e.binary,/\b.*/)),a({scope:"meta",begin:n, -end:/$/,relevance:0,"on:begin":(e,n)=>{0!==e.index&&n.ignoreMatch()}},e)}, -BACKSLASH_ESCAPE:v,APOS_STRING_MODE:O,QUOTE_STRING_MODE:k,PHRASAL_WORDS_MODE:{ -begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/ -},COMMENT:x,C_LINE_COMMENT_MODE:M,C_BLOCK_COMMENT_MODE:S,HASH_COMMENT_MODE:A, -NUMBER_MODE:{scope:"number",begin:y,relevance:0},C_NUMBER_MODE:{scope:"number", -begin:N,relevance:0},BINARY_NUMBER_MODE:{scope:"number",begin:w,relevance:0}, -REGEXP_MODE:{begin:/(?=\/[^/\n]*\/)/,contains:[{scope:"regexp",begin:/\//, -end:/\/[gimuy]*/,illegal:/\n/,contains:[v,{begin:/\[/,end:/\]/,relevance:0, -contains:[v]}]}]},TITLE_MODE:{scope:"title",begin:f,relevance:0}, -UNDERSCORE_TITLE_MODE:{scope:"title",begin:E,relevance:0},METHOD_GUARD:{ -begin:"\\.\\s*"+E,relevance:0},END_SAME_AS_BEGIN:e=>Object.assign(e,{ -"on:begin":(e,n)=>{n.data._beginMatch=e[1]},"on:end":(e,n)=>{ -n.data._beginMatch!==e[1]&&n.ignoreMatch()}})});function T(e,n){ -"."===e.input[e.index-1]&&n.ignoreMatch()}function R(e,n){ -void 0!==e.className&&(e.scope=e.className,delete e.className)}function D(e,n){ -n&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)", -e.__beforeBegin=T,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords, -void 0===e.relevance&&(e.relevance=0))}function I(e,n){ -Array.isArray(e.illegal)&&(e.illegal=m(...e.illegal))}function L(e,n){ -if(e.match){ -if(e.begin||e.end)throw Error("begin & end are not supported with match") -;e.begin=e.match,delete e.match}}function B(e,n){ -void 0===e.relevance&&(e.relevance=1)}const $=(e,n)=>{if(!e.beforeMatch)return -;if(e.starts)throw Error("beforeMatch cannot be used with starts") -;const t=Object.assign({},e);Object.keys(e).forEach((n=>{delete e[n] -})),e.keywords=t.keywords,e.begin=b(t.beforeMatch,d(t.begin)),e.starts={ -relevance:0,contains:[Object.assign(t,{endsParent:!0})] -},e.relevance=0,delete t.beforeMatch -},z=["of","and","for","in","not","or","if","then","parent","list","value"],F="keyword" -;function U(e,n,t=F){const a=Object.create(null) -;return"string"==typeof e?i(t,e.split(" ")):Array.isArray(e)?i(t,e):Object.keys(e).forEach((t=>{ -Object.assign(a,U(e[t],n,t))})),a;function i(e,t){ -n&&(t=t.map((e=>e.toLowerCase()))),t.forEach((n=>{const t=n.split("|") -;a[t[0]]=[e,j(t[0],t[1])]}))}}function j(e,n){ -return n?Number(n):(e=>z.includes(e.toLowerCase()))(e)?0:1}const P={},K=e=>{ -console.error(e)},q=(e,...n)=>{console.log("WARN: "+e,...n)},H=(e,n)=>{ -P[`${e}/${n}`]||(console.log(`Deprecated as of ${e}. ${n}`),P[`${e}/${n}`]=!0) -},G=Error();function Z(e,n,{key:t}){let a=0;const i=e[t],r={},s={} -;for(let e=1;e<=n.length;e++)s[e+a]=i[e],r[e+a]=!0,a+=p(n[e-1]) -;e[t]=s,e[t]._emit=r,e[t]._multi=!0}function W(e){(e=>{ -e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope, -delete e.scope)})(e),"string"==typeof e.beginScope&&(e.beginScope={ -_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope -}),(e=>{if(Array.isArray(e.begin)){ -if(e.skip||e.excludeBegin||e.returnBegin)throw K("skip, excludeBegin, returnBegin not compatible with beginScope: {}"), -G -;if("object"!=typeof e.beginScope||null===e.beginScope)throw K("beginScope must be object"), -G;Z(e,e.begin,{key:"beginScope"}),e.begin=h(e.begin,{joinWith:""})}})(e),(e=>{ -if(Array.isArray(e.end)){ -if(e.skip||e.excludeEnd||e.returnEnd)throw K("skip, excludeEnd, returnEnd not compatible with endScope: {}"), -G -;if("object"!=typeof e.endScope||null===e.endScope)throw K("endScope must be object"), -G;Z(e,e.end,{key:"endScope"}),e.end=h(e.end,{joinWith:""})}})(e)}function Q(e){ -function n(n,t){ -return RegExp(c(n),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(t?"g":"")) -}class t{constructor(){ -this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0} -addRule(e,n){ -n.position=this.position++,this.matchIndexes[this.matchAt]=n,this.regexes.push([n,e]), -this.matchAt+=p(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null) -;const e=this.regexes.map((e=>e[1]));this.matcherRe=n(h(e,{joinWith:"|" -}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex -;const n=this.matcherRe.exec(e);if(!n)return null -;const t=n.findIndex(((e,n)=>n>0&&void 0!==e)),a=this.matchIndexes[t] -;return n.splice(0,t),Object.assign(n,a)}}class i{constructor(){ -this.rules=[],this.multiRegexes=[], -this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){ -if(this.multiRegexes[e])return this.multiRegexes[e];const n=new t -;return this.rules.slice(e).forEach((([e,t])=>n.addRule(e,t))), -n.compile(),this.multiRegexes[e]=n,n}resumingScanAtSamePosition(){ -return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,n){ -this.rules.push([e,n]),"begin"===n.type&&this.count++}exec(e){ -const n=this.getMatcher(this.regexIndex);n.lastIndex=this.lastIndex -;let t=n.exec(e) -;if(this.resumingScanAtSamePosition())if(t&&t.index===this.lastIndex);else{ -const n=this.getMatcher(0);n.lastIndex=this.lastIndex+1,t=n.exec(e)} -return t&&(this.regexIndex+=t.position+1, -this.regexIndex===this.count&&this.considerAll()),t}} -if(e.compilerExtensions||(e.compilerExtensions=[]), -e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.") -;return e.classNameAliases=a(e.classNameAliases||{}),function t(r,s){const o=r -;if(r.isCompiled)return o -;[R,L,W,$].forEach((e=>e(r,s))),e.compilerExtensions.forEach((e=>e(r,s))), -r.__beforeBegin=null,[D,I,B].forEach((e=>e(r,s))),r.isCompiled=!0;let l=null -;return"object"==typeof r.keywords&&r.keywords.$pattern&&(r.keywords=Object.assign({},r.keywords), -l=r.keywords.$pattern, -delete r.keywords.$pattern),l=l||/\w+/,r.keywords&&(r.keywords=U(r.keywords,e.case_insensitive)), -o.keywordPatternRe=n(l,!0), -s&&(r.begin||(r.begin=/\B|\b/),o.beginRe=n(o.begin),r.end||r.endsWithParent||(r.end=/\B|\b/), -r.end&&(o.endRe=n(o.end)), -o.terminatorEnd=c(o.end)||"",r.endsWithParent&&s.terminatorEnd&&(o.terminatorEnd+=(r.end?"|":"")+s.terminatorEnd)), -r.illegal&&(o.illegalRe=n(r.illegal)), -r.contains||(r.contains=[]),r.contains=[].concat(...r.contains.map((e=>(e=>(e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((n=>a(e,{ -variants:null},n)))),e.cachedVariants?e.cachedVariants:X(e)?a(e,{ -starts:e.starts?a(e.starts):null -}):Object.isFrozen(e)?a(e):e))("self"===e?r:e)))),r.contains.forEach((e=>{t(e,o) -})),r.starts&&t(r.starts,s),o.matcher=(e=>{const n=new i -;return e.contains.forEach((e=>n.addRule(e.begin,{rule:e,type:"begin" -}))),e.terminatorEnd&&n.addRule(e.terminatorEnd,{type:"end" -}),e.illegal&&n.addRule(e.illegal,{type:"illegal"}),n})(o),o}(e)}function X(e){ -return!!e&&(e.endsWithParent||X(e.starts))}class V extends Error{ -constructor(e,n){super(e),this.name="HTMLInjectionError",this.html=n}} -const J=t,Y=a,ee=Symbol("nomatch"),ne=t=>{ -const a=Object.create(null),i=Object.create(null),r=[];let s=!0 -;const o="Could not find the language '{}', did you forget to load/include a language module?",c={ -disableAutodetect:!0,name:"Plain text",contains:[]};let p={ -ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i, -languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-", -cssSelector:"pre code",languages:null,__emitter:l};function _(e){ -return p.noHighlightRe.test(e)}function h(e,n,t){let a="",i="" -;"object"==typeof n?(a=e, -t=n.ignoreIllegals,i=n.language):(H("10.7.0","highlight(lang, code, ...args) has been deprecated."), -H("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"), -i=e,a=n),void 0===t&&(t=!0);const r={code:a,language:i};x("before:highlight",r) -;const s=r.result?r.result:f(r.language,r.code,t) -;return s.code=r.code,x("after:highlight",s),s}function f(e,t,i,r){ -const l=Object.create(null);function c(){if(!x.keywords)return void S.addText(A) -;let e=0;x.keywordPatternRe.lastIndex=0;let n=x.keywordPatternRe.exec(A),t="" -;for(;n;){t+=A.substring(e,n.index) -;const i=w.case_insensitive?n[0].toLowerCase():n[0],r=(a=i,x.keywords[a]);if(r){ -const[e,a]=r -;if(S.addText(t),t="",l[i]=(l[i]||0)+1,l[i]<=7&&(C+=a),e.startsWith("_"))t+=n[0];else{ -const t=w.classNameAliases[e]||e;g(n[0],t)}}else t+=n[0] -;e=x.keywordPatternRe.lastIndex,n=x.keywordPatternRe.exec(A)}var a -;t+=A.substring(e),S.addText(t)}function d(){null!=x.subLanguage?(()=>{ -if(""===A)return;let e=null;if("string"==typeof x.subLanguage){ -if(!a[x.subLanguage])return void S.addText(A) -;e=f(x.subLanguage,A,!0,M[x.subLanguage]),M[x.subLanguage]=e._top -}else e=E(A,x.subLanguage.length?x.subLanguage:null) -;x.relevance>0&&(C+=e.relevance),S.__addSublanguage(e._emitter,e.language) -})():c(),A=""}function g(e,n){ -""!==e&&(S.startScope(n),S.addText(e),S.endScope())}function u(e,n){let t=1 -;const a=n.length-1;for(;t<=a;){if(!e._emit[t]){t++;continue} -const a=w.classNameAliases[e[t]]||e[t],i=n[t];a?g(i,a):(A=i,c(),A=""),t++}} -function b(e,n){ -return e.scope&&"string"==typeof e.scope&&S.openNode(w.classNameAliases[e.scope]||e.scope), -e.beginScope&&(e.beginScope._wrap?(g(A,w.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap), -A=""):e.beginScope._multi&&(u(e.beginScope,n),A="")),x=Object.create(e,{parent:{ -value:x}}),x}function m(e,t,a){let i=((e,n)=>{const t=e&&e.exec(n) -;return t&&0===t.index})(e.endRe,a);if(i){if(e["on:end"]){const a=new n(e) -;e["on:end"](t,a),a.isMatchIgnored&&(i=!1)}if(i){ -for(;e.endsParent&&e.parent;)e=e.parent;return e}} -if(e.endsWithParent)return m(e.parent,t,a)}function _(e){ -return 0===x.matcher.regexIndex?(A+=e[0],1):(D=!0,0)}function h(e){ -const n=e[0],a=t.substring(e.index),i=m(x,e,a);if(!i)return ee;const r=x -;x.endScope&&x.endScope._wrap?(d(), -g(n,x.endScope._wrap)):x.endScope&&x.endScope._multi?(d(), -u(x.endScope,e)):r.skip?A+=n:(r.returnEnd||r.excludeEnd||(A+=n), -d(),r.excludeEnd&&(A=n));do{ -x.scope&&S.closeNode(),x.skip||x.subLanguage||(C+=x.relevance),x=x.parent -}while(x!==i.parent);return i.starts&&b(i.starts,e),r.returnEnd?0:n.length} -let y={};function N(a,r){const o=r&&r[0];if(A+=a,null==o)return d(),0 -;if("begin"===y.type&&"end"===r.type&&y.index===r.index&&""===o){ -if(A+=t.slice(r.index,r.index+1),!s){const n=Error(`0 width match regex (${e})`) -;throw n.languageName=e,n.badRule=y.rule,n}return 1} -if(y=r,"begin"===r.type)return(e=>{ -const t=e[0],a=e.rule,i=new n(a),r=[a.__beforeBegin,a["on:begin"]] -;for(const n of r)if(n&&(n(e,i),i.isMatchIgnored))return _(t) -;return a.skip?A+=t:(a.excludeBegin&&(A+=t), -d(),a.returnBegin||a.excludeBegin||(A=t)),b(a,e),a.returnBegin?0:t.length})(r) -;if("illegal"===r.type&&!i){ -const e=Error('Illegal lexeme "'+o+'" for mode "'+(x.scope||"