This file contains 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
(function() { | |
// импортируем нужные для старта приложения фукнции | |
var activateMap = window.map.activateMap; | |
var activateForm = window.form.activateForm; | |
// иницилизируем само приложение, просто активируя карту и форму | |
activateMap(); | |
activateForm(); | |
})() |
This file contains 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
(function () { | |
// активация формы | |
function activateForm() {/*...*/} | |
// валидация формы | |
function validateForm() {/*...*/} | |
// тут просто экспортируем функции для работы с формой | |
window.form = { | |
activateForm, |
This file contains 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
(function() { | |
// чтобы каждый раз не писать длинное имя, сохраним фукнции из модулей в обычные переменные | |
// лучше это делать в начале файле, чтобы было понятно что тут используются функции из других модулей | |
var createPins = window.pin.createPins; | |
var createPinsElement = window.pin.createPinsElement; | |
// активация карты, добавление пинов и тд | |
function activateMap() { | |
var pins = createPins(); | |
var pinsElement = createPinsElement(pins); |
This file contains 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
(function() { | |
// создание (или генерация) одного пина | |
function createPin() {/*...*/} | |
// создание списка пинов | |
function createPins() {/*...*/} | |
// создание DOM элемента | |
function createPinsElement(pins) {/*...*/} |
This file contains 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
// создание (или генерация) одного пина | |
function createPin() {/*...*/} | |
// создание списка пинов | |
function createPins() {/*...*/} | |
// создание DOM элемента | |
function createPinsElement() {/*...*/} | |
// создание детальной карточки пина |
This file contains 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
// Не правильно | |
// в одной фукнции сгенерировали данные и в ней же добавили их в DOM | |
function wrong() { | |
var data = []; | |
for (var i = 0, len = 5; len < i; i += 1) { | |
data.push(i); | |
} | |
var element = document.querySelectro('.parent'); | |
for (var i = 0, len = data.length; len < i; i += 1) { |
This file contains 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
// Не правильно | |
// нашли элемент | |
var element = document.querySelectro('.parent'); | |
function doSomeThing() { | |
// используем глобальную переменную внутри функции, не надо так! | |
element.textContent = 'Hello, world!'; | |
} | |
doSomeThing(); | |
// Правильно |
This file contains 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 MAX_VALUE = 10; | |
// объявляем фукнции | |
function getData () { | |
let result = []; | |
for (let i = 0; i < MAX_VALUE; i += 1) { | |
result = result.concat(i); | |
} |
This file contains 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
// Immutable.js non-mutating List.push | |
const collection = Immutable.List.of('ironMan'); | |
const newCollection = collection.push('captainAmerica'); | |
console.log(newCollection) | |
// Output: | |
Array [ | |
"ironMan", | |
"captainAmerica", |
This file contains 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
// Immutable.js non-mutating List.push | |
const collection = Immutable.List.of('ironMan'); | |
collection.push('captainAmerica'); | |
console.log(collection) | |
// Output: | |
Array [ | |
"ironMan", | |
] |
NewerOlder