{"action":"created","comment":{"url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/pulls/comments/76612695","id":76612695,"diff_hunk":"@@ -22,38 +19,85 @@ var reviewClone = (reviewTemplate.content || reviewTemplate).querySelector('.rev\n  */\n \n /**\n- * добавляет отзыв\n- * @param {ReviewData} data отзыв\n+ * конструктор объекта Review\n+ * @param {ReviewData} data\n+ * @constructor\n  */\n-function addReview(data) {\n-  var review = reviewClone.cloneNode(true);\n-  var reviewImage = review.querySelector('.review-author');\n-  var reviewRating = review.querySelector('.review-rating');\n-  var reviewDescription = review.querySelector('.review-text');\n+var Review = function(data) {\n+  var reviewTemplate = document.getElementById('review-template');\n+  var reviewClone = (reviewTemplate.content || reviewTemplate).querySelector('.review');\n+\n+  this.data = data;\n+  this.review = reviewClone.cloneNode(true);\n+  this.reviewDescription = this.review.querySelector('.review-text');\n+  this.reviewImage = this.review.querySelector('.review-author');\n+  this.reviewRating = this.review.querySelector('.review-rating');\n+  this.reviewQuizAnswerYes = this.review.querySelector('.review-quiz-answer-yes');\n+  this.reviewQuizAnswerNo = this.review.querySelector('.review-quiz-answer-no');\n+  this.setAnswerYes = this.setQuizAnswer.bind(this, true);\n+  this.setAnswerNo = this.setQuizAnswer.bind(this, false);\n+\n+  this.reviewDescription.textContent = this.data.description;\n+  this.setRating(this.data.rating);\n+  this.loadImage(this.data.author.picture);\n+\n+  this.element = this.review;\n+\n+  this.reviewQuizAnswerYes.addEventListener('click', this.setAnswerYes);\n+  this.reviewQuizAnswerNo.addEventListener('click', this.setAnswerNo);\n+};\n+\n+/**\n+ * устанавливает рейтинг\n+ * @param {number} number\n+ */\n+Review.prototype.setRating = function(number) {\n   var ratings = {\n     2: 'two',\n     3: 'three',\n     4: 'four',\n     5: 'five'\n   };\n \n-  if (ratings[data.rating]) {\n-    reviewRating.classList.add('review-rating-' + ratings[data.rating]);\n+  if (ratings[number]) {\n+    this.reviewRating.classList.add('review-rating-' + ratings[number]);\n   }\n-  reviewDescription.textContent = data.description;\n+};\n \n-  utils.loadImage(data.author.picture, function(isOk) {\n-    if (isOk) {\n-      reviewImage.src += data.author.picture;\n-      reviewImage.width = '124px';\n-      reviewImage.height = '124px';\n+/**\n+ * загружает изображение\n+ * @param {string} pictureUrl\n+ */\n+Review.prototype.loadImage = function(pictureUrl) {\n+  var isOk = function(isLoad) {\n+    if (isLoad) {\n+      this.reviewImage.src += pictureUrl;\n+      this.reviewImage.width = '124px';\n+      this.reviewImage.height = '124px';\n     } else {\n-      reviewImage.src = '';\n-      review.classList.add('review-load-failure');\n+      this.reviewImage.src = '';\n+      this.review.classList.add('review-load-failure');","path":"src/review.js","position":88,"original_position":88,"commit_id":"bb386d80e6299fa0bb31095a1a0f6e14bb3fb5cd","original_commit_id":"bb386d80e6299fa0bb31095a1a0f6e14bb3fb5cd","user":{"login":"isqua","id":529247,"avatar_url":"https://avatars.githubusercontent.com/u/529247?v=3","gravatar_id":"","url":"https://api.github.com/users/isqua","html_url":"https://github.com/isqua","followers_url":"https://api.github.com/users/isqua/followers","following_url":"https://api.github.com/users/isqua/following{/other_user}","gists_url":"https://api.github.com/users/isqua/gists{/gist_id}","starred_url":"https://api.github.com/users/isqua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isqua/subscriptions","organizations_url":"https://api.github.com/users/isqua/orgs","repos_url":"https://api.github.com/users/isqua/repos","events_url":"https://api.github.com/users/isqua/events{/privacy}","received_events_url":"https://api.github.com/users/isqua/received_events","type":"User","site_admin":false},"body":"И вот этот класс.","created_at":"2016-08-29T14:07:35Z","updated_at":"2016-08-29T14:07:35Z","html_url":"https://github.com/htmlacademy-javascript/151188-code-and-magick/pull/14#discussion_r76612695","pull_request_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/pulls/comments/76612695"},"html":{"href":"https://github.com/htmlacademy-javascript/151188-code-and-magick/pull/14#discussion_r76612695"},"pull_request":{"href":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/pulls/14","id":83098271,"html_url":"https://github.com/htmlacademy-javascript/151188-code-and-magick/pull/14","diff_url":"https://github.com/htmlacademy-javascript/151188-code-and-magick/pull/14.diff","patch_url":"https://github.com/htmlacademy-javascript/151188-code-and-magick/pull/14.patch","issue_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/issues/14","number":14,"state":"open","locked":false,"title":"Второй класс","user":{"login":"rustamyusupov","id":16702553,"avatar_url":"https://avatars.githubusercontent.com/u/16702553?v=3","gravatar_id":"","url":"https://api.github.com/users/rustamyusupov","html_url":"https://github.com/rustamyusupov","followers_url":"https://api.github.com/users/rustamyusupov/followers","following_url":"https://api.github.com/users/rustamyusupov/following{/other_user}","gists_url":"https://api.github.com/users/rustamyusupov/gists{/gist_id}","starred_url":"https://api.github.com/users/rustamyusupov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rustamyusupov/subscriptions","organizations_url":"https://api.github.com/users/rustamyusupov/orgs","repos_url":"https://api.github.com/users/rustamyusupov/repos","events_url":"https://api.github.com/users/rustamyusupov/events{/privacy}","received_events_url":"https://api.github.com/users/rustamyusupov/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-29T13:25:30Z","updated_at":"2016-08-29T14:07:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"79290917f6e14264fb14d998de1816842688f016","assignee":{"login":"isqua","id":529247,"avatar_url":"https://avatars.githubusercontent.com/u/529247?v=3","gravatar_id":"","url":"https://api.github.com/users/isqua","html_url":"https://github.com/isqua","followers_url":"https://api.github.com/users/isqua/followers","following_url":"https://api.github.com/users/isqua/following{/other_user}","gists_url":"https://api.github.com/users/isqua/gists{/gist_id}","starred_url":"https://api.github.com/users/isqua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isqua/subscriptions","organizations_url":"https://api.github.com/users/isqua/orgs","repos_url":"https://api.github.com/users/isqua/repos","events_url":"https://api.github.com/users/isqua/events{/privacy}","received_events_url":"https://api.github.com/users/isqua/received_events","type":"User","site_admin":false},"assignees":[{"login":"isqua","id":529247,"avatar_url":"https://avatars.githubusercontent.com/u/529247?v=3","gravatar_id":"","url":"https://api.github.com/users/isqua","html_url":"https://github.com/isqua","followers_url":"https://api.github.com/users/isqua/followers","following_url":"https://api.github.com/users/isqua/following{/other_user}","gists_url":"https://api.github.com/users/isqua/gists{/gist_id}","starred_url":"https://api.github.com/users/isqua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isqua/subscriptions","organizations_url":"https://api.github.com/users/isqua/orgs","repos_url":"https://api.github.com/users/isqua/repos","events_url":"https://api.github.com/users/isqua/events{/privacy}","received_events_url":"https://api.github.com/users/isqua/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/pulls/14/commits","review_comments_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/pulls/14/comments","review_comment_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/pulls/comments{/number}","comments_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/issues/14/comments","statuses_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/statuses/bb386d80e6299fa0bb31095a1a0f6e14bb3fb5cd","head":{"label":"rustamyusupov:module6-task2","ref":"module6-task2","sha":"bb386d80e6299fa0bb31095a1a0f6e14bb3fb5cd","user":{"login":"rustamyusupov","id":16702553,"avatar_url":"https://avatars.githubusercontent.com/u/16702553?v=3","gravatar_id":"","url":"https://api.github.com/users/rustamyusupov","html_url":"https://github.com/rustamyusupov","followers_url":"https://api.github.com/users/rustamyusupov/followers","following_url":"https://api.github.com/users/rustamyusupov/following{/other_user}","gists_url":"https://api.github.com/users/rustamyusupov/gists{/gist_id}","starred_url":"https://api.github.com/users/rustamyusupov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rustamyusupov/subscriptions","organizations_url":"https://api.github.com/users/rustamyusupov/orgs","repos_url":"https://api.github.com/users/rustamyusupov/repos","events_url":"https://api.github.com/users/rustamyusupov/events{/privacy}","received_events_url":"https://api.github.com/users/rustamyusupov/received_events","type":"User","site_admin":false},"repo":{"id":64854365,"name":"151188-code-and-magick","full_name":"rustamyusupov/151188-code-and-magick","owner":{"login":"rustamyusupov","id":16702553,"avatar_url":"https://avatars.githubusercontent.com/u/16702553?v=3","gravatar_id":"","url":"https://api.github.com/users/rustamyusupov","html_url":"https://github.com/rustamyusupov","followers_url":"https://api.github.com/users/rustamyusupov/followers","following_url":"https://api.github.com/users/rustamyusupov/following{/other_user}","gists_url":"https://api.github.com/users/rustamyusupov/gists{/gist_id}","starred_url":"https://api.github.com/users/rustamyusupov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rustamyusupov/subscriptions","organizations_url":"https://api.github.com/users/rustamyusupov/orgs","repos_url":"https://api.github.com/users/rustamyusupov/repos","events_url":"https://api.github.com/users/rustamyusupov/events{/privacy}","received_events_url":"https://api.github.com/users/rustamyusupov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rustamyusupov/151188-code-and-magick","description":"Rustam Yusupov","fork":true,"url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick","forks_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/forks","keys_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/teams","hooks_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/hooks","issue_events_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/issues/events{/number}","events_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/events","assignees_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/assignees{/user}","branches_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/branches{/branch}","tags_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/tags","blobs_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/git/refs{/sha}","trees_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/statuses/{sha}","languages_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/languages","stargazers_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/stargazers","contributors_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/contributors","subscribers_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/subscribers","subscription_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/subscription","commits_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/commits{/sha}","git_commits_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/git/commits{/sha}","comments_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/comments{/number}","issue_comment_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/issues/comments{/number}","contents_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/contents/{+path}","compare_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/merges","archive_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/downloads","issues_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/issues{/number}","pulls_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/pulls{/number}","milestones_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/milestones{/number}","notifications_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/labels{/name}","releases_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/releases{/id}","deployments_url":"https://api.github.com/repos/rustamyusupov/151188-code-and-magick/deployments","created_at":"2016-08-03T14:52:49Z","updated_at":"2016-08-03T14:52:50Z","pushed_at":"2016-08-29T13:57:27Z","git_url":"git://github.com/rustamyusupov/151188-code-and-magick.git","ssh_url":"git@github.com:rustamyusupov/151188-code-and-magick.git","clone_url":"https://github.com/rustamyusupov/151188-code-and-magick.git","svn_url":"https://github.com/rustamyusupov/151188-code-and-magick","homepage":null,"size":1486,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"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":"2d35c5edd2202023143c8aefd5ee60faed3f94f0","user":{"login":"htmlacademy-javascript","id":14179712,"avatar_url":"https://avatars.githubusercontent.com/u/14179712?v=3","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":64853014,"name":"151188-code-and-magick","full_name":"htmlacademy-javascript/151188-code-and-magick","owner":{"login":"htmlacademy-javascript","id":14179712,"avatar_url":"https://avatars.githubusercontent.com/u/14179712?v=3","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/151188-code-and-magick","description":"Rustam Yusupov","fork":false,"url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick","forks_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/forks","keys_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/keys{/key_id}","collaborators_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/teams","hooks_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/hooks","issue_events_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/issues/events{/number}","events_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/events","assignees_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/assignees{/user}","branches_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/branches{/branch}","tags_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/tags","blobs_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/git/refs{/sha}","trees_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/git/trees{/sha}","statuses_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/statuses/{sha}","languages_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/languages","stargazers_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/stargazers","contributors_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/contributors","subscribers_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/subscribers","subscription_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/subscription","commits_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/commits{/sha}","git_commits_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/git/commits{/sha}","comments_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/comments{/number}","issue_comment_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/issues/comments{/number}","contents_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/contents/{+path}","compare_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/compare/{base}...{head}","merges_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/merges","archive_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/downloads","issues_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/issues{/number}","pulls_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/pulls{/number}","milestones_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/milestones{/number}","notifications_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/labels{/name}","releases_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/releases{/id}","deployments_url":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/deployments","created_at":"2016-08-03T14:34:50Z","updated_at":"2016-08-03T15:08:54Z","pushed_at":"2016-08-29T13:57:27Z","git_url":"git://github.com/htmlacademy-javascript/151188-code-and-magick.git","ssh_url":"git@github.com:htmlacademy-javascript/151188-code-and-magick.git","clone_url":"https://github.com/htmlacademy-javascript/151188-code-and-magick.git","svn_url":"https://github.com/htmlacademy-javascript/151188-code-and-magick","homepage":"https://github.com/rustamyusupov/151188-code-and-magick","size":1558,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"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/151188-code-and-magick/pulls/14"},"html":{"href":"https://github.com/htmlacademy-javascript/151188-code-and-magick/pull/14"},"issue":{"href":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/issues/14"},"comments":{"href":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/htmlacademy-javascript/151188-code-and-magick/statuses/bb386d80e6299fa0bb31095a1a0f6e14bb3fb5cd"}}}}
{"actor":{"display_login":"isqua"}}