{"action":"created","comment":{"url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/pulls/comments/136720538","pull_request_review_id":60299734,"id":136720538,"diff_hunk":"@@ -135,14 +138,72 @@\n     return lodgeElement;\n   };\n \n-  for (var i = 0; i < PINS_COUNT; i++) {\n-    var currentPinMarker = createRandomPin();\n+  var setPinMarker = function () {\n+    for (var i = 0; i < PINS_COUNT; i++) {\n+      var currentPinMarker = createRandomPin();\n \n-    fragment.appendChild(renderPinMarker(currentPinMarker));\n-    lodgePanelAvatar.src = currentPinMarker.author.avatar;\n-    pinMarkerArr.push(currentPinMarker);\n-  }\n+      fragment.appendChild(renderPinMarker(currentPinMarker));\n+      pinMarkerArr.push(currentPinMarker);\n+    }\n+\n+    pinMap.appendChild(fragment);\n+  };\n+\n+  var renderLodgeView = function (num) {\n+    var lodgePanelItem = pinMarkerArr[num - 1] || pinMarkerArr[0];\n+\n+    lodgePanelElement.replaceWith(renderLodge(lodgePanelItem));\n+    lodgePanelElement = document.querySelector('#offer-dialog .dialog__panel');\n+    lodgePanelAvatar.src = lodgePanelItem.author.avatar;\n+  };\n+\n+  var setActive = function (item) {\n+    dialog.classList.remove('hidden');\n+\n+    if (isActive) {\n+      isActive.classList.remove('pin--active');\n+    }\n+\n+    isActive = item;\n+    isActive.classList.add('pin--active');\n+  };\n+\n+  var getPinNumber = function (item) {\n+    var i = 0;\n+\n+    while (item = item.previousSibling) {\n+      item.nodeType === 1 && i++;\n+    }\n+\n+    return i;\n+  };\n+\n+  pinMap.addEventListener('click', function (event) {\n+    var target = event.target;\n+    var targetPin = target.closest('div');\n+\n+    if (!targetPin) {\n+      return;\n+    }\n+\n+    renderLodgeView(getPinNumber(targetPin));\n+    setActive(targetPin);\n+  });\n+\n+  dialog.addEventListener('click', function (event) {\n+    var target = event.target;\n+    var targetClose = target.closest('a');\n+\n+    if (targetClose === dialogClose) {\n+      event.preventDefault();\n+      dialog.classList.add('hidden');\n+\n+      if (isActive) {\n+        isActive.classList.remove('pin--active');\n+      }\n+    }\n+  });\n \n-  pinMap.appendChild(fragment);\n-  lodgePanelElement.replaceWith(renderLodge(pinMarkerArr[0]));\n+  setPinMarker();","path":"js/map.js","position":null,"original_position":89,"commit_id":"045b52c0140f12a3b722832a217554888d6dc8ea","original_commit_id":"38c5d7f11e9c53ec1177149699fcfd1a53c7663f","user":{"login":"aalexeev239","id":6787602,"avatar_url":"https://avatars2.githubusercontent.com/u/6787602?v=4","gravatar_id":"","url":"https://api.github.com/users/aalexeev239","html_url":"https://github.com/aalexeev239","followers_url":"https://api.github.com/users/aalexeev239/followers","following_url":"https://api.github.com/users/aalexeev239/following{/other_user}","gists_url":"https://api.github.com/users/aalexeev239/gists{/gist_id}","starred_url":"https://api.github.com/users/aalexeev239/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aalexeev239/subscriptions","organizations_url":"https://api.github.com/users/aalexeev239/orgs","repos_url":"https://api.github.com/users/aalexeev239/repos","events_url":"https://api.github.com/users/aalexeev239/events{/privacy}","received_events_url":"https://api.github.com/users/aalexeev239/received_events","type":"User","site_admin":false},"body":"Вопрос о том, что такое слушатель, и какой код исполняется сразу, открыт.","created_at":"2017-09-03T16:23:49Z","updated_at":"2017-09-03T16:23:49Z","html_url":"https://github.com/htmlacademy-javascript/288419-keksobooking/pull/3#discussion_r136720538","pull_request_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/pulls/3","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/pulls/comments/136720538"},"html":{"href":"https://github.com/htmlacademy-javascript/288419-keksobooking/pull/3#discussion_r136720538"},"pull_request":{"href":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/pulls/3"}},"in_reply_to_id":136194711},"pull_request":{"url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/pulls/3","id":138525399,"html_url":"https://github.com/htmlacademy-javascript/288419-keksobooking/pull/3","diff_url":"https://github.com/htmlacademy-javascript/288419-keksobooking/pull/3.diff","patch_url":"https://github.com/htmlacademy-javascript/288419-keksobooking/pull/3.patch","issue_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/issues/3","number":3,"state":"open","locked":false,"title":"Личный проект: подробности","user":{"login":"SeraphimEvil","id":23505503,"avatar_url":"https://avatars1.githubusercontent.com/u/23505503?v=4","gravatar_id":"","url":"https://api.github.com/users/SeraphimEvil","html_url":"https://github.com/SeraphimEvil","followers_url":"https://api.github.com/users/SeraphimEvil/followers","following_url":"https://api.github.com/users/SeraphimEvil/following{/other_user}","gists_url":"https://api.github.com/users/SeraphimEvil/gists{/gist_id}","starred_url":"https://api.github.com/users/SeraphimEvil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SeraphimEvil/subscriptions","organizations_url":"https://api.github.com/users/SeraphimEvil/orgs","repos_url":"https://api.github.com/users/SeraphimEvil/repos","events_url":"https://api.github.com/users/SeraphimEvil/events{/privacy}","received_events_url":"https://api.github.com/users/SeraphimEvil/received_events","type":"User","site_admin":false},"body":"\n\n---\n:mortar_board: [Личный проект: подробности](https://up.htmlacademy.ru/javascript/10/user/288419/tasks/11)\n\n:boom: https://htmlacademy-javascript.github.io/288419-keksobooking/3/","created_at":"2017-08-30T20:52:26Z","updated_at":"2017-09-03T16:23:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a166ac2ae5a637d95e8561558eea8af082a2fc4d","assignee":{"login":"aalexeev239","id":6787602,"avatar_url":"https://avatars2.githubusercontent.com/u/6787602?v=4","gravatar_id":"","url":"https://api.github.com/users/aalexeev239","html_url":"https://github.com/aalexeev239","followers_url":"https://api.github.com/users/aalexeev239/followers","following_url":"https://api.github.com/users/aalexeev239/following{/other_user}","gists_url":"https://api.github.com/users/aalexeev239/gists{/gist_id}","starred_url":"https://api.github.com/users/aalexeev239/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aalexeev239/subscriptions","organizations_url":"https://api.github.com/users/aalexeev239/orgs","repos_url":"https://api.github.com/users/aalexeev239/repos","events_url":"https://api.github.com/users/aalexeev239/events{/privacy}","received_events_url":"https://api.github.com/users/aalexeev239/received_events","type":"User","site_admin":false},"assignees":[{"login":"aalexeev239","id":6787602,"avatar_url":"https://avatars2.githubusercontent.com/u/6787602?v=4","gravatar_id":"","url":"https://api.github.com/users/aalexeev239","html_url":"https://github.com/aalexeev239","followers_url":"https://api.github.com/users/aalexeev239/followers","following_url":"https://api.github.com/users/aalexeev239/following{/other_user}","gists_url":"https://api.github.com/users/aalexeev239/gists{/gist_id}","starred_url":"https://api.github.com/users/aalexeev239/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aalexeev239/subscriptions","organizations_url":"https://api.github.com/users/aalexeev239/orgs","repos_url":"https://api.github.com/users/aalexeev239/repos","events_url":"https://api.github.com/users/aalexeev239/events{/privacy}","received_events_url":"https://api.github.com/users/aalexeev239/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/pulls/3/commits","review_comments_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/pulls/3/comments","review_comment_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/pulls/comments{/number}","comments_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/issues/3/comments","statuses_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/statuses/045b52c0140f12a3b722832a217554888d6dc8ea","head":{"label":"SeraphimEvil:module4-task1","ref":"module4-task1","sha":"045b52c0140f12a3b722832a217554888d6dc8ea","user":{"login":"SeraphimEvil","id":23505503,"avatar_url":"https://avatars1.githubusercontent.com/u/23505503?v=4","gravatar_id":"","url":"https://api.github.com/users/SeraphimEvil","html_url":"https://github.com/SeraphimEvil","followers_url":"https://api.github.com/users/SeraphimEvil/followers","following_url":"https://api.github.com/users/SeraphimEvil/following{/other_user}","gists_url":"https://api.github.com/users/SeraphimEvil/gists{/gist_id}","starred_url":"https://api.github.com/users/SeraphimEvil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SeraphimEvil/subscriptions","organizations_url":"https://api.github.com/users/SeraphimEvil/orgs","repos_url":"https://api.github.com/users/SeraphimEvil/repos","events_url":"https://api.github.com/users/SeraphimEvil/events{/privacy}","received_events_url":"https://api.github.com/users/SeraphimEvil/received_events","type":"User","site_admin":false},"repo":{"id":99731387,"name":"288419-keksobooking","full_name":"SeraphimEvil/288419-keksobooking","owner":{"login":"SeraphimEvil","id":23505503,"avatar_url":"https://avatars1.githubusercontent.com/u/23505503?v=4","gravatar_id":"","url":"https://api.github.com/users/SeraphimEvil","html_url":"https://github.com/SeraphimEvil","followers_url":"https://api.github.com/users/SeraphimEvil/followers","following_url":"https://api.github.com/users/SeraphimEvil/following{/other_user}","gists_url":"https://api.github.com/users/SeraphimEvil/gists{/gist_id}","starred_url":"https://api.github.com/users/SeraphimEvil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SeraphimEvil/subscriptions","organizations_url":"https://api.github.com/users/SeraphimEvil/orgs","repos_url":"https://api.github.com/users/SeraphimEvil/repos","events_url":"https://api.github.com/users/SeraphimEvil/events{/privacy}","received_events_url":"https://api.github.com/users/SeraphimEvil/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SeraphimEvil/288419-keksobooking","description":"Сергей Остаповец","fork":true,"url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking","forks_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/forks","keys_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/teams","hooks_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/hooks","issue_events_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/issues/events{/number}","events_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/events","assignees_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/assignees{/user}","branches_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/branches{/branch}","tags_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/tags","blobs_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/git/refs{/sha}","trees_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/statuses/{sha}","languages_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/languages","stargazers_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/stargazers","contributors_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/contributors","subscribers_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/subscribers","subscription_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/subscription","commits_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/commits{/sha}","git_commits_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/git/commits{/sha}","comments_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/comments{/number}","issue_comment_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/issues/comments{/number}","contents_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/contents/{+path}","compare_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/merges","archive_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/downloads","issues_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/issues{/number}","pulls_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/pulls{/number}","milestones_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/milestones{/number}","notifications_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/labels{/name}","releases_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/releases{/id}","deployments_url":"https://api.github.com/repos/SeraphimEvil/288419-keksobooking/deployments","created_at":"2017-08-08T20:01:56Z","updated_at":"2017-08-08T20:01:58Z","pushed_at":"2017-09-03T13:19:27Z","git_url":"git://github.com/SeraphimEvil/288419-keksobooking.git","ssh_url":"git@github.com:SeraphimEvil/288419-keksobooking.git","clone_url":"https://github.com/SeraphimEvil/288419-keksobooking.git","svn_url":"https://github.com/SeraphimEvil/288419-keksobooking","homepage":null,"size":2544,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"htmlacademy-javascript:master","ref":"master","sha":"1fb4d1e2784c2282d7c7e1933f05fbe18d87ed6b","user":{"login":"htmlacademy-javascript","id":14179712,"avatar_url":"https://avatars2.githubusercontent.com/u/14179712?v=4","gravatar_id":"","url":"https://api.github.com/users/htmlacademy-javascript","html_url":"https://github.com/htmlacademy-javascript","followers_url":"https://api.github.com/users/htmlacademy-javascript/followers","following_url":"https://api.github.com/users/htmlacademy-javascript/following{/other_user}","gists_url":"https://api.github.com/users/htmlacademy-javascript/gists{/gist_id}","starred_url":"https://api.github.com/users/htmlacademy-javascript/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/htmlacademy-javascript/subscriptions","organizations_url":"https://api.github.com/users/htmlacademy-javascript/orgs","repos_url":"https://api.github.com/users/htmlacademy-javascript/repos","events_url":"https://api.github.com/users/htmlacademy-javascript/events{/privacy}","received_events_url":"https://api.github.com/users/htmlacademy-javascript/received_events","type":"Organization","site_admin":false},"repo":{"id":99726496,"name":"288419-keksobooking","full_name":"htmlacademy-javascript/288419-keksobooking","owner":{"login":"htmlacademy-javascript","id":14179712,"avatar_url":"https://avatars2.githubusercontent.com/u/14179712?v=4","gravatar_id":"","url":"https://api.github.com/users/htmlacademy-javascript","html_url":"https://github.com/htmlacademy-javascript","followers_url":"https://api.github.com/users/htmlacademy-javascript/followers","following_url":"https://api.github.com/users/htmlacademy-javascript/following{/other_user}","gists_url":"https://api.github.com/users/htmlacademy-javascript/gists{/gist_id}","starred_url":"https://api.github.com/users/htmlacademy-javascript/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/htmlacademy-javascript/subscriptions","organizations_url":"https://api.github.com/users/htmlacademy-javascript/orgs","repos_url":"https://api.github.com/users/htmlacademy-javascript/repos","events_url":"https://api.github.com/users/htmlacademy-javascript/events{/privacy}","received_events_url":"https://api.github.com/users/htmlacademy-javascript/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/htmlacademy-javascript/288419-keksobooking","description":"Сергей Остаповец","fork":false,"url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking","forks_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/forks","keys_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/keys{/key_id}","collaborators_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/teams","hooks_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/hooks","issue_events_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/issues/events{/number}","events_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/events","assignees_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/assignees{/user}","branches_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/branches{/branch}","tags_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/tags","blobs_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/git/refs{/sha}","trees_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/git/trees{/sha}","statuses_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/statuses/{sha}","languages_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/languages","stargazers_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/stargazers","contributors_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/contributors","subscribers_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/subscribers","subscription_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/subscription","commits_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/commits{/sha}","git_commits_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/git/commits{/sha}","comments_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/comments{/number}","issue_comment_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/issues/comments{/number}","contents_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/contents/{+path}","compare_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/compare/{base}...{head}","merges_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/merges","archive_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/downloads","issues_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/issues{/number}","pulls_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/pulls{/number}","milestones_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/milestones{/number}","notifications_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/labels{/name}","releases_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/releases{/id}","deployments_url":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/deployments","created_at":"2017-08-08T18:58:44Z","updated_at":"2017-08-08T20:37:18Z","pushed_at":"2017-09-03T16:05:38Z","git_url":"git://github.com/htmlacademy-javascript/288419-keksobooking.git","ssh_url":"git@github.com:htmlacademy-javascript/288419-keksobooking.git","clone_url":"https://github.com/htmlacademy-javascript/288419-keksobooking.git","svn_url":"https://github.com/htmlacademy-javascript/288419-keksobooking","homepage":"https://github.com/SeraphimEvil/288419-keksobooking","size":2543,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/pulls/3"},"html":{"href":"https://github.com/htmlacademy-javascript/288419-keksobooking/pull/3"},"issue":{"href":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/issues/3"},"comments":{"href":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/htmlacademy-javascript/288419-keksobooking/statuses/045b52c0140f12a3b722832a217554888d6dc8ea"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"aalexeev239"}}