Skip to content

Commit 64e8a1a

Browse files
committed
Adding names
1 parent e50de28 commit 64e8a1a

File tree

3 files changed

+70
-271
lines changed

3 files changed

+70
-271
lines changed

index.html

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
<head>
44
<meta charset="UTF-8" />
55
<title>MBTI</title>
6+
<meta
7+
name="description"
8+
content="Know your MBTI (Myers-Briggs Type Indicator) personality types."
9+
/>
610
<link rel="stylesheet" href="style.css" />
711
</head>
812
<body>

script.js

+20-7
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ const mbtiTypes = {
8383
},
8484
};
8585

86+
const cognFuncsStackNames = [
87+
"Dominant",
88+
"Auxiliary",
89+
"Tertiary",
90+
"Inferior",
91+
"Opposing",
92+
"Critical Parent",
93+
"Trickster",
94+
"Demon",
95+
];
96+
8697
const cognFuncs = {
8798
Si: {
8899
name: "Introverted Sensing",
@@ -271,23 +282,19 @@ function createCognFunctions() {
271282

272283
const $cfSpanWrap = document.createElement("div");
273284
$cfSpanWrap.classList.add("cfspanwrap");
274-
275285
const $span1 = document.createElement("span");
276286
$span1.setAttribute("data-cf-index", i);
277287
$span1.classList.add("cf");
278288
$span1.classList.add("cfa");
279289
$span1.setAttribute("draggable", true);
280290
$cfSpanWrap.appendChild($span1);
281-
282291
const $span2 = document.createElement("span");
283292
$span2.setAttribute("data-cf-index", i + 4);
284293
$span2.classList.add("cf");
285294
$span2.classList.add("cfb");
286295
$span2.setAttribute("draggable", true);
287296
$cfSpanWrap.appendChild($span2);
288-
289297
$cfWrap.appendChild($cfSpanWrap);
290-
291298
$cfsWrapper.appendChild($cfWrap);
292299

293300
const $cfDesc12Wrapper = document.createElement("div");
@@ -394,6 +401,12 @@ function renderInfiniteScroll() {
394401
});
395402
}
396403

404+
function getOrdinal(n) {
405+
const s = ["th", "st", "nd", "rd"];
406+
const v = n % 100;
407+
return n + (s[(v - 20) % 10] || s[v] || s[0]);
408+
}
409+
397410
function changeActiveType(nextType, forced = false) {
398411
let $nextType = getNodeTypeFromString(nextType);
399412
if (!$nextType) {
@@ -474,7 +487,9 @@ function changeActiveType(nextType, forced = false) {
474487
mbtiTypes[nextType].functions.forEach((text, index) => {
475488
$cfsByIndex[index].innerText = text;
476489
$cfsByIndex[index].setAttribute("data-cf", text);
477-
$cfsDescByIndex[index].innerHTML = cognFuncs[text].description;
490+
$cfsDescByIndex[index].innerHTML = `<h3>(${getOrdinal(index + 1)}) ${
491+
cognFuncsStackNames[index]
492+
}</h3><p>${cognFuncs[text].description}</p>`;
478493
});
479494
}
480495

@@ -548,9 +563,7 @@ window.addEventListener("keydown", (e) => {
548563
});
549564

550565
$cfsWrapper.addEventListener("mouseover", (e) => {
551-
console.log("e.target :>> ", e);
552566
const cfIndex = e.target.dataset.cfIndex;
553-
console.log("cfIndex :>> ", cfIndex);
554567
if (cfIndex === undefined) return;
555568
$cfsDescByIndex[cfIndex].classList.add("active");
556569
});

0 commit comments

Comments
 (0)