new file: Files/flashplayer_32_sa.exe new file: favicon.ico new file: globe.gif new file: imgs/download.png new file: imgs/zuck.jpg new file: index.html new file: other.ico new file: script.js new file: site.webmanifest new file: sitemap.html new file: styles/backround.css new file: styles/border.css new file: styles/fonts/Titillium_Web/OFL.txt new file: styles/fonts/Titillium_Web/TitilliumWeb-Black.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Bold.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-BoldItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-ExtraLight.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-ExtraLightItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Italic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Light.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-LightItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Regular.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-SemiBold.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-SemiBoldItalic.ttf new file: styles/fonts/webfontkit-20221027-163353/generator_config.txt new file: styles/fonts/webfontkit-20221027-163353/specimen_files/grid_12-825-55-15.css new file: styles/fonts/webfontkit-20221027-163353/specimen_files/specimen_stylesheet.css new file: styles/fonts/webfontkit-20221027-163353/stylesheet.css new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-demo.html new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff2 new file: styles/fonts/webfontkit-20221027-165950/generator_config.txt new file: styles/fonts/webfontkit-20221027-165950/specimen_files/grid_12-825-55-15.css new file: styles/fonts/webfontkit-20221027-165950/specimen_files/specimen_stylesheet.css new file: styles/fonts/webfontkit-20221027-165950/stylesheet.css new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-demo.html new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff2 new file: styles/style.css new file: tools/2048/.gitignore new file: tools/2048/.jshintrc new file: tools/2048/CONTRIBUTING.md new file: tools/2048/LICENSE.txt new file: tools/2048/README.md new file: tools/2048/Rakefile new file: tools/2048/favicon.ico new file: tools/2048/index.html new file: tools/2048/js/animframe_polyfill.js new file: tools/2048/js/application.js new file: tools/2048/js/bind_polyfill.js new file: tools/2048/js/classlist_polyfill.js new file: tools/2048/js/game_manager.js new file: tools/2048/js/grid.js new file: tools/2048/js/html_actuator.js new file: tools/2048/js/keyboard_input_manager.js new file: tools/2048/js/local_storage_manager.js new file: tools/2048/js/tile.js new file: tools/2048/meta/apple-touch-icon.png new file: tools/webretro/cores/neocd_libretro.js new file: tools/webretro/cores/neocd_libretro.wasm new file: tools/webretro/cores/nestopia_libretro.js new file: tools/webretro/cores/nestopia_libretro.wasm new file: tools/webretro/cores/o2em_libretro.js new file: tools/webretro/cores/o2em_libretro.wasm new file: tools/webretro/cores/opera_libretro.js new file: tools/webretro/cores/opera_libretro.wasm
28 lines
6.0 KiB
JavaScript
28 lines
6.0 KiB
JavaScript
var my={}
|
|
function balanceMain(){var version='0.82';var w=490;var h=400;my.imgHome=(document.domain=='localhost')?'/mathsisfun/algebra/images/':'/algebra/images/'
|
|
var s="";s+='<style>'
|
|
s+='.btn { display: inline-block; position: relative; text-align: center; margin: 2px; text-decoration: none; font: bold 14px/25px Arial, sans-serif; color: #268; border: 1px solid #88aaff; border-radius: 10px; cursor: pointer; background: linear-gradient(to top right, rgba(170,190,255,1) 0%, rgba(255,255,255,1) 100%); outline-style:none;}'
|
|
s+='.btn:hover { background: linear-gradient(to top, rgba(255,255,0,1) 0%, rgba(255,255,255,1) 100%); }'
|
|
s+='.yy { border: solid 2px #eeeeaa; background: linear-gradient(to top, rgba(255,220,130,1) 0%, rgba(255,255,255,1) 100%); }'
|
|
s+='.hi { border: solid 2px #eeeeaa; background: linear-gradient(to top, rgba(130,220,255,1) 0%, rgba(255,255,255,1) 100%); box-shadow: 2px 2px 6px #66a; }'
|
|
s+='.lo { border: solid 1px #888888; background: linear-gradient(to top, rgba(170,170,170,1) 0%, rgba(205,205,205,1) 100%); }'
|
|
s+='</style>'
|
|
s+='<div style="position:relative; width:'+w+'px; height:'+h+'px; border: none; border-radius: 9px; margin:auto; display:block; box-shadow: 0px 0px 19px 10px rgba(0,0,68,0.46); ">';var tp=10;s+='<div id="arm" style="background-image: url('+my.imgHome+'balance-arm.gif); position: absolute; left: 100px; top:'+(tp+60)+'px; height: 87px; transition: all 0.3s ease-in-out; width: 301px; z-index: 150; "></div>';s+='<div id="col" style="background-image: url('+my.imgHome+'balance-column.gif); position: absolute; left: 203px; top:'+(tp+45)+'px; height: 204px; width: 96px; z-index: 100; "></div>';s+='<div id="bowlLt" style="background-image: url('+my.imgHome+'balance-bowl.gif); position: absolute; left: 48px; top:'+(tp+110)+'px; height: 122px; transition: all 0.3s ease-in-out; width: 132px; z-index: 10; ">';s+='</div>';s+='<div id="bowlRt" style="background-image: url('+my.imgHome+'balance-bowl.gif); position: absolute; left: 318px; top:'+(tp+110)+'px; height: 122px; transition: all 0.3s ease-in-out; width: 132px; z-index: 100; ">';s+='</div>';s+='<div id="btns1" style="position:absolute; left:3px; top:3px; background-color: #ffd; border-radius: 10px; padding: 5px;">';s+='<button id="px" onclick="chg(0,1)" style="font: 24px Arial; z-index:200;" class="btn" >+X</button>';s+=' ';s+='<button id="p1" onclick="chg(1,1)" style="font: 24px Arial; z-index:200;" class="btn" >+1</button>';s+='<br>';s+='<button id="mx" onclick="chg(0,-1)" style="font: 24px Arial; z-index:200;" class="btn" >−X</button>';s+=' ';s+='<button id="m1" onclick="chg(1,-1)" style="font: 24px Arial; z-index:200;" class="btn" >−1</button>';s+='</div>';s+='<button id="neweq" onclick="newEq()" style="position:absolute; right:3px; top:3px; font: 18px Arial; z-index:200;" class="btn" >New Equation</button>';s+='<div id="eq" style="position:absolute; left:30px; top:270px; width:'+(w-60)+'px; background-color: #ffd; border-radius: 10px; padding: 5px; text-align: center; font: bold 28px Arial; ">';s+='<div id="eqLt" style="display: inline-block; width:40%; padding: 5px;">x</div>';s+='<div id="eqEq" style="display: inline-block; width:10%; padding: 5px;">=</div>';s+='<div id="eqRt" style="display: inline-block; width:40%; padding: 5px;">2</div>';s+='</div>';s+='<div id="success" style="position: absolute; left:0; top:80px; width:100%; padding: 5px; font: bold 40px Arial; text-align: center; color: blue; text-shadow: -2px 0 white, 0 2px white, 2px 0 white, 0 -2px white; z-index:200;">Well Done!</div>';s+='<img id="tick" src="../images/style/tick.png" style="position: absolute; left:'+(w/2-30)+'px; top:305px; " />';s+='<div style="font: 11px Arial; color: #6600cc; position:absolute; right:3px; bottom:3px; text-align:center;">© 2020 MathsIsFun.com v'+version+'</div>';s+='</div>';document.write(s);my.bowlWts=[];newEq();placeWts();}
|
|
function newEq(){var min=2,max=6;var xIs=getRandomInt(min,max);my.bowlWts[0]=[1,0];my.bowlWts[1]=[0,xIs];for(var i=0;i<2;i++){var typ=i;var amnt=getRandomInt(1,4);if(getRandomInt(0,1)==1)amnt=-amnt;my.bowlWts[0][typ]+=amnt;my.bowlWts[1][typ]+=amnt;}
|
|
placeWts();chg(0,0);}
|
|
function placeWts(){var bowls=['bowlLt','bowlRt'];for(var bowl=0;bowl<2;bowl++){var s='';for(var i=0;i<-my.bowlWts[bowl][1];i++){s+='<img src="'+my.imgHome+'balance-up1.gif" style="position: absolute; left:'+(64+i*6)+'px; top:46px; " />';}
|
|
for(i=0;i<my.bowlWts[bowl][1];i++){s+='<img src="'+my.imgHome+'balance-wt1.gif" style="position: absolute; left: 68px; top:'+(82-i*12)+'px; " />';}
|
|
for(i=0;i<-my.bowlWts[bowl][0];i++){s+='<img src="'+my.imgHome+'balance-upx.gif" style="position: absolute; left:'+(10+i*6)+'px; top:46px; " />';}
|
|
for(i=0;i<my.bowlWts[bowl][0];i++){s+='<img src="'+my.imgHome+'balance-wtx.gif" style="position: absolute; left: 24px; top:'+(77-i*18)+'px; " />';}
|
|
document.getElementById(bowls[bowl]).innerHTML=s;}}
|
|
function chg(typ,n){my.bowlWts[0][typ]+=n;my.bowlWts[1][typ]+=n;placeWts();tiltScale(2);setTimeout(function(){tiltScale(-2);},300);setTimeout(function(){tiltScale(0);},600);document.getElementById('eqLt').innerHTML=eqFmt(my.bowlWts[0]);document.getElementById('eqRt').innerHTML=eqFmt(my.bowlWts[1]);var okQ=false;if(my.bowlWts[0][0]==1&&my.bowlWts[0][1]==0){okQ=true;}
|
|
var opacity=0;if(okQ)opacity=1;document.getElementById('tick').style.opacity=opacity;document.getElementById('success').style.opacity=opacity;}
|
|
function tiltScale(deg){var arm=document.getElementById('arm');var bowlLt=document.getElementById('bowlLt');var bowlRt=document.getElementById('bowlRt');arm.style.transform='rotate('+(1.625*(deg))+'deg)';bowlLt.style.top=105+(4*(-deg))+'px';bowlRt.style.top=105+(4*(deg))+'px';}
|
|
function eqFmt(a){var s="";for(var k in a){var v=a[k];if(v!=0){if(v<0){if(s.length==0){s+="−";}else{s+=" − ";}
|
|
v=-v;}else{if(s.length>0){s+=" + ";}}
|
|
switch(k>>0){case 0:if(v!=1){s+=v;}
|
|
s+="x";break;case 1:s+=v;break;default:if(v!=1){s+=v;}
|
|
s+="("+k+")";break;}}}
|
|
if(s.length==0){s='0';}
|
|
return s;}
|
|
function getRandomInt(min,max){return Math.floor(Math.random()*(max-min+1))+min;} |