-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
631 lines (552 loc) · 21.4 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
// MBTI theory
const mbtiTypes = {
ISTJ: {
functions: ["Si", "Te", "Fi", "Ne", "Se", "Ti", "Fe", "Ni"],
description:
"Responsible and detail-oriented individuals who are dependable and thorough in their work. ISTJs value order and structure, often excelling in tasks that require precision and organization. They are practical, reliable, and loyal.",
},
ISFJ: {
functions: ["Si", "Fe", "Ti", "Ne", "Se", "Fi", "Te", "Ni"],
description:
"Compassionate and nurturing individuals who are deeply attuned to the needs of others. ISFJs are often selfless and enjoy creating harmony in their surroundings. They are loyal, responsible, and dependable friends and family members.",
},
INFJ: {
functions: ["Ni", "Fe", "Ti", "Se", "Ne", "Fi", "Te", "Si"],
description:
"Visionary and insightful individuals who are driven by their ideals and a desire to make a positive impact on the world. INFJs are often empathetic and intuitive, understanding the emotions and motivations of those around them. They are insightful, caring, and creative.",
},
INTJ: {
functions: ["Ni", "Te", "Fi", "Se", "Ne", "Ti", "Fe", "Si"],
description:
"Strategic and forward-thinking individuals who enjoy conceptualizing and planning for the future. INTJs are often logical and analytical, seeking efficient and effective solutions to complex problems. They are independent, visionary, and goal-oriented.",
},
ISTP: {
functions: ["Ti", "Se", "Ni", "Fe", "Te", "Si", "Ne", "Fi"],
description:
"Diligent workers who genuinely enjoy becoming experts at a craft or career. They tend to be calm and levelheaded in a crisis, quickly determining what needs to be done and effectively solving the problem. ISTPs are generally logical, kind, and tolerant.",
},
ISFP: {
functions: ["Fi", "Se", "Ni", "Te", "Fe", "Si", "Ne", "Ti"],
description:
"Artistic and sensitive individuals who appreciate beauty and harmony. ISFPs are often reserved and quiet, enjoying the present moment and focusing on their personal values. They are compassionate, adaptable, and enjoy expressing themselves through creative outlets.",
},
INFP: {
functions: ["Fi", "Ne", "Si", "Te", "Fe", "Ni", "Se", "Ti"],
description:
"Idealistic and creative individuals who are driven by their values and a desire to make a positive impact on the world. INFPs are often deep thinkers and feelers, valuing authenticity and authenticity in themselves and others. They are empathetic, supportive, and open-minded.",
},
INTP: {
functions: ["Ti", "Ne", "Si", "Fe", "Te", "Ni", "Se", "Fi"],
description:
"Inquisitive and analytical individuals who enjoy exploring ideas and theories. INTPs are often logical and objective, seeking to understand the underlying principles of the world. They are innovative, independent, and enjoy problem-solving.",
},
ESTP: {
functions: ["Se", "Ti", "Fe", "Ni", "Si", "Te", "Fi", "Ne"],
description:
"Energetic and action-oriented individuals who enjoy living in the moment. ESTPs are often adaptable and resourceful, thriving in dynamic and fast-paced environments. They are pragmatic, sociable, and enjoy taking risks.",
},
ESFP: {
functions: ["Se", "Fi", "Te", "Ni", "Si", "Fe", "Ti", "Ne"],
description:
"Enthusiastic and spontaneous individuals who enjoy bringing joy and excitement to those around them. ESFPs are often outgoing and social, valuing experiences and relationships. They are expressive, playful, and live in the present moment.",
},
ENFP: {
functions: ["Ne", "Fi", "Te", "Si", "Ni", "Fe", "Ti", "Se"],
description:
"Creative and imaginative individuals who are driven by their passions and a desire for personal growth. ENFPs are often enthusiastic and supportive, valuing authenticity and exploration. They are adaptable, optimistic, and enjoy connecting with others.",
},
ENTP: {
functions: ["Ne", "Ti", "Fe", "Si", "Ni", "Te", "Fi", "Se"],
description:
"Inventive and curious individuals who enjoy exploring possibilities and challenging the status quo. ENTPs are often quick-witted and analytical, thriving in intellectually stimulating environments. They are innovative, independent, and enjoy debating ideas.",
},
ESTJ: {
functions: ["Te", "Si", "Ne", "Fi", "Ti", "Se", "Ni", "Fe"],
description:
"Efficient and organized individuals who enjoy structure and order. ESTJs are often practical and reliable, excelling in tasks that require planning and implementation. They are responsible, decisive, and value tradition.",
},
ESFJ: {
functions: ["Fe", "Si", "Ne", "Ti", "Fi", "Se", "Ni", "Te"],
description:
"Sociable and caring individuals who thrive in supportive and harmonious environments. ESFJs are often empathetic and nurturing, prioritizing the well-being of others. They are responsible, loyal, and enjoy building strong connections with people.",
},
ENFJ: {
functions: ["Fe", "Ni", "Se", "Ti", "Fi", "Ne", "Si", "Te"],
description:
"Charismatic and compassionate individuals who are driven by a vision for a better future. ENFJs are often insightful and supportive, inspiring others to achieve their potential. They are empathetic, strategic, and enjoy making a positive impact on their communities.",
},
ENTJ: {
functions: ["Te", "Ni", "Se", "Fi", "Ti", "Ne", "Si", "Fe"],
description:
"Strategic and decisive individuals who enjoy leading and organizing others. ENTJs are often ambitious and goal-oriented, seeking to implement their vision for success. They are efficient, confident, and value competence in themselves and others.",
},
};
const cognFuncsStackNames = [
"Dominant",
"Auxiliary",
"Tertiary",
"Inferior",
"Opposing",
"Critical Parent",
"Trickster",
"Demon",
];
const cognFuncs = {
Si: {
name: "Introverted Sensing",
description:
"<b>Introverted Sensing (Si)</b> is the cognitive function that is oriented to the past. It is focused on internal sensations and reliving past experiences. Si is often associated with memory, tradition, and routine.",
},
Se: {
name: "Extraverted Sensing",
description:
"<b>Extraverted Sensing (Se)</b> is the cognitive function that is oriented to the present. It is focused on external sensations and taking in the world as it is. Se is often associated with spontaneity, action, and adaptability.",
},
Ni: {
name: "Introverted Intuition",
description:
"<b>Introverted Intuition (Ni)</b> is the cognitive function that is oriented to the future. It is focused on internal insights and conceptualizing the world as it could be. Ni is often associated with vision, imagination, and creativity.",
},
Ne: {
name: "Extraverted Intuition",
description:
"<b>Extraverted Intuition (Ne)</b> is the cognitive function that is oriented to the future. It is focused on external insights and conceptualizing the world as it could be. Ne is often associated with innovation, exploration, and possibility.",
},
Ti: {
name: "Introverted Thinking",
description:
"<b>Introverted Thinking (Ti)</b> is the cognitive function that is oriented to the past. It is focused on internal logic and understanding how things work. Ti is often associated with analysis, objectivity, and precision.",
},
Te: {
name: "Extraverted Thinking",
description:
"<b>Extraverted Thinking (Te)</b> is the cognitive function that is oriented to the present. It is focused on external logic and understanding how things work. Te is often associated with organization, efficiency, and leadership.",
},
Fi: {
name: "Introverted Feeling",
description:
"<b>Introverted Feeling (Fi)</b> is the cognitive function that is oriented to the past. It is focused on internal values and understanding what is important. Fi is often associated with authenticity, empathy, and personal growth.",
},
Fe: {
name: "Extraverted Feeling",
description:
"<b>Extraverted Feeling (Fe)</b> is the cognitive function that is oriented to the present. It is focused on external values and understanding what is important. Fe is often associated with harmony, compassion, and social norms.",
},
};
const mbtiOppositeCf = {
T: "F",
F: "T",
S: "N",
N: "S",
};
const mbtiOppositeExtraversion = {
e: "i",
i: "e",
};
const mbtiOppositeJP = {
J: "P",
P: "J",
};
// DOM nodes
const $typesWrapper = document.querySelector("#types");
const $typesDescWrapper = document.querySelector("#typesdesc");
const $cfsWrapper = document.querySelector("#cfs");
const $cfDescWrapper = document.querySelector("#cfdesc");
const $cfsByIndex = new Array(8).fill(null);
const $cfsDescByIndex = new Array(8).fill(null);
// Constants
const SCROLL_DURATION = 800;
const INITIAL_TYPE = (() => {
const locationHash = location.hash.toUpperCase().replace("#", "");
if (locationHash.length === 4 && locationHash in mbtiTypes) {
return locationHash;
}
return "ENFP";
})();
function calculateTypeFromStack(primary, secondary) {
const [pFn, pExt] = primary.split("");
const [sFn, sExt] = secondary.split("");
const judgFn = getJP(pFn) === "J" ? pFn : getJP(sFn) === "J" ? sFn : null;
const percFn = getJP(pFn) === "P" ? pFn : getJP(sFn) === "P" ? sFn : null;
if (!judgFn || !percFn) {
console.warn("No judgFn or percFn", arguments);
return null;
}
const jp =
(pExt === "e" && getJP(pFn) === "J") || (sExt === "e" && getJP(sFn) === "J")
? "J"
: (pExt === "e" && getJP(pFn) === "P") ||
(sExt === "e" && getJP(sFn) === "P")
? "P"
: null;
if (!jp) {
console.warn("No JP defined", arguments);
return null;
}
const type = [pExt, percFn, judgFn, jp].join("").toUpperCase();
if (!mbtiTypes[type]) {
console.warn(`Type ${type} does not exist`, arguments);
return null;
}
return type;
}
function getJP(cf) {
return ["T", "F"].includes(cf.substr(0, 1))
? "J"
: ["S", "N"].includes(cf.substr(0, 1))
? "P"
: null;
}
function getExtraversion(cf) {
return cf.substr(1, 1);
}
function calculateNewTypeAfterSwap(inCf, dropIndex) {
const inExt = getExtraversion(inCf);
const inOppExt = mbtiOppositeExtraversion[inExt];
const inCfBase = inCf.substr(0, 1);
const inJP = getJP(inCf);
const inOppJP = mbtiOppositeJP[inJP];
const inOppCf = mbtiOppositeCf[inCf.substr(0, 1)];
// If we are assignining after the main stack, just inverted the cf extraversion
if (dropIndex >= 4) {
return calculateNewTypeAfterSwap(`${inCfBase}${inOppExt}`, dropIndex - 4);
}
const currentType = $cfsByIndex
.slice(0, 4)
.map((e) => e.dataset.cf.substr(0, 1));
const newBuildType = [null, null, null, null];
// Remove incomingFn from currentType
currentType.splice(
currentType.findIndex((fn) => fn.substr(0, 1) === inCf.substr(0, 1)),
1
);
if (dropIndex === 0) {
newBuildType[0] = inCf;
newBuildType[1] =
currentType.find((fn) => getJP(fn) === inOppJP) + inOppExt;
// newBuildType[2] = mbtiOppositeCf[newBuildType[1].substr(0, 1)] + inExt;
// newBuildType[3] = inOppCf + inOppExt;
} else if (dropIndex === 1) {
newBuildType[0] =
currentType.find((fn) => getJP(fn) === inOppJP) + inOppExt;
newBuildType[1] = inCf;
// newBuildType[2] = inOppCf + inOppExt;
// newBuildType[3] = mbtiOppositeCf[newBuildType[0].substr(0, 1)] + inExt;
} else if (dropIndex === 2) {
newBuildType[0] = currentType.find((fn) => getJP(fn) === inOppJP) + inExt;
newBuildType[1] = inOppCf + inOppExt;
// newBuildType[2] = inCf;
// newBuildType[3] = mbtiOppositeCf[newBuildType[0].substr(0, 1)] + inOppExt;
} else if (dropIndex === 3) {
newBuildType[0] = inOppCf + inOppExt;
newBuildType[1] = currentType.find((fn) => getJP(fn) === inOppJP) + inExt;
// newBuildType[2] = mbtiOppositeCf[newBuildType[1].substr(0, 1)] + inOppExt;
// newBuildType[3] = inCf;
}
return calculateTypeFromStack(newBuildType[0], newBuildType[1]);
}
function createCognFunctions() {
$cfsWrapper.innerHTML = "";
for (let i = 0; i < 4; i++) {
const $cfWrap = document.createElement("div");
$cfWrap.setAttribute("data-position", i);
$cfWrap.classList.add("cfwrap");
const $cfSpanWrap = document.createElement("div");
$cfSpanWrap.classList.add("cfspanwrap");
const $span1 = document.createElement("span");
$span1.setAttribute("data-cf-index", i);
$span1.classList.add("cf");
$span1.classList.add("cfa");
$span1.setAttribute("draggable", true);
$cfSpanWrap.appendChild($span1);
const $span2 = document.createElement("span");
$span2.setAttribute("data-cf-index", i + 4);
$span2.classList.add("cf");
$span2.classList.add("cfb");
$span2.setAttribute("draggable", true);
$cfSpanWrap.appendChild($span2);
$cfWrap.appendChild($cfSpanWrap);
$cfsWrapper.appendChild($cfWrap);
const $cfDesc12Wrapper = document.createElement("div");
$cfDesc12Wrapper.classList.add("cfdesc12wrapper");
const $cfDesc1 = document.createElement("div");
$cfDesc1.classList.add("cfdesc");
$cfDesc1.setAttribute("data-cf-index", i);
const $cfDesc2 = document.createElement("div");
$cfDesc2.classList.add("cfdesc");
$cfDesc2.setAttribute("data-cf-index", i + 4);
$cfDesc12Wrapper.appendChild($cfDesc1);
$cfDesc12Wrapper.appendChild($cfDesc2);
$cfDescWrapper.appendChild($cfDesc12Wrapper);
$cfsByIndex[i] = $span1;
$cfsByIndex[i + 4] = $span2;
$cfsDescByIndex[i] = $cfDesc1;
$cfsDescByIndex[i + 4] = $cfDesc2;
}
}
function createMBTITypes() {
$typesWrapper.innerHTML = "";
$typesDescWrapper.innerHTML = "";
let index = 0;
// Create a div for each type in $types
for (const type of Object.keys(mbtiTypes)) {
const $type = document.createElement("div");
$type.setAttribute("data-type", type);
$type.setAttribute("data-index", index);
$type.classList.add("type");
if (type === INITIAL_TYPE) {
$type.classList.add("active");
}
// Create a span for each letter in type
for (const letter of type) {
const $letter = document.createElement("span");
$letter.classList.add("letter");
$letter.innerText = letter;
$type.appendChild($letter);
}
$typesWrapper.appendChild($type);
const $typedesc = document.createElement("div");
$typedesc.setAttribute("data-type", type);
$typedesc.classList.add("typedesc");
if (type === INITIAL_TYPE) {
$typedesc.classList.add("active");
}
$typedesc.innerText = mbtiTypes[type].description;
$typesDescWrapper.appendChild($typedesc);
index++;
}
}
function getNodeTypeActive() {
return document.querySelector(".type.active");
}
function getNodeTypeFromString(typeStr) {
return document.querySelector(`.type[data-type="${typeStr}"]`);
}
const INFINITE_SCROLL_DEPTH = 4;
function renderInfiniteScroll() {
const $activeType = getNodeTypeActive();
if (!$activeType) {
console.warn("No active type");
return;
}
$prevType = $activeType;
$nextType = $activeType;
for (let i = 0; i < INFINITE_SCROLL_DEPTH; i++) {
$prevType = $prevType ? $prevType.previousElementSibling : null;
$nextType = $nextType ? $nextType.nextElementSibling : null;
}
if (!$nextType) {
for (let i = 0; i < INFINITE_SCROLL_DEPTH; i++) {
const $typeAt = $typesWrapper.children[0];
const $clone = $typeAt.cloneNode(true);
$typesWrapper.appendChild($clone);
$typesWrapper.removeChild($typeAt);
}
}
if (!$prevType) {
for (let i = 0; i < INFINITE_SCROLL_DEPTH; i++) {
const $typeAt = $typesWrapper.children[$typesWrapper.children.length - 1];
const $clone = $typeAt.cloneNode(true);
$typesWrapper.prepend($clone);
$typesWrapper.removeChild($typeAt);
}
}
// Reset data-index of every children
Array.from($typesWrapper.children).forEach(($children, index) => {
$children.setAttribute("data-index", index);
});
}
function getOrdinal(n) {
const s = ["th", "st", "nd", "rd"];
const v = n % 100;
return n + (s[(v - 20) % 10] || s[v] || s[0]);
}
function changeActiveType(nextType, forced = false) {
let $nextType = getNodeTypeFromString(nextType);
if (!$nextType) {
console.warn(`Type ${nextType} does not exist`);
return;
}
const $activeType = getNodeTypeActive();
const activeTypeIsSame = $nextType === $activeType;
if (activeTypeIsSame && !forced) {
console.warn(`Type ${nextType} is already active`);
return;
}
location.hash = nextType.toLowerCase();
if (!activeTypeIsSame) {
$activeType.classList.remove("active");
$nextType.classList.add("active");
}
renderInfiniteScroll();
const oldType = $activeType.dataset.type;
const oldIndex = $activeType.dataset.index;
// Move y of $types to show active type
$typesWrapper.animate(
{
translate: [
`0 ${-$activeType.offsetTop}px`,
`0 ${-$nextType.offsetTop}px`,
],
},
{
duration: activeTypeIsSame ? 0 : SCROLL_DURATION,
easing: "ease-in-out",
fill: "forwards",
}
);
// Get typedesc of active type
if (!activeTypeIsSame) {
const scrollBy =
(Number($nextType.dataset.index) > oldIndex ? -1 : 1) * 500;
const $activeTypeDesc = document.querySelector(
`.typedesc[data-type="${oldType}"]`
);
const $nextTypeDesc = document.querySelector(
`.typedesc[data-type="${nextType}"]`
);
$activeTypeDesc.animate(
{
translate: [`0 0`, `0 ${scrollBy}px`],
},
{
duration: SCROLL_DURATION,
easing: "ease-in-out",
fill: "forwards",
}
);
$nextTypeDesc.animate(
{
translate: [`0 ${-scrollBy}px`, `0 0`],
},
{
duration: SCROLL_DURATION,
easing: "ease-in-out",
fill: "forwards",
}
);
$activeTypeDesc.classList.remove("active");
$nextTypeDesc.classList.add("active");
}
mbtiTypes[nextType].functions.forEach((text, index) => {
$cfsByIndex[index].innerText = text;
$cfsByIndex[index].setAttribute("data-cf", text);
$cfsDescByIndex[index].innerHTML = `<h3>(${getOrdinal(index + 1)}) ${
cognFuncsStackNames[index]
}</h3><p>${cognFuncs[text].description}</p>`;
});
}
function onMouseWheel(e) {
const $activeType = getNodeTypeActive();
const $nextType =
e.deltaY > 0
? $activeType.nextElementSibling
: $activeType.previousElementSibling;
changeActiveType($nextType.dataset.type);
}
function throttle(fn) {
let isThrottled = false;
return function (...args) {
if (isThrottled) return;
isThrottled = true;
setTimeout(() => {
isThrottled = false;
}, 150);
fn(...args);
};
}
// Listeners
document.body.addEventListener("mousewheel", throttle(onMouseWheel));
$typesWrapper.addEventListener("click", (e) => {
let $parent = e.target;
while (!$parent.dataset.type) {
$parent = $parent.parentElement;
}
if ($parent.dataset.type) {
changeActiveType($parent.dataset.type);
}
});
const keyPressesToCharIndex = {
e: 0,
i: 0,
s: 1,
n: 1,
t: 2,
f: 2,
j: 3,
p: 3,
};
window.addEventListener("keydown", (e) => {
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
const $activeType = getNodeTypeActive();
const $nextType =
e.key === "ArrowDown"
? $activeType.nextElementSibling
: $activeType.previousElementSibling;
changeActiveType($nextType.dataset.type);
return;
}
const changeTypeIndex = keyPressesToCharIndex[e.key];
if (changeTypeIndex !== undefined) {
const $activeType = getNodeTypeActive();
const activeTypeStrArr = $activeType.dataset.type.split("");
activeTypeStrArr[changeTypeIndex] = e.key.toUpperCase();
const newTypeStr = activeTypeStrArr.join("");
const $nextType = getNodeTypeFromString(newTypeStr);
changeActiveType($nextType.dataset.type);
}
});
$cfsWrapper.addEventListener("mouseover", (e) => {
const cfIndex = e.target.dataset.cfIndex;
if (cfIndex === undefined) return;
$cfsDescByIndex[cfIndex].classList.add("active");
});
$cfsWrapper.addEventListener("mouseout", (e) => {
const $active = document.querySelector(".cfdesc.active");
if (!$active) return;
$active.classList.remove("active");
});
$cfsWrapper.addEventListener("dragstart", (e) => {
e.target.classList.add("dragging");
const incomingCf = e.target.dataset.cf;
e.dataTransfer.effectAllowed = "move";
e.dataTransfer.setData("text/plain", incomingCf);
$cfsWrapper.querySelectorAll(`[draggable]`).forEach(($scf) => {
if ($scf === e.target) return;
$scf.classList.add("droppable");
});
});
$cfsWrapper.addEventListener("dragend", (e) => {
e.target.classList.remove("dragging");
document.querySelectorAll("[draggable]").forEach(($scf) => {
$scf.classList.remove("droppable");
$scf.classList.remove("over");
});
});
$cfsWrapper.addEventListener("dragenter", (e) => {
if (!e.target.classList.contains("droppable")) return;
e.target.classList.add("over");
});
$cfsWrapper.addEventListener("dragleave", (e) => {
if (!e.target.classList.contains("droppable")) return;
e.target.classList.remove("over");
});
$cfsWrapper.addEventListener("dragover", (e) => {
e.preventDefault();
});
$cfsWrapper.addEventListener("drop", (e) => {
e.stopPropagation();
if (!e.target.classList.contains("droppable")) return;
const incomingCf = e.dataTransfer.getData("text/plain");
const newType = calculateNewTypeAfterSwap(
incomingCf,
Number(e.target.dataset.cfIndex)
);
setTimeout(() => {
changeActiveType(newType);
}, 100);
});
// On Load - random type
createMBTITypes();
createCognFunctions();
changeActiveType(INITIAL_TYPE, true);