Compare commits
No commits in common. "471d511fde7f09ecf75e5cb499603c7c74a2257a" and "9a4720e88763aeadf149858585b41f8b4e811574" have entirely different histories.
471d511fde
...
9a4720e887
4 changed files with 62 additions and 94 deletions
|
@ -2,14 +2,3 @@
|
||||||
width: 50% !important;
|
width: 50% !important;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.firstname-constant {
|
|
||||||
height: 15em;
|
|
||||||
min-height: 15em;
|
|
||||||
max-height: 15em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.firstname-constant p {
|
|
||||||
text-align: center;
|
|
||||||
font-size: 10em;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,51 +1,26 @@
|
||||||
window.addEventListener("load", () => main());
|
window.addEventListener("load", () => main());
|
||||||
|
|
||||||
// Get input area
|
const input_name = "firstname";
|
||||||
const input = document.getElementById("firstname");
|
|
||||||
|
|
||||||
const main = () => {
|
const main = () => {
|
||||||
|
|
||||||
// Reset content of the input
|
// Reset content of the input
|
||||||
input.value = "";
|
document.getElementById(input_name).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
|
|
||||||
|
|
||||||
// Call callback when editing the input
|
// Call callback when editing the input
|
||||||
input.addEventListener("input", updateConst);
|
document.getElementById(input_name).addEventListener("input", update_const);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Callback: called when firstname is changed
|
// Callback: called when firstname is changed
|
||||||
const updateConst = () => {
|
const update_const = () => {
|
||||||
const firstname = input.value.trim().toLowerCase();
|
const firstname = document.getElementById(input_name).value;
|
||||||
if(firstname.length) {
|
if(firstname.length) {
|
||||||
const data = getConst(firstname.split(""));
|
const data = get_const(firstname.toLowerCase().split(""));
|
||||||
|
|
||||||
getParagraph().textContent = firstname.replace(/^\w/, (c) => c.toUpperCase());
|
|
||||||
|
|
||||||
console.log(`output: ${data.const} - ${JSON.stringify(data.infos)}`);
|
console.log(`output: ${data.const} - ${JSON.stringify(data.infos)}`);
|
||||||
} else {
|
|
||||||
defaultFirstname();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get the paragraph of the name
|
const get_const = (letters = Array) => {
|
||||||
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) => {
|
|
||||||
console.log(`input: ${letters}`);
|
console.log(`input: ${letters}`);
|
||||||
|
|
||||||
// Store constants of each letters of the firstname
|
// Store constants of each letters of the firstname
|
||||||
|
@ -72,9 +47,9 @@ const getConst = (letters = Array) => {
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case "c":
|
case "c":
|
||||||
const_data.push(299792458 ** position);
|
const_data.push(1.46707807943397547289 ** position);
|
||||||
const_infos[letter] = {
|
const_infos[letter] = {
|
||||||
"wikipedia": "https://en.wikipedia.org/wiki/Speed_of_light"
|
"wikipedia": "https://en.wikipedia.org/wiki/Porter%27s_constant"
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case "d":
|
case "d":
|
||||||
|
@ -101,33 +76,36 @@ const getConst = (letters = Array) => {
|
||||||
"wikipedia": "https://en.wikipedia.org/wiki/Gauss%27s_constant"
|
"wikipedia": "https://en.wikipedia.org/wiki/Gauss%27s_constant"
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case "h":
|
/* case "h":
|
||||||
const_data.push(6.62607015e-34 ** position);
|
const_data.push(x ** position);
|
||||||
const_infos[letter] = {
|
const_infos[letter] = {
|
||||||
"wikipedia": "https://en.wikipedia.org/wiki/Planck_constant"
|
"wikipedia": ""
|
||||||
};
|
};
|
||||||
break;
|
const_infos[letter] = {
|
||||||
case "i":
|
"wikipedia": ""
|
||||||
const_data.push(0.20787957635076190854695561983497877 ** position);
|
};
|
||||||
|
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] = {
|
const_infos[letter] = {
|
||||||
"oeis": {
|
"oeis": {
|
||||||
"link": "https://oeis.org/A049006",
|
"link": "https://oeis.org/A072449",
|
||||||
"name": "Decimal expansion of i^i"
|
"name": "Kasner number"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
break;
|
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":
|
case "l":
|
||||||
const_data.push(0.97027011439203392574 ** position);
|
const_data.push(0.97027011439203392574 ** position);
|
||||||
const_infos[letter] = {
|
const_infos[letter] = {
|
||||||
|
@ -140,18 +118,18 @@ const getConst = (letters = Array) => {
|
||||||
"wikipedia": "https://en.wikipedia.org/wiki/Meissel%E2%80%93Mertens_constant"
|
"wikipedia": "https://en.wikipedia.org/wiki/Meissel%E2%80%93Mertens_constant"
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case "n":
|
/* case "n":
|
||||||
const_data.push(6.02214076e+23 ** position);
|
const_data.push(x ** position);
|
||||||
const_infos[letter] = {
|
const_infos[letter] = {
|
||||||
"wikipedia": "https://en.wikipedia.org/wiki/Avogadro_constant"
|
"wikipedia": ""
|
||||||
};
|
};
|
||||||
break;
|
break; */
|
||||||
case "o":
|
/* case "o":
|
||||||
const_data.push(1.66168794963359412129581892274995074 ** position);
|
const_data.push(x ** position);
|
||||||
const_infos[letter] = {
|
const_infos[letter] = {
|
||||||
"wikipedia": "https://en.wikipedia.org/wiki/Somos%27_quadratic_recurrence_constant"
|
"wikipedia": ""
|
||||||
};
|
};
|
||||||
break;
|
break; */
|
||||||
case "p":
|
case "p":
|
||||||
const_data.push(2.29558714939263807403429804918949038 ** position);
|
const_data.push(2.29558714939263807403429804918949038 ** position);
|
||||||
const_infos[letter] = {
|
const_infos[letter] = {
|
||||||
|
@ -159,17 +137,20 @@ const getConst = (letters = Array) => {
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case "q":
|
case "q":
|
||||||
const_data.push(1.8755459e-18 ** position);
|
const_data.push(0.28878809508660242127889972192923078 ** position); // فلاجوليت وريتشموند
|
||||||
const_infos[letter] = {
|
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;
|
break;
|
||||||
case "r":
|
/* case "r":
|
||||||
const_data.push(262537412640768743.999999999999250073 ** position);
|
const_data.push(x ** position);
|
||||||
const_infos[letter] = {
|
const_infos[letter] = {
|
||||||
"wikipedia": "https://en.wikipedia.org/wiki/Heegner_number#Almost_integers_and_Ramanujan.27s_constant"
|
"wikipedia": ""
|
||||||
};
|
};
|
||||||
break;
|
break; */
|
||||||
case "s":
|
case "s":
|
||||||
const_data.push(0.18785964246206712024851793405427323 ** position);
|
const_data.push(0.18785964246206712024851793405427323 ** position);
|
||||||
const_infos[letter] = {
|
const_infos[letter] = {
|
||||||
|
@ -179,7 +160,10 @@ const getConst = (letters = Array) => {
|
||||||
case "t":
|
case "t":
|
||||||
const_data.push(1.92756197548292530426 ** position);
|
const_data.push(1.92756197548292530426 ** position);
|
||||||
const_infos[letter] = {
|
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;
|
break;
|
||||||
case "u":
|
case "u":
|
||||||
|
@ -204,24 +188,24 @@ const getConst = (letters = Array) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case "x":
|
/* case "x":
|
||||||
const_data.push(1.0021e-13 ** position);
|
const_data.push(x ** position);
|
||||||
const_infos[letter] = {
|
const_infos[letter] = {
|
||||||
"wikipedia": "https://en.wikipedia.org/wiki/X_unit"
|
"wikipedia": ""
|
||||||
};
|
};
|
||||||
break;
|
break; */
|
||||||
case "y":
|
case "y":
|
||||||
const_data.push(0.57721566490153286060651209008240243 ** position);
|
const_data.push(0.57721566490153286060651209008240243 ** position);
|
||||||
const_infos[letter] = {
|
const_infos[letter] = {
|
||||||
"wikipedia": "https://en.wikipedia.org/wiki/Euler%27s_constant"
|
"wikipedia": "https://en.wikipedia.org/wiki/Euler%27s_constant"
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case "z":
|
/* case "z":
|
||||||
const_data.push(376.730313668 ** position);
|
const_data.push(x ** position);
|
||||||
const_infos[letter] = {
|
const_infos[letter] = {
|
||||||
"wikipedia": "https://en.wikipedia.org/wiki/Impedance_of_free_space"
|
"wikipedia": ""
|
||||||
};
|
};
|
||||||
break;
|
break; */
|
||||||
|
|
||||||
default: // By default, equals to 1
|
default: // By default, equals to 1
|
||||||
const_data.push(1);
|
const_data.push(1);
|
||||||
|
|
|
@ -19,10 +19,7 @@ async function get() {
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
data = Buffer.from(json.content, json.encoding).toString('utf8');
|
data = Buffer.from(json.content, json.encoding).toString('utf8');
|
||||||
timestamp = now;
|
timestamp = now;
|
||||||
}))
|
}));
|
||||||
.catch(() => {
|
|
||||||
data = "# Constnium";
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
|
@ -29,8 +29,6 @@
|
||||||
|
|
||||||
<input id="firstname" class="form-control form-control-lg mx-auto d-block" type="text" placeholder="<%- firstname_placeholder %>" autofocus>
|
<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>
|
<hr>
|
||||||
<figure class="text-center">
|
<figure class="text-center">
|
||||||
<%- readme %>
|
<%- readme %>
|
||||||
|
|
Loading…
Reference in a new issue