let w,h,my={};function init(){let version='0.89';my.optQ=true;my.mode='1-100';let m=getQueryVariable('g');if(m){my.mode=m;my.optQ=false;} console.log("my",my);w=500;h=360;my.cellWd=46;my.cellHt=26;my.noClr='#f8f8f8';my.yesClr='#dfd';my.anims=[];loadGames();my.colMax=10;let optStr='' if(my.optQ){optStr+=wrap({id:"rangeType",tag:'sel',opts:my.games,fn:'rangeChg()',style:"font: 0.9rem Verdana;margin: 0 auto 12px auto;",lbl:'Type:'})} let s=wrap({cls:'js',style:'width:'+w+'px; min-height:'+h+'px; background-color: var(--b1Clr); padding:10px;'},getArrowBox(),optStr,wrap({id:"grid",style:"font: 17px Verdana;"},getGrid(my.mode)),wrap({id:"success",cls:"pop",pos:'abs',style:"font: 40px Verdana; color:blue; left: -500px; top: 120px; width: 300px; margin: auto; opacity: 0; "},'Well Done!
',''),wrap({id:"ansBox",cls:'arrowBox',pos:'abs',style:"left: 50px; top: 60px; visibility: hidden; "}),wrap({cls:'copyrt',pos:'abs',style:'left:5px; bottom:3px'},` © 2021 MathsIsFun.com v${version}`)) docInsert(s);my.animNo=0;my.loopNo=0;} function restart(){let div=document.getElementById('grid');div.innerHTML=getGrid(my.mode);div=document.getElementById('success') div.style.opacity=0;div.style.left='-600px';my.animNo=999;my.loopNo=999;} function rangeChg(){document.getElementById('ansBox').style.visibility='hidden';let div=document.getElementById('rangeType');let s=div.options[div.selectedIndex].value;my.mode=s.toLowerCase();console.log("my.mode",my.mode);document.getElementById('grid').innerHTML=getGrid(my.mode);} function sttAnim(){my.animNo=0;my.loopNo=0;doAnim();} function doAnim(){let div=document.getElementById(my.anims[my.animNo]);div.style.backgroundColor=getRandomClr();my.animNo++;if(my.animNo>=my.anims.length){my.animNo=0;my.loopNo++;} if(my.loopNo<3) requestAnimationFrame(doAnim);} function getAns(row,col){let x=0;if(my.game.typ=="units"){x=row*my.game.cols+col+1;}else{x=my.game.stt+(row*my.game.cols+col)*my.game.skip} return(x);} function getGrid(name){let s='';let game=null for(let i=0;i';for(let j=0;j';s+=v;s+='';my.anims.push(id);n++;let pct=qN/n;let overachievefactor=2;let density=my.game.density if(pct';for(let j=0;j<2;j++){let id=me.id+'-'+anss[n];s+='
';s+=anss[n];s+='
';n++;} s+='';} div.innerHTML=s;} function doAns(me){let ids=me.id.split('-');let a=ids.pop();let div=document.getElementById(ids.join('-'));div.innerHTML=a;document.getElementById('ansBox').style.visibility='hidden';let ans=div.getAttribute('ans')<<0;let clr=my.yesClr;if(a!=ans){clr=my.noClr;} div.style.backgroundColor=clr;if(checkSuccess()){div=document.getElementById('success');div.style.opacity=1;div.style.left=(w-320)/2+'px';sttAnim();}} function loadGames(){my.games=[{name:"1-100",descr:"1 to 100",typ:"list",rows:10,cols:10,stt:1,skip:1,yGap:0,density:0.2},{name:"0-99",descr:"0 to 99",typ:"list",rows:10,cols:10,stt:0,skip:1,yGap:0,density:0.2},{name:"evens",descr:"Even Numbers List",typ:"list",rows:3,cols:10,stt:2,skip:2,yGap:20,density:0.7},{name:"odds",descr:"Odd Numbers list",typ:"list",rows:3,cols:10,stt:1,skip:2,yGap:20,density:0.7},{name:"2s20",descr:"Skip Count by 2s to 20",typ:"list",rows:1,cols:10,stt:2,skip:2,yGap:20,density:0.5},{name:"2s100",descr:"Skip Count by 2 to 100",typ:"list",rows:5,cols:10,stt:2,skip:2,yGap:20,density:0.4},{name:"3s36",descr:"Skip Count by 3 to 36",typ:"list",rows:1,cols:12,stt:3,skip:3,yGap:20,density:0.6},{name:"3s90",descr:"Skip Count by 3 to 90",typ:"list",rows:3,cols:10,stt:3,skip:3,yGap:20,density:0.4},{name:"4s120",descr:"Skip Count by 4 to 120",typ:"list",rows:3,cols:10,stt:4,skip:4,yGap:20,density:0.4},{name:"4s48",descr:"Skip Count by 4 to 48",typ:"list",rows:1,cols:12,stt:4,skip:4,yGap:20,density:0.6},{name:"5s",descr:"Skip Count by 5 to 100",typ:"list",rows:2,cols:10,stt:5,skip:5,yGap:20,density:0.7},{name:"5s50",descr:"Skip Count by 5 to 50",typ:"list",rows:1,cols:10,stt:5,skip:5,yGap:20,density:0.6},{name:"5s100",descr:"Skip Count by 5 to 100",typ:"list",rows:2,cols:10,stt:5,skip:5,yGap:20,density:0.5},{name:"5s200",descr:"Skip Count by 5 to 200",typ:"list",rows:4,cols:10,stt:5,skip:5,yGap:20,density:0.4},{name:"10s",descr:"Skip Count by 10 to 200",typ:"list",rows:2,cols:10,stt:10,skip:10,yGap:20,density:0.7},{name:"10s100",descr:"Skip Count by 10 to 100",typ:"list",rows:1,cols:10,stt:10,skip:10,yGap:20,density:0.7},{name:"10s300",descr:"Skip Count by 10 to 300",typ:"list",rows:3,cols:10,stt:10,skip:10,yGap:20,density:0.5},{name:"25s1k",descr:"Skip Count by 25",typ:"list",rows:4,cols:10,stt:25,skip:25,yGap:20,density:0.5},{name:"50s1k",descr:"Skip Count by 50",typ:"list",rows:2,cols:10,stt:50,skip:50,yGap:20,density:0.6},{name:"100s1k",descr:"Skip Count by 100",typ:"list",rows:2,cols:10,stt:100,skip:100,yGap:20,density:0.75},{name:"20m1",descr:"Backwards from 20 to 1",typ:"list",rows:2,cols:10,stt:20,skip:-1,yGap:20,density:0.5},{name:"100m1",descr:"Backwards from 100 to 1",typ:"list",rows:10,cols:10,stt:100,skip:-1,yGap:0,density:0.2},{name:"100m2",descr:"Backwards from 100 by 2s",typ:"list",rows:5,cols:10,stt:100,skip:-2,yGap:20,density:0.5},{name:"100m5",descr:"Backwards from 100 by 5s",typ:"list",rows:2,cols:10,stt:100,skip:-5,yGap:20,density:0.7},{name:"100m10",descr:"Backwards from 100 by 10s",typ:"list",rows:1,cols:10,stt:100,skip:-10,yGap:20,density:0.7},{name:"even-units",descr:"Even Numbers",typ:"list",rows:5,cols:10,stt:0,skip:2,yGap:20,density:0.6},{name:"odd-units",descr:"Odd Numbers",typ:"list",rows:5,cols:10,stt:1,skip:2,yGap:10,density:0.8}];} function getArrowBox(){let s='';s+='';return s;} function getChoices(ans){let wrongcount=9;let wrong=[];wrong[0]=ans+Math.round(Math.random()*(9-2)+2);wrong[1]=ans-Math.round(Math.random()*(9-2)+2);wrong[2]=ans+1;wrong[3]=ans-1;wrong[4]=ans+10;wrong[5]=ans-10;wrong[6]=ans+20;wrong[7]=ans+2;wrong[8]=ans+3;let anscount=4;let answers=[];for(let j=0;j';for(let i=0;i'+opt.descr+'';} s+='';return s;} function getRandomInt(min,max){return Math.floor(Math.random()*(max-min+1))+min;} function getRandomClr(){let ltrs="56789ABCDEF".split('');let clr="#";for(let i=0;i<6;i++){clr+=ltrs[Math.round(Math.random()*(ltrs.length-1))];} return clr;} function getQueryVariable(variable){let query=window.location.search.substring(1);let vars=query.split("&");for(let i=0;i0)s+='