加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.js 11.30 KB
一键复制 编辑 原始数据 按行查看 历史
Bd999 提交于 2019-10-28 20:04 . v1.0.0 first draft
!function(e){var o={};function n(t){if(o[t])return o[t].exports;var r=o[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=o,n.d=function(e,o,t){n.o(e,o)||Object.defineProperty(e,o,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,o){if(1&o&&(e=n(e)),8&o)return e;if(4&o&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&o&&"string"!=typeof e)for(var r in e)n.d(t,r,function(o){return e[o]}.bind(null,r));return t},n.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(o,"a",o),o},n.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},n.p="",n(n.s=0)}([function(e,o,n){const t=n(1),r=n(2),a=n(3);window.aKeyboard={keyboard:t,numberKeyboard:r,mobileKeyboard:a}},function(e,o){e.exports=class{constructor(e){if("object"!=typeof e)return void console.error('aKeyboard: The obj parameter needs to be an object <In "new aKeyboard()">');this.obj=e;const o=document.querySelector(e.el);let n="";if("object"==typeof e.style)for(let o in e.style)n+=o+": "+e.style[o]+";";let t='<div class="akeyboard-keyboard'+(e.fixedBottomCenter?" akeyboard-keyboard-fixedBottomCenter":"")+'" style="'+n+'">',r=[];for(let e=1;e<10;e++)r.push(e.toString());r.push("0");const a=[["`"].concat(r).concat(["-","=","Delete"]),["Tab","q","w","e","r","t","y","u","i","o","p","[","]","\\"],["Caps","a","s","d","f","g","h","j","k","l",";","'","Enter"],["Shift","z","x","c","v","b","n","m",",",".","/","Shift"],["Space"]];let s;const c=[],i=[];for(let e=0;e<a.length;e++){c.push([]),i.push([]),s=a[e];for(let o=0;o<s.length;o++)if(1!==s[o].length)c[e].push(s[o]),i[e].push(s[o]);else{switch(i[e].push(s[o].toUpperCase()),s[o]){case"`":c[e].push("~");continue;case"1":c[e].push("!");continue;case"2":c[e].push("@");continue;case"3":c[e].push("#");continue;case"4":c[e].push("$");continue;case"5":c[e].push("%");continue;case"6":c[e].push("^");continue;case"7":c[e].push("&");continue;case"8":c[e].push("*");continue;case"9":c[e].push("(");continue;case"0":c[e].push(")");continue;case"-":c[e].push("_");continue;case"=":c[e].push("+");continue;case"[":c[e].push("{");continue;case"]":c[e].push("}");continue;case"\\":c[e].push("|");continue;case";":c[e].push(":");continue;case"'":c[e].push('"');continue;case",":c[e].push("<");continue;case".":c[e].push(">");continue;case"/":c[e].push("?");continue}c[e].push(s[o].toUpperCase())}}for(let e=0;e<a.length;e++){s=a[e],t+='<div class="akeyboard-keyboard-innerKeys">';for(let e=0;e<s.length;e++)t+='<div class="akeyboard-keyboard-keys akeyboard-keyboard-keys-'+s[e]+'">'+s[e]+"</div>";t+="</div>"}t+="</div>",o.innerHTML=t;const l=document.querySelectorAll(e.el+" .akeyboard-keyboard-keys-Shift");function d(){if(!this.isShift){if(document.querySelector(e.el+" .akeyboard-keyboard-keys-Caps").isCaps)return;l[0].isShift=!0,l[1].isShift=!0,l[0].innerHTML="SHIFT",l[1].innerHTML="SHIFT";const o=document.querySelectorAll(e.el+" .akeyboard-keyboard-innerKeys");let n;for(let e=0;e<o.length;e++){n=o[e];for(let o=0;o<n.childNodes.length;o++)"Shift"!==c[e][o]&&(n.childNodes[o].innerHTML=c[e][o])}return}l[0].isShift=!1,l[1].isShift=!1,l[0].innerHTML="Shift",l[1].innerHTML="Shift";const o=document.querySelectorAll(e.el+" .akeyboard-keyboard-innerKeys");let n;for(let e=0;e<o.length;e++){n=o[e];for(let o=0;o<n.childNodes.length;o++)n.childNodes[o].innerHTML=a[e][o]}}l[0].onclick=d,l[0].isShift=!1,l[1].onclick=d,l[1].isShift=!1;const u=document.querySelector(e.el+" .akeyboard-keyboard-keys-Caps");u.onclick=function(){if(!this.isCaps){if(document.querySelector(e.el+" .akeyboard-keyboard-keys-Shift").isShift)return;this.isCaps=!0,this.classList.add("keyboard-keyboard-keys-focus");const o=document.querySelectorAll(e.el+" .akeyboard-keyboard-innerKeys");let n;for(let e=0;e<o.length;e++){n=o[e];for(let o=0;o<n.childNodes.length;o++)n.childNodes[o].innerHTML=i[e][o]}return}this.isCaps=!1,this.classList.remove("keyboard-keyboard-keys-focus");const o=document.querySelectorAll(e.el+" .akeyboard-keyboard-innerKeys");let n;for(let e=0;e<o.length;e++){n=o[e];for(let o=0;o<n.childNodes.length;o++)n.childNodes[o].innerHTML=a[e][o]}},u.isCaps=!1}inputOn(e,o){if("string"!=typeof e)return void console.error('aKeyboard: The inputEle parameter needs to be a string <In "aKeyboard.inputOn()">');if("string"!=typeof o)return void console.error('aKeyboard: The type parameter needs to be a string <In "aKeyboard.inputOn()">');const n=document.querySelector(e),t=document.querySelectorAll(this.obj.el+" .akeyboard-keyboard-keys");for(let e=0;e<t.length;e++){switch(t[e].innerHTML){case"Shift":case"Caps":continue;case"Delete":t[e].onclick=function(){n[o]=n[o].substr(0,n[o].length-1)};continue;case"Tab":t[e].onclick=function(){n[o]+=" "};continue;case"Enter":t[e].onclick=function(){n[o]+="\n"};continue;case"Space":t[e].onclick=function(){n[o]+=" "};continue}t[e].onclick=function(){n[o]+=this.innerText}}}onclick(e,o){if("string"!=typeof e)return void console.error('aKeyboard: The btn parameter needs to be a string <In "aKeyboard.onclick()">');if("function"!=typeof o)return void console.error('aKeyboard: The fn parameter needs to be a function <In "aKeyboard.onclick()">');if("*"===e){let e=document.querySelectorAll(this.obj.el+" .akeyboard-keyboard-keys");for(let n=0;n<e.length;n++)e[n].onclick=o;return}document.querySelector(this.obj.el+" .akeyboard-keyboard-keys-"+e).onclick=o}}},function(e,o){e.exports=class{constructor(e){if("object"!=typeof e)return void console.error('aKeyboard: The obj parameter needs to be an object <In "new aKeyboard()">');this.obj=e;const o=document.querySelector(e.el);let n="";if("object"==typeof e.style)for(let o in e.style)n+=o+": "+e.style[o]+";";let t='<div class="akeyboard-numberKeyboard'+(e.fixedBottomCenter?" akeyboard-keyboard-fixedBottomCenter":"")+'" style="'+n+'">';t+='<div class="akeyboard-keyboard-innerKeys">';for(let e=1;e<10;e++)t+='<div class="akeyboard-keyboard-keys akeyboard-numberKeyboard-keys akeyboard-keyboard-keys-'+e+'">'+e+"</div>",e%3==0&&(t+='</div><div class="akeyboard-keyboard-innerKeys">');t+='<div class="akeyboard-keyboard-keys akeyboard-numberKeyboard-keys akeyboard-keyboard-keys-0">0</div><div class="akeyboard-keyboard-keys akeyboard-numberKeyboard-keys akeyboard-keyboard-keys-Delete">Delete</div></div><div class="akeyboard-keyboard-innerKeys"><div class="akeyboard-keyboard-keys akeyboard-numberKeyboard-keys akeyboard-numberKeyboard-keys-Enter">Enter</div></div>',t+="</div>",o.innerHTML=t}inputOn(e,o){if("string"!=typeof e)return void console.error('aKeyboard: The inputEle parameter needs to be a string <In "aKeyboard.inputOn()">');if("string"!=typeof o)return void console.error('aKeyboard: The type parameter needs to be a string <In "aKeyboard.inputOn()">');const n=document.querySelector(e),t=document.querySelectorAll(this.obj.el+" .akeyboard-keyboard-keys");for(let e=0;e<t.length;e++)"Delete"!==t[e].innerHTML?"Enter"!==t[e].innerHTML?t[e].onclick=function(){n[o]+=this.innerText}:t[e].onclick=function(){n[o]+="\n"}:t[e].onclick=function(){n[o]=n[o].substr(0,n[o].length-1)}}onclick(e,o){if("string"!=typeof e)return void console.error('aKeyboard: The btn parameter needs to be a string <In "aKeyboard.onclick()">');if("function"!=typeof o)return void console.error('aKeyboard: The fn parameter needs to be a function <In "aKeyboard.onclick()">');if("*"===e){let e=document.querySelectorAll(this.obj.el+" .akeyboard-numberKeyboard-keys");for(let n=0;n<e.length;n++)e[n].onclick=o;return}document.querySelector(this.obj.el+" .akeyboard-numberKeyboard-keys-"+e).onclick=o}}},function(e,o){e.exports=class{constructor(e){if("object"!=typeof e)return void console.error('aKeyboard: The obj parameter needs to be an object <In "new aKeyboard()">');this.obj=e;const o=document.querySelector(e.el);let n="";if("object"==typeof e.style)for(let o in e.style)n+=o+": "+e.style[o]+";";let t='<div class="akeyboard-mobileKeyboard'+(e.fixedBottomCenter?" akeyboard-keyboard-fixedBottomCenter":"")+'" style="'+n+'">',r=[];for(let e=1;e<10;e++)r.push(e.toString());r.push("0");const a=[["`"].concat(r).concat(["-","="]),["q","w","e","r","t","y","u","i","o","p","[","]","\\"],["a","s","d","f","g","h","j","k","l",";","'"],["","z","x","c","v","b","n","m",",",".","/",""],["Space","Enter"]];let s;const c=[];for(let e=0;e<a.length;e++){c.push([]),s=a[e];for(let o=0;o<s.length;o++)if(1!==s[o].length)c[e].push(s[o]);else{switch(s[o]){case"`":c[e].push("~");continue;case"1":c[e].push("!");continue;case"2":c[e].push("@");continue;case"3":c[e].push("#");continue;case"4":c[e].push("$");continue;case"5":c[e].push("%");continue;case"6":c[e].push("^");continue;case"7":c[e].push("&");continue;case"8":c[e].push("*");continue;case"9":c[e].push("(");continue;case"0":c[e].push(")");continue;case"-":c[e].push("_");continue;case"=":c[e].push("+");continue;case"[":c[e].push("{");continue;case"]":c[e].push("}");continue;case"\\":c[e].push("|");continue;case";":c[e].push(":");continue;case"'":c[e].push('"');continue;case",":c[e].push("<");continue;case".":c[e].push(">");continue;case"/":c[e].push("?");continue}c[e].push(s[o].toUpperCase())}}for(let e=0;e<a.length;e++){s=a[e],t+='<div class="akeyboard-keyboard-innerKeys">';for(let e=0;e<s.length;e++)t+='<div class="akeyboard-mobileKeyboard-keys akeyboard-mobileKeyboard-keys-'+s[e]+'">'+s[e]+"</div>";t+="</div>"}t+="</div>",o.innerHTML=t;const i=document.querySelector(e.el+" .akeyboard-mobileKeyboard-keys-⇧");i.onclick=function(){if(!this.isShift){i.classList.add("akeyboard-mobileKeyboard-keys-focus"),i.isShift=!0;const o=document.querySelectorAll(e.el+" .akeyboard-keyboard-innerKeys");let n;for(let e=0;e<o.length;e++){n=o[e];for(let o=0;o<n.childNodes.length;o++)n.childNodes[o].innerHTML=c[e][o]}return}i.isShift=!1,i.classList.remove("akeyboard-mobileKeyboard-keys-focus");const o=document.querySelectorAll(e.el+" .akeyboard-keyboard-innerKeys");let n;for(let e=0;e<o.length;e++){n=o[e];for(let o=0;o<n.childNodes.length;o++)n.childNodes[o].innerHTML=a[e][o]}},i.isShift=!1}inputOn(e,o){if("string"!=typeof e)return void console.error('aKeyboard: The inputEle parameter needs to be a string <In "aKeyboard.inputOn()">');if("string"!=typeof o)return void console.error('aKeyboard: The type parameter needs to be a string <In "aKeyboard.inputOn()">');const n=document.querySelector(e),t=document.querySelectorAll(this.obj.el+" .akeyboard-mobileKeyboard-keys");for(let e=0;e<t.length;e++){switch(t[e].innerHTML){case"":continue;case"":t[e].onclick=function(){n[o]=n[o].substr(0,n[o].length-1)};continue;case"Enter":t[e].onclick=function(){n[o]+="\n"};continue;case"Space":t[e].onclick=function(){n[o]+=" "};continue}t[e].onclick=function(){n[o]+=this.innerText}}}onclick(e,o){if("string"!=typeof e)return void console.error('aKeyboard: The btn parameter needs to be a string <In "aKeyboard.onclick()">');if("function"!=typeof o)return void console.error('aKeyboard: The fn parameter needs to be a function <In "aKeyboard.onclick()">');if("*"===e){let e=document.querySelectorAll(this.obj.el+" .akeyboard-mobileKeyboard-keys");for(let n=0;n<e.length;n++)e[n].onclick=o;return}let n=document.querySelector(this.obj.el+" .akeyboard-mobileKeyboard-keys-"+e);null===n&&(n=document.querySelector(this.obj.el+" .akeyboard-mobileKeyboard-keys-"+e)),n.onclick=o}}}]);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化