{"action":"created","comment":{"url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/pulls/comments/155432309","pull_request_review_id":81749323,"id":155432309,"diff_hunk":"@@ -291,50 +298,48 @@ accomodationTypeSelect.addEventListener('input', accomodationTypeSelectHandler);\n \n // синхронизируем количество комнат с количеством гостей\n // обработчик события на селект с количеством комнат\n-var roomNumberSelectSelectHadler = function () {\n-  if (roomNumberSelect.value === '1') {\n-    capacitySelect.options[2].selected = true;\n-    capacitySelect.options[0].disabled = true;\n-    capacitySelect.options[1].disabled = true;\n-    capacitySelect.options[2].disabled = false;\n-    capacitySelect.options[3].disabled = true;\n-  } else if (roomNumberSelect.value === '2') {\n-    capacitySelect.options[2].selected = true;\n-    capacitySelect.options[0].disabled = true;\n-    capacitySelect.options[1].disabled = false;\n-    capacitySelect.options[2].disabled = false;\n-    capacitySelect.options[3].disabled = true;\n-  } else if (roomNumberSelect.value === '3') {\n-    capacitySelect.options[2].selected = true;\n-    capacitySelect.options[0].disabled = false;\n-    capacitySelect.options[1].disabled = false;\n-    capacitySelect.options[2].disabled = false;\n-    capacitySelect.options[3].disabled = true;\n-  } else {\n-    capacitySelect.options[3].selected = true;\n-    capacitySelect.options[0].disabled = true;\n-    capacitySelect.options[1].disabled = true;\n-    capacitySelect.options[2].disabled = true;\n-    capacitySelect.options[3].disabled = false;\n+var roomNumberSelectHadler = function (evt) {\n+  var roomCount = evt.target.value;\n+  var options = capacitySelect.options;\n+  var hasSelected = false;\n+\n+  for (var j = 0; i < options.length; j++) {\n+    var currentOption = options[j]; // тут будет число\n+    var currentOptionValue = currentOption.value; // тут будет число (вместимость)\n+    var suitableCapacity = ROOM_CAPACITY[roomCount]; // массив со значениями (value) подходящей вместительности\n+    var isDisabled = suitableCapacity.indexOf(currentOptionValue) === -1; // если в массиве нет значения текущей опции, то статус опции disabled = true\n+\n+    currentOption.selected = false; // для начала делаем пункт не выбраным\n+    currentOption.disabled = isDisabled; // применяем к атрибуту disabled\n+    if (!isDisabled && !hasSelected) { // если не disabled  и еще нет выбранного нами вручную пункта\n+      currentOption.selected = true;\n+      hasSelected = true; // назначаем значение true, что бы больше не заходить в это условие(selected в списке должен быть только один)\n+    }\n   }\n };\n \n-// слушаем измнения в селекте кол-ва комнат\n-roomNumberSelect.addEventListener('input', roomNumberSelectSelectHadler);\n+roomNumberSelect.addEventListener('input', roomNumberSelectHadler);\n \n-// проверяем введенные данные\n-// обработчик события на invalid\n-var noticeFormInvalidHandler = function (evt) {\n-  var invalidOption = evt.target;\n-  invalidOption.style.border = '1px solid red';\n+//\n+\n+var submit = noticeForm.querySelector('.form__submit');\n+var inputs = noticeForm.querySelectorAll('input');\n+\n+var checkValidity = function () {\n+  for (i = 0; i < inputs.length; i++) {\n+    var input = inputs[i];\n+    if (input.checkValidity() === false) {\n+      input.style.borderColor = 'red';\n+    } else {\n+      input.style.borderColor = 'black';\n+    }\n+  }\n };\n \n-// обработчик события на valid\n-var noticeFormValidHandler = function (evt) {\n-  var validOption = evt.target;\n-  validOption.style.border = 'none';\n+var onSubmitClick = function (evt) {\n+  evt.preventDefault();","path":"js/map.js","position":null,"original_position":93,"commit_id":"d5dacc662227c2870bb412bcc03d81fa569b2be4","original_commit_id":"d5dacc662227c2870bb412bcc03d81fa569b2be4","user":{"login":"andreydos","id":13402400,"avatar_url":"https://avatars2.githubusercontent.com/u/13402400?v=4","gravatar_id":"","url":"https://api.github.com/users/andreydos","html_url":"https://github.com/andreydos","followers_url":"https://api.github.com/users/andreydos/followers","following_url":"https://api.github.com/users/andreydos/following{/other_user}","gists_url":"https://api.github.com/users/andreydos/gists{/gist_id}","starred_url":"https://api.github.com/users/andreydos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreydos/subscriptions","organizations_url":"https://api.github.com/users/andreydos/orgs","repos_url":"https://api.github.com/users/andreydos/repos","events_url":"https://api.github.com/users/andreydos/events{/privacy}","received_events_url":"https://api.github.com/users/andreydos/received_events","type":"User","site_admin":false},"body":"1. в любом случае отменяешь отправку формы\r\n2. проверяешь поля, возможно меняешь бордер на красный\r\n3. в любом случае сабмитишь форму\r\nт.е. превенд дефаулт нужно не здесь делать, а только в случае невалидного поля. Если поля были валидны и соответственно превенддефаулт не вызывался, то форма отправиться на сервер","created_at":"2017-12-07T05:12:46Z","updated_at":"2017-12-07T05:12:46Z","html_url":"https://github.com/htmlacademy-javascript/121563-keksobooking/pull/4#discussion_r155432309","pull_request_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/pulls/4","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/pulls/comments/155432309"},"html":{"href":"https://github.com/htmlacademy-javascript/121563-keksobooking/pull/4#discussion_r155432309"},"pull_request":{"href":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/pulls/4","id":156590585,"html_url":"https://github.com/htmlacademy-javascript/121563-keksobooking/pull/4","diff_url":"https://github.com/htmlacademy-javascript/121563-keksobooking/pull/4.diff","patch_url":"https://github.com/htmlacademy-javascript/121563-keksobooking/pull/4.patch","issue_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/issues/4","number":4,"state":"open","locked":false,"title":"Личный проект: доверяй, но проверяй","user":{"login":"lilanubis","id":15787956,"avatar_url":"https://avatars1.githubusercontent.com/u/15787956?v=4","gravatar_id":"","url":"https://api.github.com/users/lilanubis","html_url":"https://github.com/lilanubis","followers_url":"https://api.github.com/users/lilanubis/followers","following_url":"https://api.github.com/users/lilanubis/following{/other_user}","gists_url":"https://api.github.com/users/lilanubis/gists{/gist_id}","starred_url":"https://api.github.com/users/lilanubis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lilanubis/subscriptions","organizations_url":"https://api.github.com/users/lilanubis/orgs","repos_url":"https://api.github.com/users/lilanubis/repos","events_url":"https://api.github.com/users/lilanubis/events{/privacy}","received_events_url":"https://api.github.com/users/lilanubis/received_events","type":"User","site_admin":false},"body":"\n\n---\n:mortar_board: [Личный проект: доверяй, но проверяй](https://up.htmlacademy.ru/javascript/11/user/121563/tasks/14)\n\n:boom: https://htmlacademy-javascript.github.io/121563-keksobooking/4/","created_at":"2017-12-05T22:22:51Z","updated_at":"2017-12-07T05:12:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"85f0e9c44b0c690037261af988c51a7d62f1c249","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/pulls/4/commits","review_comments_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/pulls/4/comments","review_comment_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/pulls/comments{/number}","comments_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/issues/4/comments","statuses_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/statuses/d5dacc662227c2870bb412bcc03d81fa569b2be4","head":{"label":"lilanubis:module4-task2","ref":"module4-task2","sha":"d5dacc662227c2870bb412bcc03d81fa569b2be4","user":{"login":"lilanubis","id":15787956,"avatar_url":"https://avatars1.githubusercontent.com/u/15787956?v=4","gravatar_id":"","url":"https://api.github.com/users/lilanubis","html_url":"https://github.com/lilanubis","followers_url":"https://api.github.com/users/lilanubis/followers","following_url":"https://api.github.com/users/lilanubis/following{/other_user}","gists_url":"https://api.github.com/users/lilanubis/gists{/gist_id}","starred_url":"https://api.github.com/users/lilanubis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lilanubis/subscriptions","organizations_url":"https://api.github.com/users/lilanubis/orgs","repos_url":"https://api.github.com/users/lilanubis/repos","events_url":"https://api.github.com/users/lilanubis/events{/privacy}","received_events_url":"https://api.github.com/users/lilanubis/received_events","type":"User","site_admin":false},"repo":{"id":110744187,"name":"121563-keksobooking","full_name":"lilanubis/121563-keksobooking","owner":{"login":"lilanubis","id":15787956,"avatar_url":"https://avatars1.githubusercontent.com/u/15787956?v=4","gravatar_id":"","url":"https://api.github.com/users/lilanubis","html_url":"https://github.com/lilanubis","followers_url":"https://api.github.com/users/lilanubis/followers","following_url":"https://api.github.com/users/lilanubis/following{/other_user}","gists_url":"https://api.github.com/users/lilanubis/gists{/gist_id}","starred_url":"https://api.github.com/users/lilanubis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lilanubis/subscriptions","organizations_url":"https://api.github.com/users/lilanubis/orgs","repos_url":"https://api.github.com/users/lilanubis/repos","events_url":"https://api.github.com/users/lilanubis/events{/privacy}","received_events_url":"https://api.github.com/users/lilanubis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lilanubis/121563-keksobooking","description":"Olga Baryshnikova","fork":true,"url":"https://api.github.com/repos/lilanubis/121563-keksobooking","forks_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/forks","keys_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/teams","hooks_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/hooks","issue_events_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/issues/events{/number}","events_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/events","assignees_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/assignees{/user}","branches_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/branches{/branch}","tags_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/tags","blobs_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/git/refs{/sha}","trees_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/statuses/{sha}","languages_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/languages","stargazers_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/stargazers","contributors_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/contributors","subscribers_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/subscribers","subscription_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/subscription","commits_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/commits{/sha}","git_commits_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/git/commits{/sha}","comments_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/comments{/number}","issue_comment_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/issues/comments{/number}","contents_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/contents/{+path}","compare_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/merges","archive_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/downloads","issues_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/issues{/number}","pulls_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/pulls{/number}","milestones_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/milestones{/number}","notifications_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/labels{/name}","releases_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/releases{/id}","deployments_url":"https://api.github.com/repos/lilanubis/121563-keksobooking/deployments","created_at":"2017-11-14T21:00:52Z","updated_at":"2017-11-14T21:00:54Z","pushed_at":"2017-12-06T23:28:45Z","git_url":"git://github.com/lilanubis/121563-keksobooking.git","ssh_url":"git@github.com:lilanubis/121563-keksobooking.git","clone_url":"https://github.com/lilanubis/121563-keksobooking.git","svn_url":"https://github.com/lilanubis/121563-keksobooking","homepage":null,"size":2226,"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,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"htmlacademy-javascript:master","ref":"master","sha":"900fb45c76c6ef333b2cb3699053feaf20df3ea4","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":110743637,"name":"121563-keksobooking","full_name":"htmlacademy-javascript/121563-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/121563-keksobooking","description":"Olga Baryshnikova","fork":false,"url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking","forks_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/forks","keys_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/keys{/key_id}","collaborators_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/teams","hooks_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/hooks","issue_events_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/issues/events{/number}","events_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/events","assignees_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/assignees{/user}","branches_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/branches{/branch}","tags_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/tags","blobs_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/git/refs{/sha}","trees_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/git/trees{/sha}","statuses_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/statuses/{sha}","languages_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/languages","stargazers_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/stargazers","contributors_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/contributors","subscribers_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/subscribers","subscription_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/subscription","commits_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/commits{/sha}","git_commits_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/git/commits{/sha}","comments_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/comments{/number}","issue_comment_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/issues/comments{/number}","contents_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/contents/{+path}","compare_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/compare/{base}...{head}","merges_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/merges","archive_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/downloads","issues_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/issues{/number}","pulls_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/pulls{/number}","milestones_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/milestones{/number}","notifications_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/labels{/name}","releases_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/releases{/id}","deployments_url":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/deployments","created_at":"2017-11-14T20:55:06Z","updated_at":"2017-11-14T21:22:48Z","pushed_at":"2017-12-06T23:28:46Z","git_url":"git://github.com/htmlacademy-javascript/121563-keksobooking.git","ssh_url":"git@github.com:htmlacademy-javascript/121563-keksobooking.git","clone_url":"https://github.com/htmlacademy-javascript/121563-keksobooking.git","svn_url":"https://github.com/htmlacademy-javascript/121563-keksobooking","homepage":"https://github.com/lilanubis/121563-keksobooking","size":2224,"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,"archived":false,"open_issues_count":1,"license":null,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/pulls/4"},"html":{"href":"https://github.com/htmlacademy-javascript/121563-keksobooking/pull/4"},"issue":{"href":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/issues/4"},"comments":{"href":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/htmlacademy-javascript/121563-keksobooking/statuses/d5dacc662227c2870bb412bcc03d81fa569b2be4"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"andreydos"}}