Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

1.14.7#215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
otmon76 merged 7 commits intojavascript-tutorial:masterfromotmon76:1.14.7
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
449 changes: 209 additions & 240 deletions1-js/99-js-misc/07-weakref-finalizationregistry/article.md
View file
Open in desktop

Large diffs are not rendered by default.

View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,14 +10,14 @@
<body>

<div class="app">
<button class="start-messages">Start sending messages</button>
<button class="start-messages">Začít posílat zprávy</button>
<div class="window">
<div class="window__header">
<p class="window__title">Messages:</p>
<button class="window__button">Close</button>
<p class="window__title">Zprávy:</p>
<button class="window__button">Zavřít</button>
</div>
<div class="window__body">
No messages.
Žádné zprávy.
</div>
</div>
</div>
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
conststartMessagesBtn = document.querySelector('.start-messages'); // (1)
constcloseWindowBtn = document.querySelector('.window__button'); // (2)
constwindowElementRef = new WeakRef(document.querySelector(".window__body")); // (3)
consttlačítkoZačítPosílat = document.querySelector('.start-messages'); // (1)
consttlačítkoZavřítOkno = document.querySelector('.window__button'); // (2)
constodkazNaElementOkna = new WeakRef(document.querySelector(".window__body")); // (3)

startMessagesBtn.addEventListener('click', () => { // (4)
startMessages(windowElementRef);
startMessagesBtn.disabled = true;
tlačítkoZačítPosílat.addEventListener('click', () => { // (4)
startMessages(odkazNaElementOkna);
tlačítkoZačítPosílat.disabled = true;
});

closeWindowBtn.addEventListener('click', () => document.querySelector(".window__body").remove()); // (5)
tlačítkoZavřítOkno.addEventListener('click', () => document.querySelector(".window__body").remove()); // (5)


conststartMessages = (element) => {
consttimerId = setInterval(() => { // (6)
constzačniPosílatZprávy = (element) => {
constidČasovače = setInterval(() => { // (6)
if (element.deref()) { // (7)
constpayload = document.createElement("p");
payload.textContent = `Message: System status OK: ${new Date().toLocaleTimeString()}`;
element.deref().append(payload);
constzátěž = document.createElement("p");
zátěž.textContent = `Zpráva: Stav systému OK: ${new Date().toLocaleTimeString()}`;
element.deref().append(zátěž);
} else { // (8)
alert("The element has been deleted."); // (9)
clearInterval(timerId);
alert("Element byl odstraněn."); // (9)
clearInterval(idČasovače);
}
}, 1000);
};
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

[8]ページ先頭

©2009-2025 Movatter.jp