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
13 lines
4.3 KiB
JavaScript
13 lines
4.3 KiB
JavaScript
function scinotationnumMain(){w=360;h=160;engQ=false;var id="scinotationnum";s="";s+='<div style="position:relative; width:'+w+'px; height:'+h+'px; border: none; border-radius: 20px; background-color: #eeeeff; margin:auto; display:block;">';s+='<div style="font: bold 15px arial; color: #000000; position:absolute; left:5px; top:8px; ">Scientific Notation:</div>';s+='<input type="coeff" id="coeff" style="font-size: 19px; position:absolute; left:80px; top:30px; width:145px; z-index:2; color: #0000ff; background-color: #f0f8ff; text-align:right; padding-right: 8px; border-radius: 10px; " value="3.1416" onKeyUp="sci2num()" />';s+='<div style="font: 20px arial; font-weight: bold; color: #000000; position:absolute; left:240px; top:30px; ">× 10</div>';s+='<input type="text" id="expon" style="font-size: 17px; position:absolute; left:280px; top:14px; width:50px; z-index:2; color: #0000ff; background-color: #f0f8ff; text-align:left; padding-left: 8px; border-radius: 10px; " value="2" onKeyUp="sci2num()" />';s+='<button style="font: 12px Arial; position:absolute; left:5px; top:32px;" class="togglebtn" onclick="sciExample()" >Example</button>';s+='<div id="err" style="font: bold 12px arial; color: #ff0000; position:absolute; left:5px; top:59px; width:350px; text-align:center;"> </div>';s+='<div style="font: bold 15px arial; color: #000000; position:absolute; left:5px; top:80px; ">Number:</div>';s+='<div id="ansnum" style="font: 13pt arial; font-weight: bold; position:absolute; left:80px; top:80px; width:263px; text-align:center; background-color: #ffffff; border: 1px solid black; word-wrap: break-word;"> </div>';s+='<div style="font: 7pt arial; font-weight: bold; color: #6600cc; position:absolute; bottom:5px; left:5px; text-align:center;">© 2015 MathsIsFun.com v 0.85</div>';s+='</div>';document.write(s);sci2num();}
|
|
function sciExample(){var coeff=Math.floor((Math.random()*9)+1)+Math.random();coeff=coeff.toPrecision(Math.floor((Math.random()*8)+2));var expon=Math.floor((Math.random()*19)+1)-7;document.getElementById("coeff").value=coeff;document.getElementById("expon").value=expon;sci2num();}
|
|
function sci2num(){var coeff=document.getElementById("coeff").value;var expon=document.getElementById("expon").value;if(expon<-99)expon=-99;if(expon>99)expon=99;document.getElementById("expon").value=expon;coeff=coeff.toString().trim();coeff=coeff.replace(/^0+(?!\.|$)/,"");coeff=coeff.replace(/[a-z]/gi,"");document.getElementById("coeff").value=coeff;var negQ=false;if(coeff.charAt(0)=="-"){coeff=coeff.substr(1);negQ=true;}
|
|
var err="";switch(coeff.length){case 0:err="Enter a number";break;case 1:if(isNaN(coeff))err="Enter a number";break;default:var leadDig=coeff.charAt(0);var nextDig=coeff.charAt(1);if(leadDig>=1&&leadDig<=9){}else{err="The digits part should be from 1 to 9.999...";}
|
|
if(nextDig!="."){err="The digits part should be from 1 to 9.999...";}}
|
|
document.getElementById("err").innerHTML=err;v=moveDec(coeff,expon);if(negQ)v="-"+v;document.getElementById("ansnum").innerHTML=v;return;}
|
|
function toFixed(x){if(Math.abs(x)<1.0){var e=parseInt(x.toString().split('e-')[1]);var digits=x.toString().split('e-')[0];digits=digits.replace(/\./gi,'');console.log("toFixed A",x,digits);if(e){console.log("D",x,digits);x*=Math.pow(10,e-1);x=x.toPrecision(digits.length);x='0.'+(new Array(e)).join('0')+x.toString().substring(2);}}else{var e=parseInt(x.toString().split('e+')[1]);var digits=x.toString().split('e+')[0];digits=digits.replace(/\./gi,"");console.log("toFixed A",x,digits,e);x/=Math.pow(10,e);console.log("toFixed C",x,e);x=x.toPrecision(digits.length);console.log("toFixed D",x);x+=(new Array(e+1)).join('0');}
|
|
return x;}
|
|
function moveDec(val,n){if(isNaN(n))return val;var was=val;var negQ=false;if(val.charAt(0)=="-"){val=val.substr(1);negQ=true;}
|
|
var decAt=val.indexOf(".");if(decAt==-1)decAt=val.length;val=val.replace(/\./gi,'');var newDec=decAt+Number(n);if(newDec<0){val="0."+"0".repeat(-newDec)+val;}else{if(newDec>val.length){val=val+"0".repeat(newDec-val.length);}else{val=val.substr(0,newDec)+"."+val.substr(newDec);}}
|
|
if(val.charAt(0)==".")val="0"+val;if(val.charAt(val.length-1)==".")val=val.substr(0,val.length-1);return val;}
|
|
String.prototype.repeat=function(count){if(count<1)return '';var result='',pattern=this.valueOf();while(count>1){if(count&1)result+=pattern;count>>=1,pattern+=pattern;}
|
|
return result+pattern;}; |