Learn
+-
+
- + Lesson 0: C names + +
- + Lesson 1: Basics + +
- + Lesson 2: Arguments + +
Practice
+-
+
- + Primitive Types + +
diff --git a/flashcard.css b/flashcard.css new file mode 100644 index 0000000..50226bd --- /dev/null +++ b/flashcard.css @@ -0,0 +1,35 @@ +.flash-card { + margin-bottom: 10px; +} + +.flashcard-questionee { + font-size: 1rem; +} + +.flashcard-option-list { + display: flex; + flex-direction: column; + gap: 10px; + padding-left: 0; +} + +.flashcard-option { + width: 250px; + font-weight: bold; + padding: 10px; + background-color: var(--color-primary); + color: var(--color-white); + border: none; + text-decoration: none; + + display: block; + cursor: pointer; + + &:hover { + background-color: color-mix(in oklab, var(--color-primary), white 15%); + } +} + +.flashcard-error { + color: var(--color-error); +} diff --git a/flashcard.js b/flashcard.js new file mode 100644 index 0000000..8761135 --- /dev/null +++ b/flashcard.js @@ -0,0 +1,57 @@ +const randomItem = (not) => { + let item; + + do { + const idx = Math.floor(Math.random() * window.ITEMS.length); + item = window.ITEMS[idx]; + } while (not && item === not); + + return item; +}; + +const infoText = document.querySelector("#info-text"); + +function next() { + infoText.textContent = ""; + const item = randomItem(); + + const mangle = Math.random() > 0.5; + + const question = `What is the ${mangle ? "" : "de"}mangled form of this?`; + + const children = card.querySelectorAll("#card > *"); + children[0].textContent = question; + children[1].textContent = mangle ? item.means : item.mangle; + + const options = [ + randomItem(item), + randomItem(item), + randomItem(item), + randomItem(item), + ]; + const correctIdx = Math.floor(Math.random() * options.length); + options[correctIdx] = item; + + children[2].replaceChildren( + ...options.map((opt, i) => { + const isCorrect = i === correctIdx; + + const text = document.createElement("li"); + text.classList.add("flashcard-option"); + text.textContent = mangle ? opt.mangle : opt.means; + text.tabIndex = "0"; + text.addEventListener("click", () => { + if (isCorrect) { + infoText.classList.remove("flashcard-error"); + next(); + } else { + infoText.classList.add("flashcard-error"); + infoText.textContent = "Incorrect."; + } + }); + return text; + }) + ); +} + +next(); diff --git a/index.css b/index.css index e954496..292ac27 100644 --- a/index.css +++ b/index.css @@ -6,6 +6,7 @@ html { --color-primary: rebeccapurple; --color-white: white; --color-error: red; + --color-success: green; height: 100%; } @@ -25,6 +26,9 @@ body { footer { justify-self: flex-end; + position: absolute; + bottom: 0; + margin-bottom: 20px; } .content { @@ -43,6 +47,18 @@ footer { text-decoration: none; } +.main-two-columns { + display: flex; + flex-direction: row; + gap: 20px; + + margin-bottom: 40px; +} + +.column-divider { + border: black 1px solid; +} + .action-button { width: 250px; font-size: 1rem; @@ -66,7 +82,6 @@ footer { display: flex; flex-direction: column; gap: 10px; - } .step { diff --git a/index.html b/index.html index bb4713c..42b3d38 100644 --- a/index.html +++ b/index.html @@ -18,8 +18,8 @@
- This website will teach you C++ Itanium Symbol Name Mangling. Itanium-style - mangling is used on a lot of platforms, including Linux. + This website will teach you C++ Itanium Symbol Name Mangling. + Itanium-style mangling is used on a lot of platforms, including Linux.
Since C++ mangling (the entire ABI) is considered stable today, you @@ -31,17 +31,39 @@ each step to test your knowledge.