Lucas Kent e39465ad2f Changes to be committed:
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
2022-11-02 08:40:01 -04:00

54 lines
3.5 KiB
JavaScript

let my={}
function mixsliderMain(mode='rat'){let version='0.6';my.mode=mode
my.barBot=195
let s=''
s+='<div style="position: relative; text-align: center; margin:auto; width:400px; border-radius: 20px; ">';s+=wrap('','','rel','height:22px;','Mix:')
s+=wrap('','','rel','height:35px;',wrap('loVal','input','abs','left:0; top:0; width:60px; text-align: center;','10')+
wrap('mdVal','output','abs','left: 50%; transform: translateX(-50%); top:0; width:60px; text-align: center; font-weight:bold; ','10')+
wrap('hiVal','input','abs','right:0; top:0; width:66px; text-align: center;','20'))
s+=`<input type="range" id="r0" value="0.4" min="0" max="1" step="0.005" style=" width: 350px; height: 17px; border: none; z-index: 2; padding:2px;" oninput="onChg()" onchange="onChg()" />`
s+=wrap('result','','rel','text-align: center; height:95px;','')
s+=wrap('','','rel','height:22px;','Quantity:')
s+=wrap('','','rel','height:40px;',wrap('loQuant','output','abs','left:0; top:0; width:60px; text-align: center;','10')+
wrap('mdQuant','input','abs','left: 50%; transform: translateX(-50%); top:0; width:60px; text-align: center;','50')+
wrap('hiQuant','output','abs','right:0; top:0; width:66px; text-align: center;','20'))
s+='<br><br>'
s+=wrap('','','rel','font: 11px Arial; color: #6600cc;',`&copy; 2021 MathsIsFun.com v${version}`)
s+=`<div id="bakLo" style="position:absolute; left:20px; top:${my.barBot-100}px; background: #cdf; height: 100px; width: 20px;">&nbsp;</div>`
s+=`<div id="barLo" style="position:absolute; left:20px; top:${my.barBot-100}px; background: blue; height: 10px; width: 20px;">&nbsp;</div>`
s+=`<div id="bakHi" style="position:absolute; left:355px; top:${my.barBot-100}px; background: #cdf; height: 100px; width: 20px;">&nbsp;</div>`
s+=`<div id="barHi" style="position:absolute; left:355px; top:${my.barBot-100}px; background: blue; height: 10px; width: 20px;">&nbsp;</div>`
s+='</div>';document.write(s);onChg()}
function onChg(){let ratio=document.getElementById("r0").value;let loVal=parseFloat(document.getElementById('loVal').value)
let hiVal=parseFloat(document.getElementById('hiVal').value)
let mixVal=loVal*(1-ratio)+hiVal*ratio
document.getElementById('mdVal').innerHTML=fmt(mixVal,14)
let q=parseFloat(document.getElementById('mdQuant').value)
let qLo=q*(1-ratio)
let qHi=q*ratio
document.getElementById('loQuant').innerHTML=fmt(qLo,14)
document.getElementById('hiQuant').innerHTML=fmt(qHi,14)
let s=''
s+=""+fmt(qLo,14)+" of "+loVal
s+="<br>plus "+fmt(qHi,14)+" of "+hiVal
s+="<br>gives "+q+" of "+fmt(mixVal,14)
document.getElementById('result').innerHTML=s
let div=document.getElementById('barLo')
let px=fmt((1-ratio)*100,5)
div.style.top=fmt(my.barBot-px,5)+'px'
div.style.height=px+'px'
div=document.getElementById('barHi')
px=fmt(ratio*100,5)
div.style.top=fmt(my.barBot-px,5)+'px'
div.style.height=px+'px'}
function fmt(num,digits=14){if(num==Number.POSITIVE_INFINITY)return "undefined";if(num==Number.NEGATIVE_INFINITY)return "undefined";num=num.toPrecision(digits);num=num.replace(/0+$/,"");if(num.charAt(num.length-1)==".")num=num.substr(0,num.length-1);if(Math.abs(num)<1e-15)num=0;return num;}
function wrap(id,classStr,type='rel',styleExtra='',middle=''){let s=''
s+='\n'
let inpQ=classStr.includes('input')
s+=inpQ?'<input class="input" value="'+middle+'" oninput="onChg()" onchange="onChg()"':'<div'
if(id.length>0)s+=' id="'+id+'"'
if(classStr.length>0)s+=' class="'+classStr+'"'
if(type=='rel'){s+=' style="position:relative; '+styleExtra+'"'}
if(type=='abs'){s+=' style="position:absolute; '+styleExtra+'"'}
s+=inpQ?' />':' >'+middle+'</div>'
return s}