Compare commits

..

No commits in common. "471d511fde7f09ecf75e5cb499603c7c74a2257a" and "9a4720e88763aeadf149858585b41f8b4e811574" have entirely different histories.

4 changed files with 62 additions and 94 deletions

View file

@ -2,14 +2,3 @@
width: 50% !important;
text-align: center;
}
.firstname-constant {
height: 15em;
min-height: 15em;
max-height: 15em;
}
.firstname-constant p {
text-align: center;
font-size: 10em;
}

View file

@ -1,51 +1,26 @@
window.addEventListener("load", () => main());
// Get input area
const input = document.getElementById("firstname");
const input_name = "firstname";
const main = () => {
// Reset content of the input
input.value = "";
// Create the paragraph of the firstname
let paragraph_firstname = document.createElement("p");
paragraph_firstname.className = "firstname-constant-paragraph";
document.getElementsByClassName("firstname-constant").item(0).append(paragraph_firstname);
defaultFirstname()
// Create the paragraph of the constant
document.getElementById(input_name).value = "";
// Call callback when editing the input
input.addEventListener("input", updateConst);
document.getElementById(input_name).addEventListener("input", update_const);
};
// Callback: called when firstname is changed
const updateConst = () => {
const firstname = input.value.trim().toLowerCase();
const update_const = () => {
const firstname = document.getElementById(input_name).value;
if(firstname.length) {
const data = getConst(firstname.split(""));
getParagraph().textContent = firstname.replace(/^\w/, (c) => c.toUpperCase());
const data = get_const(firstname.toLowerCase().split(""));
console.log(`output: ${data.const} - ${JSON.stringify(data.infos)}`);
} else {
defaultFirstname();
}
};
// Get the paragraph of the name
const getParagraph = () => {
return document.getElementsByClassName("firstname-constant").item(0)
.getElementsByClassName("firstname-constant-paragraph").item(0);
}
// Set the paragraph of the name to the placeholder
const defaultFirstname = () => {
getParagraph().textContent = input.placeholder;
}
const getConst = (letters = Array) => {
const get_const = (letters = Array) => {
console.log(`input: ${letters}`);
// Store constants of each letters of the firstname
@ -72,9 +47,9 @@ const getConst = (letters = Array) => {
};
break;
case "c":
const_data.push(299792458 ** position);
const_data.push(1.46707807943397547289 ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/Speed_of_light"
"wikipedia": "https://en.wikipedia.org/wiki/Porter%27s_constant"
};
break;
case "d":
@ -101,33 +76,36 @@ const getConst = (letters = Array) => {
"wikipedia": "https://en.wikipedia.org/wiki/Gauss%27s_constant"
};
break;
case "h":
const_data.push(6.62607015e-34 ** position);
/* case "h":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/Planck_constant"
"wikipedia": ""
};
break;
case "i":
const_data.push(0.20787957635076190854695561983497877 ** position);
const_infos[letter] = {
"wikipedia": ""
};
break; */
/* case "i":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": ""
};
break; */
/* case "j":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": ""
};
break; */
case "k":
const_data.push(1.75793275661800453270881963821813852 ** position);
const_infos[letter] = {
"oeis": {
"link": "https://oeis.org/A049006",
"name": "Decimal expansion of i^i"
"link": "https://oeis.org/A072449",
"name": "Kasner number"
}
};
break;
case "j":
const_data.push(5.5208e27 ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/J/psi_meson"
};
break;
case "k":
const_data.push((-273.15) ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/Kelvin"
};
break;
case "l":
const_data.push(0.97027011439203392574 ** position);
const_infos[letter] = {
@ -140,18 +118,18 @@ const getConst = (letters = Array) => {
"wikipedia": "https://en.wikipedia.org/wiki/Meissel%E2%80%93Mertens_constant"
};
break;
case "n":
const_data.push(6.02214076e+23 ** position);
/* case "n":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/Avogadro_constant"
"wikipedia": ""
};
break;
case "o":
const_data.push(1.66168794963359412129581892274995074 ** position);
break; */
/* case "o":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/Somos%27_quadratic_recurrence_constant"
"wikipedia": ""
};
break;
break; */
case "p":
const_data.push(2.29558714939263807403429804918949038 ** position);
const_infos[letter] = {
@ -159,17 +137,20 @@ const getConst = (letters = Array) => {
};
break;
case "q":
const_data.push(1.8755459e-18 ** position);
const_data.push(0.28878809508660242127889972192923078 ** position); // فلاجوليت وريتشموند
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/Planck_units#History_and_definition"
"oeis": {
"link": "https://oeis.org/A048651",
"name": "Flajolet and Richmond"
}
};
break;
case "r":
const_data.push(262537412640768743.999999999999250073 ** position);
/* case "r":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/Heegner_number#Almost_integers_and_Ramanujan.27s_constant"
"wikipedia": ""
};
break;
break; */
case "s":
const_data.push(0.18785964246206712024851793405427323 ** position);
const_infos[letter] = {
@ -179,7 +160,10 @@ const getConst = (letters = Array) => {
case "t":
const_data.push(1.92756197548292530426 ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/Generalizations_of_Fibonacci_numbers#Tetranacci_numbers"
"oeis": {
"link": "https://oeis.org/A086088",
"name": "Decimal expansion of the limit of the ratio of consecutive terms in the tetranacci sequence"
}
};
break;
case "u":
@ -204,24 +188,24 @@ const getConst = (letters = Array) => {
}
};
break;
case "x":
const_data.push(1.0021e-13 ** position);
/* case "x":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/X_unit"
"wikipedia": ""
};
break;
break; */
case "y":
const_data.push(0.57721566490153286060651209008240243 ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/Euler%27s_constant"
};
break;
case "z":
const_data.push(376.730313668 ** position);
/* case "z":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/Impedance_of_free_space"
"wikipedia": ""
};
break;
break; */
default: // By default, equals to 1
const_data.push(1);

View file

@ -19,10 +19,7 @@ async function get() {
// eslint-disable-next-line no-undef
data = Buffer.from(json.content, json.encoding).toString('utf8');
timestamp = now;
}))
.catch(() => {
data = "# Constnium";
});
}));
}
return data;

View file

@ -29,8 +29,6 @@
<input id="firstname" class="form-control form-control-lg mx-auto d-block" type="text" placeholder="<%- firstname_placeholder %>" autofocus>
<div class="firstname-constant"></div>
<hr>
<figure class="text-center">
<%- readme %>