瀏覽代碼

Format all of the source files

master
Fen Dweller 5 年之前
父節點
當前提交
51985708e0
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: E80B35A6F11C3656
共有 7 個文件被更改,包括 4635 次插入4705 次删除
  1. +1
    -1
      darkmode.js
  2. +1859
    -1859
      features.js
  3. +1011
    -1080
      game.js
  4. +1062
    -1062
      recursive-desc.js
  5. +500
    -501
      recursive-macro.js
  6. +17
    -17
      sounds.js
  7. +185
    -185
      units.js

+ 1
- 1
darkmode.js 查看文件

@@ -10,7 +10,7 @@ function toggleDarkMode(e) {

function setDarkMode(darkMode) {
dark = darkMode;
window.localStorage.setItem("dark-mode",dark);
window.localStorage.setItem("dark-mode", dark);
if (dark) {
document.querySelector("body").classList.remove("light");
document.querySelector("body").classList.add("dark");


+ 1859
- 1859
features.js
文件差異過大導致無法顯示
查看文件


+ 1011
- 1080
game.js
文件差異過大導致無法顯示
查看文件


+ 1062
- 1062
recursive-desc.js
文件差異過大導致無法顯示
查看文件


+ 500
- 501
recursive-macro.js
文件差異過大導致無法顯示
查看文件


+ 17
- 17
sounds.js 查看文件

@@ -2,37 +2,37 @@ let last_used = {};

let sounds = {
"crush": [["Thump.", "Thoomp."], ["Crunch."], ["Crrruunch."], ["CRUNCH!"], ["CRRRUNNCH!"], ["SKRRRRUNCH!"], ["SKRRRRRRRSMASH!"]],
"swallow": [["Ulp.", "Glp.", "Slurp."], ["Glrph.", "Glurk."], ["Gluuuurrkph!", "Glurp - GLK."],["GLRP!", "GULP!", "GLUK!"],["GLRRRRPKH!", "GLUUUURK!"],["GLUUUUURRPKH!", "GLOOOORPH-GLK!"]],
"swallow": [["Ulp.", "Glp.", "Slurp."], ["Glrph.", "Glurk."], ["Gluuuurrkph!", "Glurp - GLK."], ["GLRP!", "GULP!", "GLUK!"], ["GLRRRRPKH!", "GLUUUURK!"], ["GLUUUUURRPKH!", "GLOOOORPH-GLK!"]],
"drip":
[["Drip."],["Dribble"],["Drip-sploosh"],["Dribble-SPLOOSH!"],["SPLOOOOOSH!!"]],
"liquid": [["Sploosh."],["Gush!"],["SPLOOSH!"],["SPLOOSH!"],["SPLOOOOOOSH!"]],
"insert": [["Slp.", "Shlk."],["Shlp.", "Shlrp."],["Shlllp."],["SHLP!", "SQUELCH!"],["SHLLLLRP!"]],
"drop": [["Thump."],["Thump!"],["Splat."],["Splat!"],["SPLAT!"]],
"belch": [["Burp.", "Urp."],["Urph.", "Burph."],["Urrrrrph."],["UuuuuuuRRRRRPPHHHhhhh."],["UUUURRRRPHH!"],["BUUUURRRRRRRRPPPHHH!"]],
[["Drip."], ["Dribble"], ["Drip-sploosh"], ["Dribble-SPLOOSH!"], ["SPLOOOOOSH!!"]],
"liquid": [["Sploosh."], ["Gush!"], ["SPLOOSH!"], ["SPLOOSH!"], ["SPLOOOOOOSH!"]],
"insert": [["Slp.", "Shlk."], ["Shlp.", "Shlrp."], ["Shlllp."], ["SHLP!", "SQUELCH!"], ["SHLLLLRP!"]],
"drop": [["Thump."], ["Thump!"], ["Splat."], ["Splat!"], ["SPLAT!"]],
"belch": [["Burp.", "Urp."], ["Urph.", "Burph."], ["Urrrrrph."], ["UuuuuuuRRRRRPPHHHhhhh."], ["UUUURRRRPHH!"], ["BUUUURRRRRRRRPPPHHH!"]],
"fart":
[["Pft."],["Pffft."],["Pfffffbt."],["Frrrrrrrt."],["FRRRRRRRRPBBT!"]],
[["Pft."], ["Pffft."], ["Pfffffbt."], ["Frrrrrrrt."], ["FRRRRRRRRPBBT!"]],
"scat":
[["Clench."],["Squeeeeeze."],["Squeeeeeeeeeeeze."],["Sqlllllch."],["SQLLLLLLCH!"]],
[["Clench."], ["Squeeeeeze."], ["Squeeeeeeeeeeeze."], ["Sqlllllch."], ["SQLLLLLLCH!"]],
"digest":
[["Grrgle."],["Grrrrgle"],["Grrrrlglorp."],["GrrrrGLRRRLPH!"],["GRRRRRLGPRLHK!"]],
[["Grrgle."], ["Grrrrgle"], ["Grrrrlglorp."], ["GrrrrGLRRRLPH!"], ["GRRRRRLGPRLHK!"]],
"goo":
[["Splat."], ["Squish."], ["Squish!"], ["SQLCH!"], ["SQLLLLRCH!"], ["SQQQQUEEEEELLCH!"]],
[["Splat."], ["Squish."], ["Squish!"], ["SQLCH!"], ["SQLLLLRCH!"], ["SQQQQUEEEEELLCH!"]],
"vomit":
[["Hurk."], ["Hurrk."], ["Bleugh."], ["Bleugh!"], ["Bleeeugh!"], ["BLEEEUGHK!"]],
[["Hurk."], ["Hurrk."], ["Bleugh."], ["Bleugh!"], ["Bleeeugh!"], ["BLEEEUGHK!"]],
"breath":
[["Woosh."],["Fwoosh."],["FWOOSH."],["FWOOSH!"],["FWOOOOOOSH!"]],
[["Woosh."], ["Fwoosh."], ["FWOOSH."], ["FWOOSH!"], ["FWOOOOOOSH!"]],
"chew":
[["Snap.", "Crack."],["Crunch."],["Crack!"],["CRUNCH!"],["CRRRUNCH!"]],
[["Snap.", "Crack."], ["Crunch."], ["Crack!"], ["CRUNCH!"], ["CRRRUNCH!"]],
"magic":
[["Zap."],["Zap!"],["Fwoosh!"]]
[["Zap."], ["Zap!"], ["Fwoosh!"]]
};

function pickByMass(name, mass) {
let list = sounds[name];
let index = Math.floor(Math.log10(mass/100)/2);
let index = Math.floor(Math.log10(mass / 100) / 2);
index = Math.max(index, 0);

choice = index < list.length ? list[index] : list[list.length-1];
choice = index < list.length ? list[index] : list[list.length - 1];

let subindex = Math.floor(Math.random() * Math.floor(choice.length));

@@ -47,5 +47,5 @@ function pickByMass(name, mass) {
}

function getSound(name, mass) {
return "<i>" + pickByMass(name,mass) + "</i>";
return "<i>" + pickByMass(name, mass) + "</i>";
}

+ 185
- 185
units.js 查看文件

@@ -1,10 +1,10 @@
'use strict';

function round(number,precision=3) {
return Math.round(number*Math.pow(10,precision)) / Math.pow(10,precision);
function round(number, precision = 3) {
return Math.round(number * Math.pow(10, precision)) / Math.pow(10, precision);
}

function numberRough(value,suffix="") {
function numberRough(value, suffix = "") {
if (value == 1) {
return "a single";
} else if (value < 5) {
@@ -15,7 +15,7 @@ function numberRough(value,suffix="") {
return "a dozen";
} else {
var scale = Math.floor(Math.log10(value));
switch(scale) {
switch (scale) {
case 1: return "dozens " + suffix;
case 2: return "hundreds " + suffix;
default:
@@ -26,9 +26,9 @@ function numberRough(value,suffix="") {
else if (scale % 3 == 2)
prefix = "hundreds of ";

let order = Math.floor(scale/3);
let order = Math.floor(scale / 3);

switch(order) {
switch (order) {
case 1: return prefix + "thousands " + suffix;
case 2: return prefix + "millions " + suffix;
case 3: return prefix + "billions " + suffix;
@@ -45,12 +45,12 @@ function fixedIfDecimal(num, fixed) {
if (fixed === undefined)
return num.toString();
else;
return num.toFixed(fixed);
return num.toFixed(fixed);
}

function number(value, type="full", fixed) {
function number(value, type = "full", fixed) {
var val = parseFloat(value);
switch(type) {
switch (type) {
case "full":
if (Math.log(value) / Math.log(10) < 10) {
return fixedIfDecimal(val, fixed);
@@ -67,7 +67,7 @@ function number_words(value) {
if (scale < 0) {
return fixedIfDecimal(value, fixed);
}
switch(scale) {
switch (scale) {
case 0: return value.toString();
case 1: return Math.round(value / 1e3).toString() + " thousand";
case 2: return Math.round(value / 1e6).toString() + " million";
@@ -99,7 +99,7 @@ function number_words_repeated(value, fixed) {
var scale = Math.floor(Math.log(value) / Math.log(1000));
if (scale < 0)
return fixedIfDecimal(value, fixed);
switch(scale) {
switch (scale) {
case 0: return fixedIfDecimal(value, fixed);
case 1: return Math.round(value / 1e3).toString() + " thousand";
case 2: return Math.round(value / 1e6).toString() + " million";
@@ -120,7 +120,7 @@ function number_prefix(value, fixed) {
var scale = Math.floor(Math.log(value) / Math.log(1000));
if (scale < 0)
return fixedIfDecimal(value, fixed);
switch(scale) {
switch (scale) {
case 0: return fixedIfDecimal(value, fixed);
case 1: return Math.round(value / 1e3).toString() + "K";
case 2: return Math.round(value / 1e6).toString() + "M";
@@ -133,8 +133,8 @@ function number_prefix(value, fixed) {
}
}

function mass(kg, type="metric", singular=false) {
switch(type) {
function mass(kg, type = "metric", singular = false) {
switch (type) {
case "metric": return metricMass(kg, singular);
case "SI": return metricSymMass(kg, singular);
case "customary": return customaryMass(kg, singular);
@@ -143,8 +143,8 @@ function mass(kg, type="metric", singular=false) {
}
}

function length(m, type="metric", singular=false) {
switch(type) {
function length(m, type = "metric", singular = false) {
switch (type) {
case "metric": return metricLength(m, singular);
case "SI": return metricSymLength(m, singular);
case "customary": return customaryLength(m, singular);
@@ -153,8 +153,8 @@ function length(m, type="metric", singular=false) {
}
}

function area(m2, type="metric", singular=false) {
switch(type) {
function area(m2, type = "metric", singular = false) {
switch (type) {
case "metric": return metricArea(m2, singular);
case "SI": return metricSymArea(m2, singular);
case "customary": return customaryArea(m2, singular);
@@ -163,8 +163,8 @@ function area(m2, type="metric", singular=false) {
}
}

function volume(m3, type="metric", singular=false) {
switch(type) {
function volume(m3, type = "metric", singular = false) {
switch (type) {
case "metric": return metricVolume(m3, singular);
case "SI": return metricSymVolume(m3, singular);
case "customary": return customaryVolume(m3, singular);
@@ -173,442 +173,442 @@ function volume(m3, type="metric", singular=false) {
}
}

function metricMass(kg, singular=false) {
if (kg < 1/1000) {
let mass = round(kg * 1e6,0);
function metricMass(kg, singular = false) {
if (kg < 1 / 1000) {
let mass = round(kg * 1e6, 0);
return mass + (singular || mass == 1 ? " milligram" : " milligrams");
} else if (kg < 1) {
let mass = round(kg * 1000,0);
let mass = round(kg * 1000, 0);
return mass + (singular || mass == 1 ? " gram" : " grams");
} else if (kg < 5000) {
let mass = round(kg,0);
let mass = round(kg, 0);
return mass + (singular || mass == 1 ? " kilogram" : " kilograms");
} else if (kg < 5000000) {
let mass = round(kg / 1000,1);
let mass = round(kg / 1000, 1);
return mass + (singular || mass == 1 ? " metric ton" : " metric tons");
} else if (kg < 5000000000) {
let mass = round(kg / 1000000,1);
let mass = round(kg / 1000000, 1);
return mass + (singular || mass == 1 ? " kiloton" : " kilotons");
} else if (kg < 5000000000000) {
let mass = round(kg / 1000000000,1);
let mass = round(kg / 1000000000, 1);
return mass + (singular || mass == 1 ? " megaton" : " megatons");
} else {
let mass = round(kg / 1000000000000,1);
let mass = round(kg / 1000000000000, 1);
return mass + (singular || mass == 1 ? " gigaton" : " gigatons");
}
}

function metricSymMass(kg, singular=false) {
if (kg < 1/1000) {
let mass = round(kg * 1e6,0);
function metricSymMass(kg, singular = false) {
if (kg < 1 / 1000) {
let mass = round(kg * 1e6, 0);
return mass + " mg";
} else if (kg < 1) {
let mass = round(kg * 1000,0);
let mass = round(kg * 1000, 0);
return mass + " g";
} else if (kg < 5000) {
let mass = round(kg,0);
let mass = round(kg, 0);
return mass + " kg";
} else if (kg < 5000000) {
let mass = round(kg / 1000,1);
let mass = round(kg / 1000, 1);
return mass + " t";
} else if (kg < 5000000000) {
let mass = round(kg / 1000000,1);
let mass = round(kg / 1000000, 1);
return mass + " kt";
} else if (kg < 5000000000000) {
let mass = round(kg / 1000000000,1);
let mass = round(kg / 1000000000, 1);
return mass + " mt";
} else {
let mass = round(kg / 1000000000000,1);
let mass = round(kg / 1000000000000, 1);
return mass + " gt";
}
}

function customaryMass(kg, singular=false) {
function customaryMass(kg, singular = false) {
let lbs = kg * 2.2;

if (lbs < 1) {
let mass = round(lbs * 16,0);
let mass = round(lbs * 16, 0);
return mass + (singular || mass == 1 ? " ounce" : " ounces");
} else if (lbs < 2000) {
let mass = round(lbs,0);
let mass = round(lbs, 0);
return mass + (singular || mass == 1 ? " pound" : " pounds");
} else {
let mass = round(lbs / 2000,1);
let mass = round(lbs / 2000, 1);
return mass + (singular || mass == 1 ? " ton" : " tons");
}
}

function customarySymMass(kg, singular=false) {
function customarySymMass(kg, singular = false) {
let lbs = kg * 2.2;

if (lbs < 1) {
let mass = round(lbs * 16,0);
let mass = round(lbs * 16, 0);
return mass + " oz";
} else if (lbs < 2000) {
let mass = round(lbs,0);
let mass = round(lbs, 0);
return mass + (singular || mass == 1 ? " lb" : " lbs");
} else {
let mass = round(lbs / 2000,1);
let mass = round(lbs / 2000, 1);
return mass + (singular || mass == 1 ? " ton" : " tons");
}
}

function approxMass(kg, singular=false) {
function approxMass(kg, singular = false) {
if (kg < 4500) {
let mass = round(kg/1000,2);
let mass = round(kg / 1000, 2);
return mass + (singular || mass == 1 ? "car" : " cars");
} else if (kg < 54431) {
let mass = round(kg/6000,2);
let mass = round(kg / 6000, 2);
return mass + (singular || mass == 1 ? " elephant" : " elephants");
//this unit almost never gets used and is mostly redundant, perhaps remove it if units are cleaned up
} else if (kg < 10000000) {
let mass = round(kg/54431.1,2);
let mass = round(kg / 54431.1, 2);
return mass + (singular || mass == 1 ? " tank" : " tanks");
} else if (kg < 5.2e10) {
let mass = round(kg/9.7e7,2);
let mass = round(kg / 9.7e7, 2);
return mass + (singular || mass == 1 ? " aircraft carrier" : " aircraft carriers");
} else if (kg < 1.5e13) {
let mass = round(kg/5.2e10,2);
return mass + (singular || mass == 1 ? " Great Wall of China" : " Great Wall Of Chinas");
let mass = round(kg / 5.2e10, 2);
return mass + (singular || mass == 1 ? " Great Wall of China" : " Great Wall Of Chinas");
} else if (kg < 5e21) {
let mass = round(kg/1.5e15,2);
let mass = round(kg / 1.5e15, 2);
return mass + (singular || mass == 1 ? " New York City" : " New York Cities");
//this figure includes a lot of underlying bedrock, just the city itself is 1.13587210581190e11 but I needed a good figure to fit in this spot
} else if (kg < 6e23) {
let mass = round(kg/4.6e20,2);
let mass = round(kg / 4.6e20, 2);
return mass + (singular || mass == 1 ? " Australia" : " Australias");
//this is a napkin math number based on the land area of Australia, 25km of height, and rough density of rock
} else if (kg < 2e27) {
let mass = round(kg/6e24,2);
return mass + (singular || mass == 1 ? " Earth" :" Earths");
} else if (kg < 1.4e39) {
let mass = round(kg/2e30,2);
return mass + (singular || mass == 1 ? " Sun" :" Suns");
} else if (kg < 2e27) {
let mass = round(kg / 6e24, 2);
return mass + (singular || mass == 1 ? " Earth" : " Earths");
} else if (kg < 1.4e39) {
let mass = round(kg / 2e30, 2);
return mass + (singular || mass == 1 ? " Sun" : " Suns");
} else {
let mass = round(kg/1.4e42,2);
return mass + (singular || mass == 1 ? " Milky Way" :" Milky Ways");
let mass = round(kg / 1.4e42, 2);
return mass + (singular || mass == 1 ? " Milky Way" : " Milky Ways");
}
}

function metricLength(m, singular=false) {
if (m < 1/100) {
let length = round(m * 1000,2);
function metricLength(m, singular = false) {
if (m < 1 / 100) {
let length = round(m * 1000, 2);
return length + (singular || length == 1 ? " millimeter" : " millimeters");
} else if (m < 1) {
let length = round(m * 100,0);
let length = round(m * 100, 0);
return length + (singular || length == 1 ? " centimeter" : " centimeters");
} else if (m < 500) {
let length = round(m,2);
let length = round(m, 2);
return length + (singular || length == 1 ? " meter" : " meters");
} else if (m < 1e12) {
let length = round(m / 1000,1);
let length = round(m / 1000, 1);
return length + (singular || length == 1 ? " kilometer" : " kilometers");
} else if (m < 1e15) {
let length = round(m / 1e6,1);
let length = round(m / 1e6, 1);
return length + (singular || length == 1 ? " megameter" : " megameters");
} else if (m < 1e18) {
let length = round(m / 1e9,1);
let length = round(m / 1e9, 1);
return length + (singular || length == 1 ? " gigameter" : " gigameters");
} else {
let length = round(m / 1e12,1);
let length = round(m / 1e12, 1);
return length + (singular || length == 1 ? " terameter" : " terameters");
}
}

function metricSymLength(m, singular=false) {
if (m < 1/100) {
let length = round(m * 1000,2);
function metricSymLength(m, singular = false) {
if (m < 1 / 100) {
let length = round(m * 1000, 2);
return length + " mm";
} else if (m < 1) {
let length = round(m * 100,0);
let length = round(m * 100, 0);
return length + " cm";
} else if (m < 500) {
let length = round(m,2);
let length = round(m, 2);
return length + " m";
} else {
let length = round(m / 1000,1);
let length = round(m / 1000, 1);
return length + " km";
}
}

function customaryLength(m, singular=false) {
function customaryLength(m, singular = false) {
let ft = m * 3.28084;

if (ft < 1) {
let length = round(ft * 12,0);
let length = round(ft * 12, 0);
return length + (singular || length == 1 ? " inch" : " inches");
} else if (ft < 5280) {
let end = customaryLength((ft - Math.floor(ft))/3.28084, singular);
let end = customaryLength((ft - Math.floor(ft)) / 3.28084, singular);
let length = Math.floor(ft);
return length + (singular || length == 1 ? " foot" : " feet") + " " + end;
} else {
let length = round(ft/5280,1);
let length = round(ft / 5280, 1);
return length + (singular || length == 1 ? " mile" : " miles");
}
}

function customarySymLength(m, singular=false) {
function customarySymLength(m, singular = false) {
let ft = m * 3.28084;

if (ft < 1) {
let length = round(ft * 12,0);
let length = round(ft * 12, 0);
return length + "\"";
} else if (ft < 5280) {
let end = customarySymLength((ft - Math.floor(ft))/3.28084, singular);
let end = customarySymLength((ft - Math.floor(ft)) / 3.28084, singular);
let length = Math.floor(ft);
return length + "'" + " " + end;
} else {
let length = round(ft/5280,1);
let length = round(ft / 5280, 1);
return length + " mi";
}
}

function approxLength(m, singular=false) {
function approxLength(m, singular = false) {
if (m < 25) {
let length = round(m/1.9,1);
let length = round(m / 1.9, 1);
return length + (singular || length == 1 ? " person" : " people");
} else if (m < 350) {
let length = round(m/49,1);
let length = round(m / 49, 1);
return length + (singular || length == 1 ? " football field" : " football fields");
} else if (m < 20000) {
let length = round(m/449,1);
let length = round(m / 449, 1);
return length + (singular || length == 1 ? " Empire State Building" : " Empire State Buildings");
} else if (m < 2000000) {
let length = round(m/80467.2,1);
let length = round(m / 80467.2, 1);
return length + (singular || length == 1 ? " Panama Canal" : " Panama Canals");
} else if (m < 3474574*2) {
let length = round(m/3474574,1);
} else if (m < 3474574 * 2) {
let length = round(m / 3474574, 1);
return length + (singular || length == 1 ? " Moon" : " moons");
} else if (m < 12.742e6*130) {
let length = round(m/12.742e6,2);
} else if (m < 12.742e6 * 130) {
let length = round(m / 12.742e6, 2);
return length + (singular || length == 1 ? " Earth" : " earths");
} else if (m < 149.6e12) {
let length = round(m/149.6e9,3);
let length = round(m / 149.6e9, 3);
return length + (singular || length == 1 ? " AU" : " AUs");
} else if (m < 9.4607e22) {
let length = round(m/9.4607e15,3);
let length = round(m / 9.4607e15, 3);
return length + (singular || length == 1 ? " light year" : " light years");
} else if (m < 3e19) {
let length = round(m/3.0856776e16,3);
let length = round(m / 3.0856776e16, 3);
return length + (singular || length == 1 ? " parsec" : " parsecs");
} else if (m < 3e22) {
let length = round(m/3.0856776e19,3);
let length = round(m / 3.0856776e19, 3);
return length + (singular || length == 1 ? " kiloparsec" : " kiloparsecs");
} else if (m < 3e25) {
let length = round(m/3.0856776e22,3);
let length = round(m / 3.0856776e22, 3);
return length + (singular || length == 1 ? " megaparsec" : " megaparsecs");
} else if (m < 3e28) {
let length = round(m/3.0856776e25,3);
let length = round(m / 3.0856776e25, 3);
return length + (singular || length == 1 ? " gigaparsec" : " gigaparsecss");
} else {
let length = round(m/3.0856776e28,3);
let length = round(m / 3.0856776e28, 3);
return length + (singular || length == 1 ? " teraparsec" : " teraparsecs");
}
}

function metricArea(m2, singular=false) {
if (m2 < 1/10) {
let area = round(m2 * 10000,2);
function metricArea(m2, singular = false) {
if (m2 < 1 / 10) {
let area = round(m2 * 10000, 2);
return area + (singular || area == 1 ? " square centimeter" : " square centimeters");
} else if (m2 < 100000) {
let area = round(m2,2);
let area = round(m2, 2);
return area + (singular || area == 1 ? " square meter" : " square meters");
} else {
let area = round(m2 / 1e6,2);
let area = round(m2 / 1e6, 2);
return area + (singular || area == 1 ? " kilometer" : " square kilometers");
}
}

function metricSymArea(m2, singular=false) {
if (m2 < 1/10) {
let area = round(m2 * 10000,2);
function metricSymArea(m2, singular = false) {
if (m2 < 1 / 10) {
let area = round(m2 * 10000, 2);
return area + " cm" + "2".sup();
} else if (m2 < 100000) {
let area = round(m2,2);
let area = round(m2, 2);
return area + " m" + "2".sup();
} else {
let area = round(m2 / 1e6,2);
let area = round(m2 / 1e6, 2);
return area + " km" + "2".sup();
}
}

function customaryArea(m2, singular=false) {
function customaryArea(m2, singular = false) {
let ft2 = m2 * 3.28084 * 3.28084;

if (ft2 < 1) {
let area = round(ft2 * 144,0);
let area = round(ft2 * 144, 0);
return area + (singular || area == 1 ? " square inch" : " square inches");
} else if (ft2 < 5280 * 5280 / 10) {
let area = round(ft2,1);
let area = round(ft2, 1);
return area + (singular || area == 1 ? " square foot" : " square feet");
} else {
let area = round(ft2 / 5280 / 5280,1);
let area = round(ft2 / 5280 / 5280, 1);
return area + (singular || area == 1 ? " square mile" : " square miles");
}
}

function customarySymArea(m2, singular=false) {
if (m2 < 1/10) {
let area = round(m2 * 10000,2);
function customarySymArea(m2, singular = false) {
if (m2 < 1 / 10) {
let area = round(m2 * 10000, 2);
return area + " in" + "2".sup();
} else if (m2 < 100000) {
let area = round(m2,2);
let area = round(m2, 2);
return area + " ft" + "2".sup();
} else {
let area = round(m2 / 1e6,2);
let area = round(m2 / 1e6, 2);
return area + " mi" + "2".sup();
}
}

function approxArea(m2, singular=false) {
function approxArea(m2, singular = false) {
if (m2 < 20000) {
let area = round(m2/5341.85,1);
let area = round(m2 / 5341.85, 1);
return area + (singular || area == 1 ? " football field" : " football fields");
} else if (m2 < 9.36e+15) {
let area = round(m2/10117.1,1);
let area = round(m2 / 10117.1, 1);
return area + (singular || area == 1 ? " block" : " blocks");
} else if (m2 < 3.7920361e+13) {
let area = round(m2/9.36e+8,1);
let area = round(m2 / 9.36e+8, 1);
return area + (singular || area == 1 ? " city" : " cities");
} else if (m2 < 9.4800902e+18) {
let area = round(m2/9.4800902e+12,1);
let area = round(m2 / 9.4800902e+12, 1);
return area + (singular || area == 1 ? " moon" : " moons");
} else if (m2 < 2.8118957330513e+42) {
let area = round(m2/6.4900004e+28,1);
let area = round(m2 / 6.4900004e+28, 1);
return area + (singular || area == 1 ? " solar system" : " solar systems");
} else {
let area = round(m2/2.8118957330513e+42,1);
let area = round(m2 / 2.8118957330513e+42, 1);
return area + (singular || area == 1 ? " milky way" : " milky ways");
}
}

function metricVolume(m3, singular=false) {
if (m3 < 1/1000) {
let volume = round(m3*1e6, 0);
function metricVolume(m3, singular = false) {
if (m3 < 1 / 1000) {
let volume = round(m3 * 1e6, 0);
return volume + (singular || volume == 1 ? " milliliter" : " milliliters");
} else if (m3 < 1) {
let volume = round(m3*1000, 1);
let volume = round(m3 * 1000, 1);
return volume + (singular || volume == 1 ? " liter" : " liters");
} else if (m3 < 1000000) {
let volume = round(m3, 0);
return volume + (singular || volume == 1 ? " cubic meter" : " cubic meters");
} else if (m3 < 1e12){
let volume = round(m3/1e9, 3);
} else if (m3 < 1e12) {
let volume = round(m3 / 1e9, 3);
return volume + (singular || volume == 1 ? " cubic kilometer" : " cubic kilometers");
} else {
let volume = round(m3/1e9, 0);
let volume = round(m3 / 1e9, 0);
return volume + (singular || volume == 1 ? " cubic kilometer" : " cubic kilometers");
}
}

function metricSymVolume(m3, singular=false) {
if (m3 < 1/1000) {
let volume = round(m3*1e6, 0);
function metricSymVolume(m3, singular = false) {
if (m3 < 1 / 1000) {
let volume = round(m3 * 1e6, 0);
return volume + " mL";
} else if (m3 < 1) {
let volume = round(m3*1000, 1);
let volume = round(m3 * 1000, 1);
return volume + " L";
} else if (m3 < 1000000) {
let volume = round(m3, 0);
return volume + " m" + "³";
} else if (m3 < 1e12){
let volume = round(m3/1e9, 3);
} else if (m3 < 1e12) {
let volume = round(m3 / 1e9, 3);
return volume + " km" + "³";
} else {
let volume = round(m3/1e9, 0);
let volume = round(m3 / 1e9, 0);
return volume + " km" + "³";
}
}

function customaryVolume(m3, singular=false) {
function customaryVolume(m3, singular = false) {
let gallons = m3 * 264.172;
if (gallons < 1/16) {
let volume = round(gallons*128,0);
if (gallons < 1 / 16) {
let volume = round(gallons * 128, 0);
return volume + (singular || volume == 1 ? " fluid ounce" : " fluid ounces");
} else if (gallons < 1/4) {
let volume = round(gallons*16,1);
} else if (gallons < 1 / 4) {
let volume = round(gallons * 16, 1);
return volume + (singular || volume == 1 ? " cup" : " cups");
} else if (gallons < 1/2) {
let volume = round(gallons*8,1);
} else if (gallons < 1 / 2) {
let volume = round(gallons * 8, 1);
return volume + (singular || volume == 1 ? " pint" : " pints");
} else if (gallons < 1) {
let volume = round(gallons*4,1);
let volume = round(gallons * 4, 1);
return volume + (singular || volume == 1 ? " quart" : " quarts");
} else if (gallons < 100) {
let volume = round(gallons,1);
let volume = round(gallons, 1);
return volume + (singular || volume == 1 ? " gallon" : " gallons");
} else {
let volume = round(gallons,0);
let volume = round(gallons, 0);
return volume + (singular || volume == 1 ? " gallon" : " gallons");
}
}

function customarySymVolume(m3, singular=false) {
function customarySymVolume(m3, singular = false) {
let gallons = m3 * 264.172;
if (gallons < 1/16) {
let volume = round(gallons*128,0);
if (gallons < 1 / 16) {
let volume = round(gallons * 128, 0);
return volume + " fl oz";
} else if (gallons < 1/4) {
let volume = round(gallons*16,1);
} else if (gallons < 1 / 4) {
let volume = round(gallons * 16, 1);
return volume + (singular || volume == 1 ? " cp" : " cps");
} else if (gallons < 1/2) {
let volume = round(gallons*8,1);
} else if (gallons < 1 / 2) {
let volume = round(gallons * 8, 1);
return volume + " pt";
} else if (gallons < 1) {
let volume = round(gallons*4,1);
let volume = round(gallons * 4, 1);
return volume + " qt";
} else if (gallons < 100) {
let volume = round(gallons,1);
let volume = round(gallons, 1);
return volume + " g";
} else {
let volume = round(gallons,0);
let volume = round(gallons, 0);
return volume + " g";
}
}

function approxVolume(m3, singular=false) {
if (m3 < 2/10000) {
let volume = round(m3*4e5,0);
function approxVolume(m3, singular = false) {
if (m3 < 2 / 10000) {
let volume = round(m3 * 4e5, 0);
return volume + (singular || volume == 1 ? " shot" : " shots");
} else if (m3 < .1) {
let volume = round(m3*2254,1);
let volume = round(m3 * 2254, 1);
return volume + (singular || volume == 1 ? " glass" : " glasses");
} else if (m3 < 100) {
let volume = round(m3*2.64,1);
let volume = round(m3 * 2.64, 1);
return volume + (singular || volume == 1 ? " bathtub" : " bathtubs");
} else if (m3 < 1e5) {
let volume = round(m3/1000,2);
return volume + (singular || volume == 1 ? " Olympic swimming pool" : " Olympic swimming pools");
let volume = round(m3 / 1000, 2);
return volume + (singular || volume == 1 ? " Olympic swimming pool" : " Olympic swimming pools");
} else if (m3 < 1e9) {
let volume = round(m3/3.2e5,2);
let volume = round(m3 / 3.2e5, 2);
return volume + (singular || volume == 1 ? " oil tanker" : " oil tankers");
} else if (m3 < 1e15) {
let volume = round(m3/1.8919e10,3);
let volume = round(m3 / 1.8919e10, 3);
return volume + (singular || volume == 1 ? " Great Salt Lake" : " Great Salt Lakes");
} else if (m3 < 1e20){
let volume = round(m3/3.547e17, 3);
return volume + (singular || volume == 1 ? " ocean" : " oceans");
} else if (m3 < 1e25){
let volume = round(m3/1e21, 3);
} else if (m3 < 1e20) {
let volume = round(m3 / 3.547e17, 3);
return volume + (singular || volume == 1 ? " ocean" : " oceans");
} else if (m3 < 1e25) {
let volume = round(m3 / 1e21, 3);
return volume + (singular || volume == 1 ? " Earth" : " Earths");
} else {
let volume = round(m3/1.4e27, 3);
return volume + (singular || volume == 1 ? " Sun" : " Suns");
let volume = round(m3 / 1.4e27, 3);
return volume + (singular || volume == 1 ? " Sun" : " Suns");
}
}


function makeSphere(input=0, diameter=false) {
function makeSphere(input = 0, diameter = false) {
if (diameter = true) {
input = input/2;
input = input / 2;
}
return (4/3)*Math.PI*(Math.pow(input, 3));
return (4 / 3) * Math.PI * (Math.pow(input, 3));
}

function breakSphere(input=0, diameter=false) {
let output = math.pow((3*input)/(4*Math.PI), 1/3)
if (diameter=true) {
output = output*2;
function breakSphere(input = 0, diameter = false) {
let output = math.pow((3 * input) / (4 * Math.PI), 1 / 3)
if (diameter = true) {
output = output * 2;
}
return output;
}

Loading…
取消
儲存