I did 3 things throughout yesterday til now but, they weren't the 3 things I said I was going to do. I did finish the docs, so that was one thing. I also set the stage for the search feature but, I had another idea and got sidetracked so, I'm not even counting that in these 3 things. I implemented that new idea so, now there is yet another feature in QTV, and it's one that I feel is pretty damn important. The third thing I did was work more on GypQuery.
One thing I hate about javascript is all the "this. this. this." about everything. I wanted to remove as much of that as I can from GypQuery. I was thinking about what I said the other day regarding the outside scope allowed in classes and the "inside scope" of functions. This gave me an idea and my idea turned out to be possible. I wrapped the entire GypQuery class in a function and declared constants in that function that represent the majority of "this." variables. By doing so, I don't need most of the "this." bullshit cause constants are constant (but only in the scope of the function, which is perfect). Once I got that to work I made a couple of other things constant to try and chop this down to as few characters as possible. I have a fully minimized version. It's just this version with every unnecessary space character removed. It clocks in at 2308 characters. It would be much much more than that without removing the "this." of it all.
After chopping it down as small as I can get it I added some more features that I realized I could use. I put "off" back in cause now I am removing event listeners from over 500 targets in a certain scenario. That scenario came about with my sidetrack idea that is now part of QTV. I also made some things "inlineable" and other things flexible.
for "inlineable" we have stuff like
$('#myThing').rem('thisClass').add('thatClass');
and for flexible we have stuff like
_$('.allTheCheckBoxes').uncheck(); //or check();
and
$('#justThisCheckBox').uncheck(); //or check();
let gq = function(el){
const _t=true;const _f=false;if(el==null)el=_f;const e=el;const g=(el!=_f);const s=!el.length;const evt=new WeakMap();
class GypQuery
{ constructor(el){(el==_f)?this.el=null:this.el=el;};
sysb(ev,c,t){t.addEventListener(ev,c,_f);};
sysub(ev,t){t.removeEventListener(ev,evt[ev],_f);};
b(ev,c){if(!s)e.forEach((i)=>{this.sysb(ev,c,i);});else this.sysb(ev,c,e);evt[ev]=c};
ub(ev){if(!s)e.forEach((i)=>{this.sysub(ev,i);});else this.sysub(ev,e);};
on(ev,c){this.b(ev,c);return _t};
off(ev){this.ub(ev);return _f};
get isNull() {return(!g); };
get text() {return(g&&s)?e.textContent :null;};
get html() {return(g&&s)?e.innerHTML :null;};
get val() {return(g&&s)?e.value :null;};
get src() {return(g&&s)?e.src :null;};
get width() {return(g&&s)?e.offsetWidth :null;};
get height() {return(g&&s)?e.offsetHeight:null;};
get top() {return(g&&s)?e.offsetTop :null;};
get left() {return(g&&s)?e.offsetLeft :null;};
get scrollTop() {return(g&&s)?e.scrollTop :null;};
get scrollLeft() {return(g&&s)?e.scrollLeft :null;};
set text(v) {if(g&&s)e.textContent=v; };
set html(v) {if(g&&s)e.innerHTML=v; };
set val(v) {if(g&&s)e.value=v; };
set src(v) {if(g&&s)e.src=v; };
set width(v) {if(g&&s)e.style.width=v+"px"; };
set height(v) {if(g&&s)e.style.height=v+"px"; };
set top(v) {if(g&&s)e.style.top=v+"px"; };
set left(v) {if(g&&s)e.style.left=v+"px"; };
set scrollTop(v) {if(g&&s)e.scrollTop=v; };
set scrollLeft(v){if(g&&s)e.scrollLeft=v; };
get length() {return(g&&!s)?e.length :null;};
uncheck() {if(g&&!s){for(var i=0;i<e.length;i++){e[i].checked=_f;}}else{e.checked=_f;};return this};
check() {if(g&&!s){for(var i=0;i<e.length;i++){e[i].checked=_t;}}else{e.checked=_t};return this};
remAttr(a) {if(g&&!s){for(var i=0;i<e.length;i++){e[i].removeAttribute(a);}}else{e.removeAttribute(a);};return this};
withAttr(a,v) {if(g&&!s){for(var i=0;i<e.length;i++){if(e[i].getAttribute(a) == v){return e[i];}}return null;}}
has(c) {return(g&&s)?e.classList.contains(c):_f;};
add(c) {if((g&&s)&&(!this.has(c)))e.classList.add(c);return this;};
rem(c) {if((g&&s)&&(this.has(c)))e.classList.remove(c);return this;};
attr(n, v) {if(g&&s){if(v===undefined){return e.getAttribute(n);}else{e.setAttribute(n,v);return this;}}};
};
return new GypQuery(e);
};
$ = function(s){return new gq(document.querySelector(s));}/*query single*/
_$ = function(s){return new gq(document.querySelectorAll(s))}/*query all*/
$$ = function(el){return new gq(el)}/*cast element*/
min
let gq=function(el){const _t=true;const _f=false;if(el==null)el=_f;const e=el;const g=(el!=_f);const s=!el.length;const evt=new WeakMap();class GypQuery{constructor(el){(el==_f)?this.el=null:this.el=el;};sysb(ev,c,t){t.addEventListener(ev,c,_f);};sysub(ev,t){t.removeEventListener(ev,evt[ev],_f);};b(ev,c){if(!s)e.forEach((i)=>{this.sysb(ev,c,i);});else this.sysb(ev,c,e);evt[ev]=c};ub(ev){if(!s)e.forEach((i)=>{this.sysub(ev,i);});else this.sysub(ev,e);};on(ev,c){this.b(ev,c);return _t};off(ev){this.ub(ev);return _f};get isNull(){return(!g);};get text(){return(g&&s)?e.textContent:null;};get html(){return(g&&s)?e.innerHTML:null;};get val(){return(g&&s)?e.value:null;};get src(){return(g&&s)?e.src:null;};get width(){return(g&&s)?e.offsetWidth:null;};get height(){return(g&&s)?e.offsetHeight:null;};get top(){return(g&&s)?e.offsetTop:null;};get left(){return(g&&s)?e.offsetLeft:null;};get scrollTop(){return(g&&s)?e.scrollTop:null;};get scrollLeft(){return(g&&s)?e.scrollLeft:null;};set text(v){if(g&&s)e.textContent=v;};set html(v){if(g&&s)e.innerHTML=v;};set val(v){if(g&&s)e.value=v;};set src(v){if(g&&s)e.src=v;};set width(v){if(g&&s)e.style.width=v+"px";};set height(v){if(g&&s)e.style.height=v+"px";};set top(v){if(g&&s)e.style.top=v+"px";};set left(v){if(g&&s)e.style.left=v+"px";};set scrollTop(v){if(g&&s)e.scrollTop=v;};set scrollLeft(v){if(g&&s)e.scrollLeft=v;};get length(){return(g&&!s)?e.length:null;};remAttr(a){if(g&&!s){for(var i=0;i<e.length;i++){e[i].removeAttribute(a);}}else{e.removeAttribute(a);};return this};uncheck(){if(g&&!s){for(var i=0;i<e.length;i++){e[i].checked=_f;}}else{e.checked=_f;};return this};check(){if(g&&!s){for(var i=0;i<e.length;i++){e[i].checked=_t;}}else{e.checked=_t;};return this};withAttr(a,v){if(g&&!s){for(var i=0;i<e.length;i++){if(e[i].getAttribute(a) == v){return e[i];}}return null;}};has(c){return(g&&s)?e.classList.contains(c):_f;};add(c){if((g&&s)&&(!this.has(c)))e.classList.add(c);return this;};rem(c){if((g&&s)&&(this.has(c)))e.classList.remove(c);return this;};attr(n,v){if(g&&s){if(v===undefined){return e.getAttribute(n);}else{e.setAttribute(n,v);return this;}}};};return new GypQuery(e);};$=function(s){return new gq(document.querySelector(s));};_$=function(s){return new gq(document.querySelectorAll(s))};$$=function(el){return new gq(el)};
|