- Взять index.html и style.css из исходного задания
- Взять script.js из этого gist-а.
- Файлы с уровнями отсюда
- И, теперь главное -- сделать так, чтобы когда мы перешли с уровня на уровень, имеющийся обработчик (созданный в 28 строке, в функции on()) отключался, для того, чтобы второй уровень работал нормально.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // util functions | |
| const list = (arrLike) => Array.from(arrLike); | |
| const first = (selector) => document.querySelector(selector); | |
| const all = (selector) => list(document.querySelectorAll(selector)); | |
| const child = (el, index = 0) => list(el.children)[index]; | |
| const text = (el, value = null) => { | |
| if (value === null) { | |
| return el && el.textContent; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "width": 7, | |
| "height": 7, | |
| "walls": [ | |
| "0:0", | |
| "1:0", | |
| "2:0", | |
| "3:0", | |
| "4:0", | |
| "5:0", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Все, что было раньше плюс | |
| const makeCell = (x, y) => { | |
| return "<div class='item' data-pos='" + x + ":" + y + "'></div>" | |
| } | |
| const makeRow = (y) => { | |
| let row = "<div class='row'>"; | |
| for (let x = 0; x <= 10; x++) { | |
| row += makeCell(x, y); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html> | |
| <head> | |
| <title>SVG sample</title> | |
| <link rel="stylesheet" href="./style.css" /> | |
| </head> | |
| <body> | |
| <main></main> | |
| <div class="arrows"> | |
| <svg |
- Добавляем новую ветку
- Добавляем класс Organization в types
- Делаем API списка организаций по сваггеру
- Меняем API пользователя с учетом привязки к организациям
- Добавляем список организаций пользователю
- Добавляем в организацию список привязанных веток
- UI списка групп
- UI привязки веток к организации
Временная мёртвая зона (TDZ) обеспечивается на нескольких уровнях работы JavaScript-движка. Вот как это реализовано технически:
На этапе компиляции движок JavaScript выполняет:
- Анализ лексического окружения (LexicalEnvironment):
- Для каждого блока создаётся отдельное лексическое окружение
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const bindHandler = (e) => { | |
| if (pause) { | |
| dispatch(setBind(e.code)); | |
| dispatch(setPause(false)); | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| setBind: (state, action) => { | |
| const code = action.payload; | |
| if (state.direction) { | |
| state.bindings[state.direction] = code; | |
| state.direction = null; | |
| } | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| useEffect(() => { | |
| if (row) { | |
| nameRef.current?.value = name; | |
| cityRef.current?.value = city; | |
| } | |
| }, [row]); |
NewerOlder