Skip to content

Commit 7ee92ce

Browse files
committed
[refactor] change const and let to var for compatibility
1 parent b683214 commit 7ee92ce

File tree

1 file changed

+32
-70
lines changed

1 file changed

+32
-70
lines changed

‎src/js/helper.js‎

Lines changed: 32 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -666,14 +666,14 @@ var helper = (function(){
666666
};
667667

668668
convertColor.rgb.hsl=function(rgb){
669-
constr=rgb[0]/255;
670-
constg=rgb[1]/255;
671-
constb=rgb[2]/255;
672-
constmin=Math.min(r,g,b);
673-
constmax=Math.max(r,g,b);
674-
constdelta=max-min;
675-
leth;
676-
lets;
669+
varr=rgb[0]/255;
670+
varg=rgb[1]/255;
671+
varb=rgb[2]/255;
672+
varmin=Math.min(r,g,b);
673+
varmax=Math.max(r,g,b);
674+
vardelta=max-min;
675+
varh;
676+
vars;
677677

678678
if(max===min){
679679
h=0;
@@ -683,81 +683,43 @@ var helper = (function(){
683683
h=2+(b-r)/delta;
684684
}elseif(b===max){
685685
h=4+(r-g)/delta;
686-
}
686+
};
687687

688688
h=Math.min(h*60,360);
689689

690690
if(h<0){
691691
h+=360;
692-
}
692+
};
693693

694-
constl=(min+max)/2;
694+
varl=(min+max)/2;
695695

696696
if(max===min){
697697
s=0;
698698
}elseif(l<=0.5){
699699
s=delta/(max+min);
700700
}else{
701701
s=delta/(2-max-min);
702-
}
702+
};
703703

704704
return[h,s*100,l*100];
705705
};
706706

707-
convertColor.rgb.lab=function(rgb){
708-
constxyz=convertColor.rgb.xyz(rgb);
709-
letx=xyz[0];
710-
lety=xyz[1];
711-
letz=xyz[2];
712-
713-
x/=95.047;
714-
y/=100;
715-
z/=108.883;
716-
717-
x=x>0.008856 ? (x**(1/3)) : (7.787*x)+(16/116);
718-
y=y>0.008856 ? (y**(1/3)) : (7.787*y)+(16/116);
719-
z=z>0.008856 ? (z**(1/3)) : (7.787*z)+(16/116);
720-
721-
constl=(116*y)-16;
722-
consta=500*(x-y);
723-
constb=200*(y-z);
724-
725-
return[l,a,b];
726-
};
727-
728-
convertColor.rgb.xyz=function(rgb){
729-
letr=rgb[0]/255;
730-
letg=rgb[1]/255;
731-
letb=rgb[2]/255;
732-
733-
// Assume sRGB
734-
r=r>0.04045 ? (((r+0.055)/1.055)**2.4) : (r/12.92);
735-
g=g>0.04045 ? (((g+0.055)/1.055)**2.4) : (g/12.92);
736-
b=b>0.04045 ? (((b+0.055)/1.055)**2.4) : (b/12.92);
737-
738-
constx=(r*0.4124)+(g*0.3576)+(b*0.1805);
739-
consty=(r*0.2126)+(g*0.7152)+(b*0.0722);
740-
constz=(r*0.0193)+(g*0.1192)+(b*0.9505);
741-
742-
return[x*100,y*100,z*100];
743-
};
744-
745707
convertColor.rgb.hex=function(args){
746-
constinteger=((Math.round(args[0])&0xFF)<<16)+
708+
varinteger=((Math.round(args[0])&0xFF)<<16)+
747709
((Math.round(args[1])&0xFF)<<8)+
748710
(Math.round(args[2])&0xFF);
749711

750-
conststring=integer.toString(16).toUpperCase();
751-
return'000000'.substring(string.length)+string;
712+
varstring=integer.toString(16).toUpperCase();
713+
return"000000".substring(string.length)+string;
752714
};
753715

754716
convertColor.hsl.rgb=function(hsl){
755-
consth=hsl[0]/360;
756-
consts=hsl[1]/100;
757-
constl=hsl[2]/100;
758-
lett2;
759-
lett3;
760-
letval;
717+
varh=hsl[0]/360;
718+
vars=hsl[1]/100;
719+
varl=hsl[2]/100;
720+
vart2;
721+
vart3;
722+
varval;
761723

762724
if(s===0){
763725
val=l*255;
@@ -770,10 +732,10 @@ var helper = (function(){
770732
t2=l+s-l*s;
771733
}
772734

773-
constt1=2*l-t2;
735+
vart1=2*l-t2;
774736

775-
constrgb=[0,0,0];
776-
for(leti=0;i<3;i++){
737+
varrgb=[0,0,0];
738+
for(vari=0;i<3;i++){
777739
t3=h+1/3*-(i-1);
778740
if(t3<0){
779741
t3++;
@@ -800,23 +762,23 @@ var helper = (function(){
800762
};
801763

802764
convertColor.hex.rgb=function(args){
803-
constmatch=args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
765+
varmatch=args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
804766
if(!match){
805767
return[0,0,0];
806768
}
807769

808-
letcolorString=match[0];
770+
varcolorString=match[0];
809771

810772
if(match[0].length===3){
811-
colorString=colorString.split('').map(char=>{
773+
colorString=colorString.split("").map(function(char){
812774
returnchar+char;
813-
}).join('');
775+
}).join("");
814776
}
815777

816-
constinteger=parseInt(colorString,16);
817-
constr=(integer>>16)&0xFF;
818-
constg=(integer>>8)&0xFF;
819-
constb=integer&0xFF;
778+
varinteger=parseInt(colorString,16);
779+
varr=(integer>>16)&0xFF;
780+
varg=(integer>>8)&0xFF;
781+
varb=integer&0xFF;
820782

821783
return[r,g,b];
822784
};

0 commit comments

Comments
(0)