- Introduced a new script to check TypeScript lesson files for errors. - Created a main TypeScript file to render lessons and their details. - Added lesson definitions with starter and answer codes. - Implemented a user interface for navigating and running lessons. - Styled the application with CSS for a better user experience. - Updated README to reflect the new TypeScript section and usage instructions.
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
const prependButton = document.getElementById("prepend-btn");
|
|
const clearActiveButton = document.getElementById("clear-active-btn");
|
|
const helpLink = document.getElementById("help-link");
|
|
const hintText = document.getElementById("hint-text");
|
|
const messageList = document.getElementById("message-list");
|
|
|
|
let messageIndex = 1;
|
|
|
|
prependButton.addEventListener("click", function () {
|
|
const item = document.createElement("li");
|
|
item.className = "item active";
|
|
item.textContent = `新插入的提醒 ${messageIndex}`;
|
|
messageList.prepend(item);
|
|
hintText.textContent = "已把一条消息插入到最前面";
|
|
messageIndex += 1;
|
|
});
|
|
|
|
clearActiveButton.addEventListener("click", function () {
|
|
const items = document.querySelectorAll(".item");
|
|
|
|
items.forEach(function (item) {
|
|
item.classList.remove("active");
|
|
});
|
|
|
|
hintText.textContent = "已移除全部高亮状态";
|
|
});
|
|
|
|
helpLink.addEventListener("click", function (event) {
|
|
event.preventDefault();
|
|
hintText.textContent = "已阻止默认跳转";
|
|
});
|