From 1fa65e537cbc56fff5e03165f46bf56c158e7fa4 Mon Sep 17 00:00:00 2001 From: KLA6 Date: Wed, 13 Dec 2023 07:09:27 +0700 Subject: [PATCH] --- README.md | 4 ++-- k6_console.js | 4 ++-- k6_console.min.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index be51474..f7e6c7e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Secondly, to show the `console....` things at a corner on a mobile device screen ## Install ``` - + + diff --git a/k6_console.js b/k6_console.js index 7ebe9d1..881676a 100644 --- a/k6_console.js +++ b/k6_console.js @@ -51,8 +51,8 @@ class k6_console { this .FM ( 'white', 'black' , result, false ) } // function - function T_name( worker, prefix, name ) { return worker ? `window[ '${prefix}${name}' ]` - : `self.${prefix}${name}` } + function T_name( worker, prefix, name ) { return worker ? `self.${prefix}${name}` + : `window[ '${prefix}${name}' ]` } if( this.global ) eval( `${ T_name( this.worker, this.prefix, 'CD' ) } = this.CD ;` + diff --git a/k6_console.min.js b/k6_console.min.js index 041ed1e..6d747a2 100644 --- a/k6_console.min.js +++ b/k6_console.min.js @@ -1 +1 @@ -class k6_console{constructor(P={}){function T_name(i,t,e){return i?`window[ '${t}${e}' ]`:`self.${t}${e}`}this.prod=P.prod||P.production||!1,this.global=P.global||!0,this.worker=P.worker||!1,this.mobile=P.mobile||"bl",(!1==P.mobile||"false"==P.mobile)&&(this.mobile=!1),this.header=P.header||"K6",this.prefix=P.prefix||"",this.prod||console.warn("k6_console.js:",`Don't forget "production: true" or "const ${this.prefix}CD = null, ${this.prefix}FCD = ${this.prefix}FCE = ${this.prefix}FCW = ${this.prefix}FCG = ${this.prefix}FCGE = ${this.prefix}FCT = ${this.prefix}FCI = ${this.prefix}FCL = ${this.prefix}FCLR = () => {}" for the production mode.`),!this.worker&&this.mobile&&(this.FC=document.createElement("pre"),document.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(this.FC)}),this.FC.id="k6_console",this.FC.style.position="fixed",this.FC.style.fontSize="12px",this.FC.style.margin="10px 8px",this.FC.style.padding="6px 8px",this.FC.style.borderRadius="4px","tl"==this.mobile&&(this.FC.style.top=0,this.FC.style.left=0),"tr"==this.mobile&&(this.FC.style.top=0,this.FC.style.right=0),"bl"==this.mobile&&(this.FC.style.bottom=0,this.FC.style.left=0),"br"==this.mobile&&(this.FC.style.bottom=0,this.FC.style.right=0)),this.FM=(i,t,e,s=!0)=>{!this.worker&&this.mobile&&(this.FC.style.color=i,this.FC.style.backgroundColor=t,this.FC.innerText=s?JSON.stringify(e):e)},this.CD=!this.prod,this.FCD=this.prod?()=>{}:(...i)=>{console.debug("%c"+this.header,"color: white; background-color: magenta;",...i),this.FM("white","magenta",i)},this.FCE=this.prod?()=>{}:(...i)=>{console.error("%c"+this.header,"color: white; background-color: red ;",...i),this.FM("white","red",i)},this.FCW=this.prod?()=>{}:(...i)=>{console.warn("%c"+this.header,"color: black; background-color: yellow ;",...i),this.FM("black","yellow",i)},this.FCG=this.prod?()=>{}:(...i)=>{console.group("%c"+this.header,"color: white; background-color: grey ;",...i),this.FM("white","grey",i)},this.FCGE=this.prod?()=>{}:(...i)=>{console.groupEnd()},this.FCT=this.prod?()=>{}:(...i)=>{console.trace("%c"+this.header,"color: white; background-color: blue ;",...i),this.FM("white","blue",i)},this.FCI=this.prod?()=>{}:(...i)=>{console.info("%c"+this.header,"color: black; background-color: cyan ;",...i),this.FM("black","cyan",i)},this.FCL=this.prod?()=>{}:(...i)=>{console.log("%c"+this.header,"color: white; background-color: green ;",...i),this.FM("white","green",i)},this.FCLR=this.prod?()=>{}:i=>{function t(i,t){if("object"==typeof t&&null!==t){if(-1!==e.indexOf(t))return;e.push(t)}return t}let e=[],s=JSON.stringify(i,t);e=null,console.log("%c"+this.header,"color: white; background-color: black;",s),this.FM("white","black",s,!1)},this.global&&eval(`${T_name(this.worker,this.prefix,"CD")} = this.CD ;${T_name(this.worker,this.prefix,"FCD")} = this.FCD ;${T_name(this.worker,this.prefix,"FCE")} = this.FCE ;${T_name(this.worker,this.prefix,"FCW")} = this.FCW ;${T_name(this.worker,this.prefix,"FCG")} = this.FCG ;${T_name(this.worker,this.prefix,"FCGE")} = this.FCGE;${T_name(this.worker,this.prefix,"FCT")} = this.FCT ;${T_name(this.worker,this.prefix,"FCI")} = this.FCI ;${T_name(this.worker,this.prefix,"FCL")} = this.FCL ;${T_name(this.worker,this.prefix,"FCLR")} = this.FCLR;`)}} +class k6_console{constructor(P={}){function T_name(i,t,e){return i?`self.${t}${e}`:`window[ '${t}${e}' ]`}this.prod=P.prod||P.production||!1,this.global=P.global||!0,this.worker=P.worker||!1,this.mobile=P.mobile||"bl",(!1==P.mobile||"false"==P.mobile)&&(this.mobile=!1),this.header=P.header||"K6",this.prefix=P.prefix||"",this.prod||console.warn("k6_console.js:",`Don't forget "production: true" or "const ${this.prefix}CD = null, ${this.prefix}FCD = ${this.prefix}FCE = ${this.prefix}FCW = ${this.prefix}FCG = ${this.prefix}FCGE = ${this.prefix}FCT = ${this.prefix}FCI = ${this.prefix}FCL = ${this.prefix}FCLR = () => {}" for the production mode.`),!this.worker&&this.mobile&&(this.FC=document.createElement("pre"),document.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(this.FC)}),this.FC.id="k6_console",this.FC.style.position="fixed",this.FC.style.fontSize="12px",this.FC.style.margin="10px 8px",this.FC.style.padding="6px 8px",this.FC.style.borderRadius="4px","tl"==this.mobile&&(this.FC.style.top=0,this.FC.style.left=0),"tr"==this.mobile&&(this.FC.style.top=0,this.FC.style.right=0),"bl"==this.mobile&&(this.FC.style.bottom=0,this.FC.style.left=0),"br"==this.mobile&&(this.FC.style.bottom=0,this.FC.style.right=0)),this.FM=(i,t,e,s=!0)=>{!this.worker&&this.mobile&&(this.FC.style.color=i,this.FC.style.backgroundColor=t,this.FC.innerText=s?JSON.stringify(e):e)},this.CD=!this.prod,this.FCD=this.prod?()=>{}:(...i)=>{console.debug("%c"+this.header,"color: white; background-color: magenta;",...i),this.FM("white","magenta",i)},this.FCE=this.prod?()=>{}:(...i)=>{console.error("%c"+this.header,"color: white; background-color: red ;",...i),this.FM("white","red",i)},this.FCW=this.prod?()=>{}:(...i)=>{console.warn("%c"+this.header,"color: black; background-color: yellow ;",...i),this.FM("black","yellow",i)},this.FCG=this.prod?()=>{}:(...i)=>{console.group("%c"+this.header,"color: white; background-color: grey ;",...i),this.FM("white","grey",i)},this.FCGE=this.prod?()=>{}:(...i)=>{console.groupEnd()},this.FCT=this.prod?()=>{}:(...i)=>{console.trace("%c"+this.header,"color: white; background-color: blue ;",...i),this.FM("white","blue",i)},this.FCI=this.prod?()=>{}:(...i)=>{console.info("%c"+this.header,"color: black; background-color: cyan ;",...i),this.FM("black","cyan",i)},this.FCL=this.prod?()=>{}:(...i)=>{console.log("%c"+this.header,"color: white; background-color: green ;",...i),this.FM("white","green",i)},this.FCLR=this.prod?()=>{}:i=>{function t(i,t){if("object"==typeof t&&null!==t){if(-1!==e.indexOf(t))return;e.push(t)}return t}let e=[],s=JSON.stringify(i,t);e=null,console.log("%c"+this.header,"color: white; background-color: black;",s),this.FM("white","black",s,!1)},this.global&&eval(`${T_name(this.worker,this.prefix,"CD")} = this.CD ;${T_name(this.worker,this.prefix,"FCD")} = this.FCD ;${T_name(this.worker,this.prefix,"FCE")} = this.FCE ;${T_name(this.worker,this.prefix,"FCW")} = this.FCW ;${T_name(this.worker,this.prefix,"FCG")} = this.FCG ;${T_name(this.worker,this.prefix,"FCGE")} = this.FCGE;${T_name(this.worker,this.prefix,"FCT")} = this.FCT ;${T_name(this.worker,this.prefix,"FCI")} = this.FCI ;${T_name(this.worker,this.prefix,"FCL")} = this.FCL ;${T_name(this.worker,this.prefix,"FCLR")} = this.FCLR;`)}}