Compare commits

..

No commits in common. "273b9c4af8bff80fd38f31c800d86c84ed3bb5e0" and "a2bf8c822138b0aee08868e7c78b688969d03573" have entirely different histories.

4 changed files with 34 additions and 29 deletions

View file

@ -29,7 +29,7 @@
"space-infix-ops": "warn", "space-infix-ops": "warn",
"brace-style": "warn", "brace-style": "warn",
"comma-spacing": "warn", "comma-spacing": "warn",
"indent": ["warn", 4, { "SwitchCase": 1 }], "indent": ["warn", { "SwitchCase": 2 }],
"arrow-spacing": "warn" "arrow-spacing": "warn"
} }
} }

View file

@ -31,7 +31,7 @@ const main = () => {
// Callback: called when first name is changed // Callback: called when first name is changed
const updateConst = () => { const updateConst = () => {
const firstname = input.value.trim().toLowerCase(); const firstname = input.value.trim().toLowerCase();
if (firstname.length) { if(firstname.length) {
const data = getConst(firstname); const data = getConst(firstname);
setString(firstname.replace(/^\w/, (c) => c.toUpperCase()), data.infos); setString(firstname.replace(/^\w/, (c) => c.toUpperCase()), data.infos);
@ -61,7 +61,7 @@ const setString = (firstname = String, data = Object) => {
link.href = data[clearText(letter_value)][key]; link.href = data[clearText(letter_value)][key];
link.innerText = key; link.innerText = key;
infos.append(link); infos.append(link);
}); })
// Change parameter of tags // Change parameter of tags
infos.hidden = true; infos.hidden = true;
@ -77,12 +77,17 @@ const setString = (firstname = String, data = Object) => {
letter.addEventListener("mouseenter", (e) => e.target.firstElementChild.hidden = false); letter.addEventListener("mouseenter", (e) => e.target.firstElementChild.hidden = false);
letter.addEventListener("mouseleave", (e) => e.target.firstElementChild.hidden = true); letter.addEventListener("mouseleave", (e) => e.target.firstElementChild.hidden = true);
}); });
}; }
// Get the paragraph of the name
const getString = () => {
return document.getElementsByClassName("firstname-constant-string").item(0);
}
// Get the paragraph of the constant // Get the paragraph of the constant
const getDouble = () => { const getDouble = () => {
return document.getElementsByClassName("firstname-constant-double").item(0); return document.getElementsByClassName("firstname-constant-double").item(0);
}; }
// Set the paragraph of the name to the placeholder // Set the paragraph of the name to the placeholder
const defaultInfos = () => { const defaultInfos = () => {
@ -94,12 +99,12 @@ const defaultInfos = () => {
// Define the constant // Define the constant
getDouble().textContent = data.const; getDouble().textContent = data.const;
}; }
// Remove accent and lower the string // Remove accent and lower the string
const clearText = (string = String) => { const clearText = (string = String) => {
return string.normalize('NFD').replace(/[\u0300-\u036f]/g, "").toLowerCase(); return string.normalize('NFD').replace(/[\u0300-\u036f]/g, "").toLowerCase();
}; }
const getConst = (letters = String) => { const getConst = (letters = String) => {
// Turn letters to an array // Turn letters to an array
@ -117,7 +122,7 @@ const getConst = (letters = String) => {
position++; position++;
switch (letter) { switch (letter) {
case "a": case "a":
const_data.push(1.2824271291006226 ** position); const_data.push(1.28242712910062263687534256886979172 ** position);
const_infos[letter] = { const_infos[letter] = {
"Wikipedia": "https://en.wikipedia.org/wiki/Glaisher%E2%80%93Kinkelin_constant" "Wikipedia": "https://en.wikipedia.org/wiki/Glaisher%E2%80%93Kinkelin_constant"
}; };
@ -135,25 +140,25 @@ const getConst = (letters = String) => {
}; };
break; break;
case "d": case "d":
const_data.push(0.7390851332151606 ** position); const_data.push(0.73908513321516064165 ** position);
const_infos[letter] = { const_infos[letter] = {
"Wikipedia": "https://en.wikipedia.org/wiki/Dottie_number" "Wikipedia": "https://en.wikipedia.org/wiki/Dottie_number"
}; };
break; break;
case "e": case "e":
const_data.push(2.718281828459045 ** position); const_data.push(2.71828182845904523536028747135266250 ** position);
const_infos[letter] = { const_infos[letter] = {
"Wikipedia": "https://en.wikipedia.org/wiki/E_(mathematical_constant)" "Wikipedia": "https://en.wikipedia.org/wiki/E_(mathematical_constant)"
}; };
break; break;
case "f": case "f":
const_data.push(2.807770242028519 ** position); const_data.push(2,80777024202851936522150118655777293 ** position);
const_infos[letter] = { const_infos[letter] = {
"Wikipedia": "https://en.wikipedia.org/wiki/Frans%C3%A9n%E2%80%93Robinson_constant" "Wikipedia": "https://en.wikipedia.org/wiki/Frans%C3%A9n%E2%80%93Robinson_constant"
}; };
break; break;
case "g": case "g":
const_data.push(0.8346268416740731 ** position); const_data.push(0.83462684167407318628142973279904680 ** position);
const_infos[letter] = { const_infos[letter] = {
"Wikipedia": "https://en.wikipedia.org/wiki/Gauss%27s_constant" "Wikipedia": "https://en.wikipedia.org/wiki/Gauss%27s_constant"
}; };
@ -165,7 +170,7 @@ const getConst = (letters = String) => {
}; };
break; break;
case "i": case "i":
const_data.push(0.20787957635076190 ** position); const_data.push(0.20787957635076190854695561983497877 ** position);
const_infos[letter] = { const_infos[letter] = {
"oeis": "https://oeis.org/A049006" "oeis": "https://oeis.org/A049006"
}; };
@ -183,13 +188,13 @@ const getConst = (letters = String) => {
}; };
break; break;
case "l": case "l":
const_data.push(0.97027011439203392 ** position); const_data.push(0.97027011439203392574 ** position);
const_infos[letter] = { const_infos[letter] = {
"Wikipedia": "https://en.wikipedia.org/wiki/Lochs%27s_theorem" "Wikipedia": "https://en.wikipedia.org/wiki/Lochs%27s_theorem"
}; };
break; break;
case "m": case "m":
const_data.push(0.2614972128476427 ** position); const_data.push(0.26149721284764278375542683860869585 ** position);
const_infos[letter] = { const_infos[letter] = {
"Wikipedia": "https://en.wikipedia.org/wiki/Meissel%E2%80%93Mertens_constant" "Wikipedia": "https://en.wikipedia.org/wiki/Meissel%E2%80%93Mertens_constant"
}; };
@ -201,13 +206,13 @@ const getConst = (letters = String) => {
}; };
break; break;
case "o": case "o":
const_data.push(1.66168794963359412 ** position); const_data.push(1.66168794963359412129581892274995074 ** position);
const_infos[letter] = { const_infos[letter] = {
"Wikipedia": "https://en.wikipedia.org/wiki/Somos%27_quadratic_recurrence_constant" "Wikipedia": "https://en.wikipedia.org/wiki/Somos%27_quadratic_recurrence_constant"
}; };
break; break;
case "p": case "p":
const_data.push(2.295587149392638 ** position); const_data.push(2.29558714939263807403429804918949038 ** position);
const_infos[letter] = { const_infos[letter] = {
"Wikipedia": "https://en.wikipedia.org/wiki/Universal_parabolic_constant" "Wikipedia": "https://en.wikipedia.org/wiki/Universal_parabolic_constant"
}; };
@ -219,37 +224,37 @@ const getConst = (letters = String) => {
}; };
break; break;
case "r": case "r":
const_data.push(2625374126407687e2 ** position); const_data.push(262537412640768743.999999999999250073 ** position);
const_infos[letter] = { const_infos[letter] = {
"Wikipedia": "https://en.wikipedia.org/wiki/Heegner_number#Almost_integers_and_Ramanujan.27s_constant" "Wikipedia": "https://en.wikipedia.org/wiki/Heegner_number#Almost_integers_and_Ramanujan.27s_constant"
}; };
break; break;
case "s": case "s":
const_data.push(0.1878596424620671 ** position); const_data.push(0.18785964246206712024851793405427323 ** position);
const_infos[letter] = { const_infos[letter] = {
"Wikipedia": "https://en.wikipedia.org/wiki/MRB_constant" "Wikipedia": "https://en.wikipedia.org/wiki/MRB_constant"
}; };
break; break;
case "t": case "t":
const_data.push(1.927561975482925 ** 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" "Wikipedia": "https://en.wikipedia.org/wiki/Generalizations_of_Fibonacci_numbers#Tetranacci_numbers"
}; };
break; break;
case "u": case "u":
const_data.push(1.8477590650225735 ** position); const_data.push(1.84775906502257351225 ** position);
const_infos[letter] = { const_infos[letter] = {
"Wikipedia": "https://en.wikipedia.org/wiki/Self-avoiding_walk" "Wikipedia": "https://en.wikipedia.org/wiki/Self-avoiding_walk"
}; };
break; break;
case "v": case "v":
const_data.push(0.4221577331158266 ** position); const_data.push(0.42215773311582662702 ** position);
const_infos[letter] = { const_infos[letter] = {
"Wikipedia": "https://en.wikipedia.org/wiki/Reuleaux_tetrahedron" "Wikipedia": "https://en.wikipedia.org/wiki/Reuleaux_tetrahedron"
}; };
break; break;
case "w": case "w":
const_data.push(2.0945514815423265 ** position); const_data.push(2.09455148154232659148 ** position);
const_infos[letter] = { const_infos[letter] = {
"OEIS": "https://oeis.org/A007493" "OEIS": "https://oeis.org/A007493"
}; };
@ -261,7 +266,7 @@ const getConst = (letters = String) => {
}; };
break; break;
case "y": case "y":
const_data.push(0.5772156649015328 ** 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"
}; };
@ -275,7 +280,7 @@ const getConst = (letters = String) => {
default: // By default, equals to 1 default: // By default, equals to 1
const_data.push(1); const_data.push(1);
} };
}); });
return { return {

View file

@ -1,4 +1,4 @@
const fs = require('fs'); fs = require('fs');
// Retrieve the FAQ file // Retrieve the FAQ file
const get = () => { const get = () => {
@ -11,7 +11,7 @@ const get = () => {
ok(data); ok(data);
}); });
}); });
}; }
module.exports = { module.exports = {
get get

View file

@ -20,7 +20,7 @@ const randomFirstname = () => {
"James", "James",
"John", "John",
"Lucas" "Lucas"
]; ]
return firstnames[Math.floor(Math.random() * firstnames.length)]; return firstnames[Math.floor(Math.random() * firstnames.length)];
}; };