{"action":"created","comment":{"url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/pulls/comments/196950011","pull_request_review_id":130594404,"id":196950011,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5Njk1MDAxMQ==","diff_hunk":"@@ -427,3 +400,69 @@ var updatePreviewStyle = function (effectDescription, sizeDescription) {\n   }\n   previewImg.setAttribute('style', effectDescription + sizeDescription);\n };\n+\n+// проверка хештегов на валидность.\n+var hashTagField = document.querySelector('.text__hashtags');\n+// var descriptionField = document.querySelector('.text__description');\n+// var commentaryField = document.querySelector('.social__footer-text');\n+\n+var checkHashTagQuantity = function (element) {\n+  var message;\n+  var array = element.value.trim().split(' ');\n+  if (array.length > 5) {\n+    message = element.setCustomValidity('Максимальное количество хешгетов - 5. Удалите один или несколько хешгетов');\n+  } else {\n+    message = true;\n+  }\n+  return message;\n+};\n+\n+var checkDuplicates = function (element) {\n+  var array = element.value.split(' ');\n+  var message;\n+  array.sort();\n+  for (var i = 0; i < array.length - 1; i++) {\n+    if (String(array[i]).toUpperCase() === String(array[i + 1]).toUpperCase()) {\n+      message = element.setCustomValidity('один и тот же хэш-тег не может быть использован дважды');\n+      return message;\n+    } else {\n+      message = true;\n+    }\n+  }\n+  return message;\n+};\n+\n+//  Вадим, вот тут некрасиво сообщения выводяться, как поправить?\n+var checkHashTags = function (element) {\n+  var message;\n+  var array = element.value.split(' ');\n+  var regExp = /#[^#\\s]{1,18}/i;\n+  var errorMessages = [\n+    '1. хэш-тег начинается с символа # (решётка)',\n+    '2. хеш-тег не может состоять только из одной решётки',\n+    '3. хэш-теги разделяются пробелами',\n+    '4. максимальная длина одного хэш-тега 20 символов, включая решётку'\n+  ];\n+  for (var i = 0; i < array.length; i++) {\n+    if (array[i].search(regExp)) {\n+      message = element.setCustomValidity(errorMessages.join('\\n'));\n+    } else {\n+      message = true;\n+    }\n+  }\n+  return message;\n+};\n+\n+var checkHashTagValidity = function (element) {\n+  if (checkHashTagQuantity(element) && checkDuplicates(element) && checkHashTags(element)) {","path":"js/pictures.js","position":99,"original_position":99,"commit_id":"1b6156bbf0a38346dcc992001a8790f0bf62a032","original_commit_id":"1b6156bbf0a38346dcc992001a8790f0bf62a032","user":{"login":"Siri0n","id":5023794,"node_id":"MDQ6VXNlcjUwMjM3OTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5023794?v=4","gravatar_id":"","url":"https://api.github.com/users/Siri0n","html_url":"https://github.com/Siri0n","followers_url":"https://api.github.com/users/Siri0n/followers","following_url":"https://api.github.com/users/Siri0n/following{/other_user}","gists_url":"https://api.github.com/users/Siri0n/gists{/gist_id}","starred_url":"https://api.github.com/users/Siri0n/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Siri0n/subscriptions","organizations_url":"https://api.github.com/users/Siri0n/orgs","repos_url":"https://api.github.com/users/Siri0n/repos","events_url":"https://api.github.com/users/Siri0n/events{/privacy}","received_events_url":"https://api.github.com/users/Siri0n/received_events","type":"User","site_admin":false},"body":"Более изящно было бы переписать это знаешь как? Смотри. Можно сделать так, что функции check принимают в качестве аргумента массив тегов и возвращают сообщение об ошибке. Если ошибки нет, то пустую строку. Тогда можно переписать следующим образом:\r\n```javascript\r\nvar tags = element.value.trim().split(/\\s+/);\r\nvar errorMessage = checkHashTagQuantity(element) || checkDuplicates(element) || checkHashTags(element);\r\nelement.setCustomValidity(errorMessage);\r\n```","created_at":"2018-06-20T21:34:05Z","updated_at":"2018-06-20T21:37:10Z","html_url":"https://github.com/htmlacademy-javascript/509275-kekstagram/pull/4#discussion_r196950011","pull_request_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/pulls/4","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/pulls/comments/196950011"},"html":{"href":"https://github.com/htmlacademy-javascript/509275-kekstagram/pull/4#discussion_r196950011"},"pull_request":{"href":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/pulls/4","id":196147297,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2MTQ3Mjk3","html_url":"https://github.com/htmlacademy-javascript/509275-kekstagram/pull/4","diff_url":"https://github.com/htmlacademy-javascript/509275-kekstagram/pull/4.diff","patch_url":"https://github.com/htmlacademy-javascript/509275-kekstagram/pull/4.patch","issue_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/issues/4","number":4,"state":"open","locked":false,"title":"Личный проект: доверяй, но проверяй","user":{"login":"OlegOschepkov","id":36763883,"node_id":"MDQ6VXNlcjM2NzYzODgz","avatar_url":"https://avatars1.githubusercontent.com/u/36763883?v=4","gravatar_id":"","url":"https://api.github.com/users/OlegOschepkov","html_url":"https://github.com/OlegOschepkov","followers_url":"https://api.github.com/users/OlegOschepkov/followers","following_url":"https://api.github.com/users/OlegOschepkov/following{/other_user}","gists_url":"https://api.github.com/users/OlegOschepkov/gists{/gist_id}","starred_url":"https://api.github.com/users/OlegOschepkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OlegOschepkov/subscriptions","organizations_url":"https://api.github.com/users/OlegOschepkov/orgs","repos_url":"https://api.github.com/users/OlegOschepkov/repos","events_url":"https://api.github.com/users/OlegOschepkov/events{/privacy}","received_events_url":"https://api.github.com/users/OlegOschepkov/received_events","type":"User","site_admin":false},"body":"Вадим, функция checkHashTags некрасиво сообщения выводит, как поправить можно?\n\n---\n:mortar_board: [Личный проект: доверяй, но проверяй](https://up.htmlacademy.ru/javascript/14/user/509275/tasks/16)\n\n:boom: https://htmlacademy-javascript.github.io/509275-kekstagram/4/","created_at":"2018-06-20T13:51:01Z","updated_at":"2018-06-20T21:37:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9018bfb69c9e4b6ca52cd97f702363fa9554bc32","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/pulls/4/commits","review_comments_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/pulls/4/comments","review_comment_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/pulls/comments{/number}","comments_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/issues/4/comments","statuses_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/statuses/1b6156bbf0a38346dcc992001a8790f0bf62a032","head":{"label":"OlegOschepkov:module4-task2","ref":"module4-task2","sha":"1b6156bbf0a38346dcc992001a8790f0bf62a032","user":{"login":"OlegOschepkov","id":36763883,"node_id":"MDQ6VXNlcjM2NzYzODgz","avatar_url":"https://avatars1.githubusercontent.com/u/36763883?v=4","gravatar_id":"","url":"https://api.github.com/users/OlegOschepkov","html_url":"https://github.com/OlegOschepkov","followers_url":"https://api.github.com/users/OlegOschepkov/followers","following_url":"https://api.github.com/users/OlegOschepkov/following{/other_user}","gists_url":"https://api.github.com/users/OlegOschepkov/gists{/gist_id}","starred_url":"https://api.github.com/users/OlegOschepkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OlegOschepkov/subscriptions","organizations_url":"https://api.github.com/users/OlegOschepkov/orgs","repos_url":"https://api.github.com/users/OlegOschepkov/repos","events_url":"https://api.github.com/users/OlegOschepkov/events{/privacy}","received_events_url":"https://api.github.com/users/OlegOschepkov/received_events","type":"User","site_admin":false},"repo":{"id":135347930,"node_id":"MDEwOlJlcG9zaXRvcnkxMzUzNDc5MzA=","name":"509275-kekstagram","full_name":"OlegOschepkov/509275-kekstagram","owner":{"login":"OlegOschepkov","id":36763883,"node_id":"MDQ6VXNlcjM2NzYzODgz","avatar_url":"https://avatars1.githubusercontent.com/u/36763883?v=4","gravatar_id":"","url":"https://api.github.com/users/OlegOschepkov","html_url":"https://github.com/OlegOschepkov","followers_url":"https://api.github.com/users/OlegOschepkov/followers","following_url":"https://api.github.com/users/OlegOschepkov/following{/other_user}","gists_url":"https://api.github.com/users/OlegOschepkov/gists{/gist_id}","starred_url":"https://api.github.com/users/OlegOschepkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OlegOschepkov/subscriptions","organizations_url":"https://api.github.com/users/OlegOschepkov/orgs","repos_url":"https://api.github.com/users/OlegOschepkov/repos","events_url":"https://api.github.com/users/OlegOschepkov/events{/privacy}","received_events_url":"https://api.github.com/users/OlegOschepkov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/OlegOschepkov/509275-kekstagram","description":"Олег Ощепков","fork":true,"url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram","forks_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/forks","keys_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/teams","hooks_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/hooks","issue_events_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/issues/events{/number}","events_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/events","assignees_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/assignees{/user}","branches_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/branches{/branch}","tags_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/tags","blobs_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/git/refs{/sha}","trees_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/statuses/{sha}","languages_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/languages","stargazers_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/stargazers","contributors_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/contributors","subscribers_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/subscribers","subscription_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/subscription","commits_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/commits{/sha}","git_commits_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/git/commits{/sha}","comments_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/comments{/number}","issue_comment_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/issues/comments{/number}","contents_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/contents/{+path}","compare_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/merges","archive_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/downloads","issues_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/issues{/number}","pulls_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/pulls{/number}","milestones_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/milestones{/number}","notifications_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/labels{/name}","releases_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/releases{/id}","deployments_url":"https://api.github.com/repos/OlegOschepkov/509275-kekstagram/deployments","created_at":"2018-05-29T20:12:36Z","updated_at":"2018-06-20T16:37:15Z","pushed_at":"2018-06-20T17:55:58Z","git_url":"git://github.com/OlegOschepkov/509275-kekstagram.git","ssh_url":"git@github.com:OlegOschepkov/509275-kekstagram.git","clone_url":"https://github.com/OlegOschepkov/509275-kekstagram.git","svn_url":"https://github.com/OlegOschepkov/509275-kekstagram","homepage":null,"size":2218,"stargazers_count":0,"watchers_count":0,"language":"CSS","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":"7204b0c5a58d7ee82d97ae16c577ebda5685e96b","user":{"login":"htmlacademy-javascript","id":14179712,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MTc5NzEy","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":135341228,"node_id":"MDEwOlJlcG9zaXRvcnkxMzUzNDEyMjg=","name":"509275-kekstagram","full_name":"htmlacademy-javascript/509275-kekstagram","owner":{"login":"htmlacademy-javascript","id":14179712,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MTc5NzEy","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/509275-kekstagram","description":"Олег Ощепков","fork":false,"url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram","forks_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/forks","keys_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/keys{/key_id}","collaborators_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/teams","hooks_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/hooks","issue_events_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/issues/events{/number}","events_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/events","assignees_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/assignees{/user}","branches_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/branches{/branch}","tags_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/tags","blobs_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/git/refs{/sha}","trees_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/git/trees{/sha}","statuses_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/statuses/{sha}","languages_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/languages","stargazers_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/stargazers","contributors_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/contributors","subscribers_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/subscribers","subscription_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/subscription","commits_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/commits{/sha}","git_commits_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/git/commits{/sha}","comments_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/comments{/number}","issue_comment_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/issues/comments{/number}","contents_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/contents/{+path}","compare_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/compare/{base}...{head}","merges_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/merges","archive_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/downloads","issues_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/issues{/number}","pulls_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/pulls{/number}","milestones_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/milestones{/number}","notifications_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/labels{/name}","releases_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/releases{/id}","deployments_url":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/deployments","created_at":"2018-05-29T19:06:23Z","updated_at":"2018-06-18T20:31:25Z","pushed_at":"2018-06-20T20:46:41Z","git_url":"git://github.com/htmlacademy-javascript/509275-kekstagram.git","ssh_url":"git@github.com:htmlacademy-javascript/509275-kekstagram.git","clone_url":"https://github.com/htmlacademy-javascript/509275-kekstagram.git","svn_url":"https://github.com/htmlacademy-javascript/509275-kekstagram","homepage":"https://github.com/OlegOschepkov/509275-kekstagram","size":2229,"stargazers_count":0,"watchers_count":0,"language":"CSS","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/509275-kekstagram/pulls/4"},"html":{"href":"https://github.com/htmlacademy-javascript/509275-kekstagram/pull/4"},"issue":{"href":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/issues/4"},"comments":{"href":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/htmlacademy-javascript/509275-kekstagram/statuses/1b6156bbf0a38346dcc992001a8790f0bf62a032"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Siri0n"}}