{"action":"created","comment":{"url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/pulls/comments/47612296","id":47612296,"diff_hunk":"@@ -6,13 +5,83 @@\n   var filters = document.querySelector('.filters');\n   var container = document.querySelector('.pictures');\n   var template = document.querySelector('#picture-template');\n+  var activeFilter = null;\n+  var pictures = [];\n+\n+  var filtersList = document.querySelectorAll('.filters-radio');\n+  for (var i = 0; i < filtersList.length; i++) {\n+    filtersList[i].onclick = function(evt) {\n+      var clickedElementID = evt.target.id;\n+      setActiveFilter(clickedElementID);\n+    };\n+  }\n \n   filters.classList.add('hidden');\n+  getPictures();\n+\n+  function renderPictures(picturesToRender) {\n+    container.innerHTML = '';\n+    var fragment = document.createDocumentFragment();\n+\n+    picturesToRender.forEach(function(picture) {\n+      var element = getElementFromTemplate(picture);\n+      fragment.appendChild(element);\n+    });\n+\n+    container.appendChild(fragment);\n+  }\n+\n+  function setActiveFilter(id) {\n+    if (activeFilter === id) {\n+      return;\n+    }\n+\n+    var filteredPictures = pictures.slice(0);\n \n-  pictures.forEach(function(picture) {\n-    var element = getElementFromTemplate(picture);\n-    container.appendChild(element);\n-  });\n+    switch (id) {\n+      case 'filter-popular':\n+        filteredPictures = filteredPictures.sort(function(a, b) {\n+          return b.likes - a.likes;\n+        });\n+        break;\n+\n+      case 'filter-new':\n+        filteredPictures = filteredPictures.sort(function(a, b) {\n+          return b.date - a.date;\n+        });","path":"js/pictures.js","position":56,"original_position":56,"commit_id":"77f101506bf5aa03d5c19b41c381d0f3b82e6336","original_commit_id":"77f101506bf5aa03d5c19b41c381d0f3b82e6336","user":{"login":"ekirill","id":1984189,"avatar_url":"https://avatars.githubusercontent.com/u/1984189?v=3","gravatar_id":"","url":"https://api.github.com/users/ekirill","html_url":"https://github.com/ekirill","followers_url":"https://api.github.com/users/ekirill/followers","following_url":"https://api.github.com/users/ekirill/following{/other_user}","gists_url":"https://api.github.com/users/ekirill/gists{/gist_id}","starred_url":"https://api.github.com/users/ekirill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ekirill/subscriptions","organizations_url":"https://api.github.com/users/ekirill/orgs","repos_url":"https://api.github.com/users/ekirill/repos","events_url":"https://api.github.com/users/ekirill/events{/privacy}","received_events_url":"https://api.github.com/users/ekirill/received_events","type":"User","site_admin":false},"body":"забыл отфильтровать картинки старше 3х месяцев","created_at":"2015-12-15T09:13:17Z","updated_at":"2015-12-15T09:13:17Z","html_url":"https://github.com/js-htmlacademy/97423-keksogram/pull/7#discussion_r47612296","pull_request_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/pulls/comments/47612296"},"html":{"href":"https://github.com/js-htmlacademy/97423-keksogram/pull/7#discussion_r47612296"},"pull_request":{"href":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/pulls/7","id":53150435,"html_url":"https://github.com/js-htmlacademy/97423-keksogram/pull/7","diff_url":"https://github.com/js-htmlacademy/97423-keksogram/pull/7.diff","patch_url":"https://github.com/js-htmlacademy/97423-keksogram/pull/7.patch","issue_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/issues/7","number":7,"state":"open","locked":false,"title":"Робкое знакомство с AJAX","user":{"login":"klhz1","id":14335590,"avatar_url":"https://avatars.githubusercontent.com/u/14335590?v=3","gravatar_id":"","url":"https://api.github.com/users/klhz1","html_url":"https://github.com/klhz1","followers_url":"https://api.github.com/users/klhz1/followers","following_url":"https://api.github.com/users/klhz1/following{/other_user}","gists_url":"https://api.github.com/users/klhz1/gists{/gist_id}","starred_url":"https://api.github.com/users/klhz1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klhz1/subscriptions","organizations_url":"https://api.github.com/users/klhz1/orgs","repos_url":"https://api.github.com/users/klhz1/repos","events_url":"https://api.github.com/users/klhz1/events{/privacy}","received_events_url":"https://api.github.com/users/klhz1/received_events","type":"User","site_admin":false},"body":"\n\n--\n:boom: https://js-htmlacademy.github.io/97423-keksogram/7/","created_at":"2015-12-09T17:24:05Z","updated_at":"2015-12-15T09:13:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cae9d554f20ed3f155066e2310e0ce1b65d09768","assignee":{"login":"ekirill","id":1984189,"avatar_url":"https://avatars.githubusercontent.com/u/1984189?v=3","gravatar_id":"","url":"https://api.github.com/users/ekirill","html_url":"https://github.com/ekirill","followers_url":"https://api.github.com/users/ekirill/followers","following_url":"https://api.github.com/users/ekirill/following{/other_user}","gists_url":"https://api.github.com/users/ekirill/gists{/gist_id}","starred_url":"https://api.github.com/users/ekirill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ekirill/subscriptions","organizations_url":"https://api.github.com/users/ekirill/orgs","repos_url":"https://api.github.com/users/ekirill/repos","events_url":"https://api.github.com/users/ekirill/events{/privacy}","received_events_url":"https://api.github.com/users/ekirill/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/pulls/7/commits","review_comments_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/pulls/7/comments","review_comment_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/pulls/comments{/number}","comments_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/issues/7/comments","statuses_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/statuses/77f101506bf5aa03d5c19b41c381d0f3b82e6336","head":{"label":"klhz1:module5-task1","ref":"module5-task1","sha":"77f101506bf5aa03d5c19b41c381d0f3b82e6336","user":{"login":"klhz1","id":14335590,"avatar_url":"https://avatars.githubusercontent.com/u/14335590?v=3","gravatar_id":"","url":"https://api.github.com/users/klhz1","html_url":"https://github.com/klhz1","followers_url":"https://api.github.com/users/klhz1/followers","following_url":"https://api.github.com/users/klhz1/following{/other_user}","gists_url":"https://api.github.com/users/klhz1/gists{/gist_id}","starred_url":"https://api.github.com/users/klhz1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klhz1/subscriptions","organizations_url":"https://api.github.com/users/klhz1/orgs","repos_url":"https://api.github.com/users/klhz1/repos","events_url":"https://api.github.com/users/klhz1/events{/privacy}","received_events_url":"https://api.github.com/users/klhz1/received_events","type":"User","site_admin":false},"repo":{"id":45932271,"name":"97423-keksogram","full_name":"klhz1/97423-keksogram","owner":{"login":"klhz1","id":14335590,"avatar_url":"https://avatars.githubusercontent.com/u/14335590?v=3","gravatar_id":"","url":"https://api.github.com/users/klhz1","html_url":"https://github.com/klhz1","followers_url":"https://api.github.com/users/klhz1/followers","following_url":"https://api.github.com/users/klhz1/following{/other_user}","gists_url":"https://api.github.com/users/klhz1/gists{/gist_id}","starred_url":"https://api.github.com/users/klhz1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klhz1/subscriptions","organizations_url":"https://api.github.com/users/klhz1/orgs","repos_url":"https://api.github.com/users/klhz1/repos","events_url":"https://api.github.com/users/klhz1/events{/privacy}","received_events_url":"https://api.github.com/users/klhz1/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/klhz1/97423-keksogram","description":"Anatolijs Vahterovs","fork":true,"url":"https://api.github.com/repos/klhz1/97423-keksogram","forks_url":"https://api.github.com/repos/klhz1/97423-keksogram/forks","keys_url":"https://api.github.com/repos/klhz1/97423-keksogram/keys{/key_id}","collaborators_url":"https://api.github.com/repos/klhz1/97423-keksogram/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/klhz1/97423-keksogram/teams","hooks_url":"https://api.github.com/repos/klhz1/97423-keksogram/hooks","issue_events_url":"https://api.github.com/repos/klhz1/97423-keksogram/issues/events{/number}","events_url":"https://api.github.com/repos/klhz1/97423-keksogram/events","assignees_url":"https://api.github.com/repos/klhz1/97423-keksogram/assignees{/user}","branches_url":"https://api.github.com/repos/klhz1/97423-keksogram/branches{/branch}","tags_url":"https://api.github.com/repos/klhz1/97423-keksogram/tags","blobs_url":"https://api.github.com/repos/klhz1/97423-keksogram/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/klhz1/97423-keksogram/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/klhz1/97423-keksogram/git/refs{/sha}","trees_url":"https://api.github.com/repos/klhz1/97423-keksogram/git/trees{/sha}","statuses_url":"https://api.github.com/repos/klhz1/97423-keksogram/statuses/{sha}","languages_url":"https://api.github.com/repos/klhz1/97423-keksogram/languages","stargazers_url":"https://api.github.com/repos/klhz1/97423-keksogram/stargazers","contributors_url":"https://api.github.com/repos/klhz1/97423-keksogram/contributors","subscribers_url":"https://api.github.com/repos/klhz1/97423-keksogram/subscribers","subscription_url":"https://api.github.com/repos/klhz1/97423-keksogram/subscription","commits_url":"https://api.github.com/repos/klhz1/97423-keksogram/commits{/sha}","git_commits_url":"https://api.github.com/repos/klhz1/97423-keksogram/git/commits{/sha}","comments_url":"https://api.github.com/repos/klhz1/97423-keksogram/comments{/number}","issue_comment_url":"https://api.github.com/repos/klhz1/97423-keksogram/issues/comments{/number}","contents_url":"https://api.github.com/repos/klhz1/97423-keksogram/contents/{+path}","compare_url":"https://api.github.com/repos/klhz1/97423-keksogram/compare/{base}...{head}","merges_url":"https://api.github.com/repos/klhz1/97423-keksogram/merges","archive_url":"https://api.github.com/repos/klhz1/97423-keksogram/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/klhz1/97423-keksogram/downloads","issues_url":"https://api.github.com/repos/klhz1/97423-keksogram/issues{/number}","pulls_url":"https://api.github.com/repos/klhz1/97423-keksogram/pulls{/number}","milestones_url":"https://api.github.com/repos/klhz1/97423-keksogram/milestones{/number}","notifications_url":"https://api.github.com/repos/klhz1/97423-keksogram/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/klhz1/97423-keksogram/labels{/name}","releases_url":"https://api.github.com/repos/klhz1/97423-keksogram/releases{/id}","created_at":"2015-11-10T18:35:44Z","updated_at":"2015-11-10T18:35:45Z","pushed_at":"2015-12-14T22:41:54Z","git_url":"git://github.com/klhz1/97423-keksogram.git","ssh_url":"git@github.com:klhz1/97423-keksogram.git","clone_url":"https://github.com/klhz1/97423-keksogram.git","svn_url":"https://github.com/klhz1/97423-keksogram","homepage":null,"size":3779,"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":"js-htmlacademy:master","ref":"master","sha":"541f0457cf6b22706f68e0aa310df6d93a49464f","user":{"login":"js-htmlacademy","id":14179712,"avatar_url":"https://avatars.githubusercontent.com/u/14179712?v=3","gravatar_id":"","url":"https://api.github.com/users/js-htmlacademy","html_url":"https://github.com/js-htmlacademy","followers_url":"https://api.github.com/users/js-htmlacademy/followers","following_url":"https://api.github.com/users/js-htmlacademy/following{/other_user}","gists_url":"https://api.github.com/users/js-htmlacademy/gists{/gist_id}","starred_url":"https://api.github.com/users/js-htmlacademy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/js-htmlacademy/subscriptions","organizations_url":"https://api.github.com/users/js-htmlacademy/orgs","repos_url":"https://api.github.com/users/js-htmlacademy/repos","events_url":"https://api.github.com/users/js-htmlacademy/events{/privacy}","received_events_url":"https://api.github.com/users/js-htmlacademy/received_events","type":"Organization","site_admin":false},"repo":{"id":45931954,"name":"97423-keksogram","full_name":"js-htmlacademy/97423-keksogram","owner":{"login":"js-htmlacademy","id":14179712,"avatar_url":"https://avatars.githubusercontent.com/u/14179712?v=3","gravatar_id":"","url":"https://api.github.com/users/js-htmlacademy","html_url":"https://github.com/js-htmlacademy","followers_url":"https://api.github.com/users/js-htmlacademy/followers","following_url":"https://api.github.com/users/js-htmlacademy/following{/other_user}","gists_url":"https://api.github.com/users/js-htmlacademy/gists{/gist_id}","starred_url":"https://api.github.com/users/js-htmlacademy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/js-htmlacademy/subscriptions","organizations_url":"https://api.github.com/users/js-htmlacademy/orgs","repos_url":"https://api.github.com/users/js-htmlacademy/repos","events_url":"https://api.github.com/users/js-htmlacademy/events{/privacy}","received_events_url":"https://api.github.com/users/js-htmlacademy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/js-htmlacademy/97423-keksogram","description":"Anatolijs Vahterovs","fork":false,"url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram","forks_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/forks","keys_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/keys{/key_id}","collaborators_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/teams","hooks_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/hooks","issue_events_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/issues/events{/number}","events_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/events","assignees_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/assignees{/user}","branches_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/branches{/branch}","tags_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/tags","blobs_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/git/refs{/sha}","trees_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/git/trees{/sha}","statuses_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/statuses/{sha}","languages_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/languages","stargazers_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/stargazers","contributors_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/contributors","subscribers_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/subscribers","subscription_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/subscription","commits_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/commits{/sha}","git_commits_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/git/commits{/sha}","comments_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/comments{/number}","issue_comment_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/issues/comments{/number}","contents_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/contents/{+path}","compare_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/compare/{base}...{head}","merges_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/merges","archive_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/downloads","issues_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/issues{/number}","pulls_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/pulls{/number}","milestones_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/milestones{/number}","notifications_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/labels{/name}","releases_url":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/releases{/id}","created_at":"2015-11-10T18:30:12Z","updated_at":"2015-11-12T21:55:14Z","pushed_at":"2015-12-14T22:44:10Z","git_url":"git://github.com/js-htmlacademy/97423-keksogram.git","ssh_url":"git@github.com:js-htmlacademy/97423-keksogram.git","clone_url":"https://github.com/js-htmlacademy/97423-keksogram.git","svn_url":"https://github.com/js-htmlacademy/97423-keksogram","homepage":"https://github.com/klhz1/97423-keksogram","size":3786,"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/js-htmlacademy/97423-keksogram/pulls/7"},"html":{"href":"https://github.com/js-htmlacademy/97423-keksogram/pull/7"},"issue":{"href":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/issues/7"},"comments":{"href":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/js-htmlacademy/97423-keksogram/statuses/77f101506bf5aa03d5c19b41c381d0f3b82e6336"}}}}