{"action":"created","comment":{"url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/pulls/comments/46813732","id":46813732,"diff_hunk":"@@ -2,5 +2,91 @@\n \n // Получаем комбинации элементов\n var formulas = window.formulas;\n+var cauldron = document.getElementById('cauldron');\n+var components = document.getElementById('components');\n+var filter = document.getElementById('filter');\n \n-// Механизмы котла описывать здесь\n+filter.onkeyup = filterElements;\n+filter.onclick = checkClearFilter;\n+\n+Array.prototype.forEach.call(components.children, function (child) {\n+    child.onclick = moveToCauldron.bind(child);\n+});\n+\n+Array.prototype.forEach.call(cauldron.children, function (child) {\n+    child.onclick = removeFromCauldron.bind(child);\n+});\n+\n+checkFormulas(cauldron.children);\n+\n+function moveToCauldron() {\n+    cauldron.appendChild(this);\n+    this.onclick = removeFromCauldron.bind(this);\n+    this.innerHTML = this.innerText;\n+    checkFormulas(cauldron.children);\n+}\n+\n+function removeFromCauldron() {\n+    components.appendChild(this);\n+    this.onclick = moveToCauldron.bind(this);\n+    filterElements();\n+    checkFormulas(cauldron.children);\n+}\n+\n+function checkFormulas(elementsInCauldron) {\n+    var countElements = 0;\n+    var resFormula = null;\n+    formulas.forEach(function (formula) {\n+        if (formula.elements.every(function (element) {\n+            return Array.prototype.some.call(elementsInCauldron, function (elementInCauldron) {\n+                    if (elementInCauldron.getAttribute('data-element') === element) {\n+                        return true;\n+                    }\n+                });\n+\n+        }) && formula.elements.length > countElements) {\n+            countElements = formula.elements.length;\n+            resFormula = formula;\n+        }\n+    });\n+    var resSpan = document.getElementById('result');","path":"cauldron.js","position":52,"original_position":52,"commit_id":"bfeac9b6be129a84a65869ded070d61c704668c2","original_commit_id":"bfeac9b6be129a84a65869ded070d61c704668c2","user":{"login":"sameoldmadness","id":1537724,"avatar_url":"https://avatars.githubusercontent.com/u/1537724?v=3","gravatar_id":"","url":"https://api.github.com/users/sameoldmadness","html_url":"https://github.com/sameoldmadness","followers_url":"https://api.github.com/users/sameoldmadness/followers","following_url":"https://api.github.com/users/sameoldmadness/following{/other_user}","gists_url":"https://api.github.com/users/sameoldmadness/gists{/gist_id}","starred_url":"https://api.github.com/users/sameoldmadness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sameoldmadness/subscriptions","organizations_url":"https://api.github.com/users/sameoldmadness/orgs","repos_url":"https://api.github.com/users/sameoldmadness/repos","events_url":"https://api.github.com/users/sameoldmadness/events{/privacy}","received_events_url":"https://api.github.com/users/sameoldmadness/received_events","type":"User","site_admin":false},"body":"Почему не закэширован вместе с остальными элементами?","created_at":"2015-12-07T12:05:21Z","updated_at":"2015-12-07T12:05:21Z","html_url":"https://github.com/urfu-2015/javascript-tasks-10/pull/6#discussion_r46813732","pull_request_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/pulls/comments/46813732"},"html":{"href":"https://github.com/urfu-2015/javascript-tasks-10/pull/6#discussion_r46813732"},"pull_request":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/pulls/6","id":52786911,"html_url":"https://github.com/urfu-2015/javascript-tasks-10/pull/6","diff_url":"https://github.com/urfu-2015/javascript-tasks-10/pull/6.diff","patch_url":"https://github.com/urfu-2015/javascript-tasks-10/pull/6.patch","issue_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/issues/6","number":6,"state":"open","locked":false,"title":"Nekrasov Alexey","user":{"login":"NekrasovAlexey","id":9476133,"avatar_url":"https://avatars.githubusercontent.com/u/9476133?v=3","gravatar_id":"","url":"https://api.github.com/users/NekrasovAlexey","html_url":"https://github.com/NekrasovAlexey","followers_url":"https://api.github.com/users/NekrasovAlexey/followers","following_url":"https://api.github.com/users/NekrasovAlexey/following{/other_user}","gists_url":"https://api.github.com/users/NekrasovAlexey/gists{/gist_id}","starred_url":"https://api.github.com/users/NekrasovAlexey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NekrasovAlexey/subscriptions","organizations_url":"https://api.github.com/users/NekrasovAlexey/orgs","repos_url":"https://api.github.com/users/NekrasovAlexey/repos","events_url":"https://api.github.com/users/NekrasovAlexey/events{/privacy}","received_events_url":"https://api.github.com/users/NekrasovAlexey/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-06T18:41:19Z","updated_at":"2015-12-07T12:05:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"081534bd07324d71ff71966b0e8a9165dc1425be","assignee":{"login":"sameoldmadness","id":1537724,"avatar_url":"https://avatars.githubusercontent.com/u/1537724?v=3","gravatar_id":"","url":"https://api.github.com/users/sameoldmadness","html_url":"https://github.com/sameoldmadness","followers_url":"https://api.github.com/users/sameoldmadness/followers","following_url":"https://api.github.com/users/sameoldmadness/following{/other_user}","gists_url":"https://api.github.com/users/sameoldmadness/gists{/gist_id}","starred_url":"https://api.github.com/users/sameoldmadness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sameoldmadness/subscriptions","organizations_url":"https://api.github.com/users/sameoldmadness/orgs","repos_url":"https://api.github.com/users/sameoldmadness/repos","events_url":"https://api.github.com/users/sameoldmadness/events{/privacy}","received_events_url":"https://api.github.com/users/sameoldmadness/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/pulls/6/commits","review_comments_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/pulls/6/comments","review_comment_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/pulls/comments{/number}","comments_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/issues/6/comments","statuses_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/statuses/bfeac9b6be129a84a65869ded070d61c704668c2","head":{"label":"NekrasovAlexey:master","ref":"master","sha":"bfeac9b6be129a84a65869ded070d61c704668c2","user":{"login":"NekrasovAlexey","id":9476133,"avatar_url":"https://avatars.githubusercontent.com/u/9476133?v=3","gravatar_id":"","url":"https://api.github.com/users/NekrasovAlexey","html_url":"https://github.com/NekrasovAlexey","followers_url":"https://api.github.com/users/NekrasovAlexey/followers","following_url":"https://api.github.com/users/NekrasovAlexey/following{/other_user}","gists_url":"https://api.github.com/users/NekrasovAlexey/gists{/gist_id}","starred_url":"https://api.github.com/users/NekrasovAlexey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NekrasovAlexey/subscriptions","organizations_url":"https://api.github.com/users/NekrasovAlexey/orgs","repos_url":"https://api.github.com/users/NekrasovAlexey/repos","events_url":"https://api.github.com/users/NekrasovAlexey/events{/privacy}","received_events_url":"https://api.github.com/users/NekrasovAlexey/received_events","type":"User","site_admin":false},"repo":{"id":47467376,"name":"javascript-tasks-10","full_name":"NekrasovAlexey/javascript-tasks-10","owner":{"login":"NekrasovAlexey","id":9476133,"avatar_url":"https://avatars.githubusercontent.com/u/9476133?v=3","gravatar_id":"","url":"https://api.github.com/users/NekrasovAlexey","html_url":"https://github.com/NekrasovAlexey","followers_url":"https://api.github.com/users/NekrasovAlexey/followers","following_url":"https://api.github.com/users/NekrasovAlexey/following{/other_user}","gists_url":"https://api.github.com/users/NekrasovAlexey/gists{/gist_id}","starred_url":"https://api.github.com/users/NekrasovAlexey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NekrasovAlexey/subscriptions","organizations_url":"https://api.github.com/users/NekrasovAlexey/orgs","repos_url":"https://api.github.com/users/NekrasovAlexey/repos","events_url":"https://api.github.com/users/NekrasovAlexey/events{/privacy}","received_events_url":"https://api.github.com/users/NekrasovAlexey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/NekrasovAlexey/javascript-tasks-10","description":"Задача к лекции «DOM и события» – «Котёл алхимика»","fork":true,"url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10","forks_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/forks","keys_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/teams","hooks_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/hooks","issue_events_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/issues/events{/number}","events_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/events","assignees_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/assignees{/user}","branches_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/branches{/branch}","tags_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/tags","blobs_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/git/refs{/sha}","trees_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/statuses/{sha}","languages_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/languages","stargazers_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/stargazers","contributors_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/contributors","subscribers_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/subscribers","subscription_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/subscription","commits_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/commits{/sha}","git_commits_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/git/commits{/sha}","comments_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/comments{/number}","issue_comment_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/issues/comments{/number}","contents_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/contents/{+path}","compare_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/merges","archive_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/downloads","issues_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/issues{/number}","pulls_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/pulls{/number}","milestones_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/milestones{/number}","notifications_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/labels{/name}","releases_url":"https://api.github.com/repos/NekrasovAlexey/javascript-tasks-10/releases{/id}","created_at":"2015-12-05T18:22:29Z","updated_at":"2015-12-06T18:04:05Z","pushed_at":"2015-12-06T18:40:24Z","git_url":"git://github.com/NekrasovAlexey/javascript-tasks-10.git","ssh_url":"git@github.com:NekrasovAlexey/javascript-tasks-10.git","clone_url":"https://github.com/NekrasovAlexey/javascript-tasks-10.git","svn_url":"https://github.com/NekrasovAlexey/javascript-tasks-10","homepage":"","size":7,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"urfu-2015:master","ref":"master","sha":"cf1962ca153988f8cb7138dee415e4531ff8aac5","user":{"login":"urfu-2015","id":14800971,"avatar_url":"https://avatars.githubusercontent.com/u/14800971?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2015","html_url":"https://github.com/urfu-2015","followers_url":"https://api.github.com/users/urfu-2015/followers","following_url":"https://api.github.com/users/urfu-2015/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2015/subscriptions","organizations_url":"https://api.github.com/users/urfu-2015/orgs","repos_url":"https://api.github.com/users/urfu-2015/repos","events_url":"https://api.github.com/users/urfu-2015/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2015/received_events","type":"Organization","site_admin":false},"repo":{"id":47191467,"name":"javascript-tasks-10","full_name":"urfu-2015/javascript-tasks-10","owner":{"login":"urfu-2015","id":14800971,"avatar_url":"https://avatars.githubusercontent.com/u/14800971?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2015","html_url":"https://github.com/urfu-2015","followers_url":"https://api.github.com/users/urfu-2015/followers","following_url":"https://api.github.com/users/urfu-2015/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2015/subscriptions","organizations_url":"https://api.github.com/users/urfu-2015/orgs","repos_url":"https://api.github.com/users/urfu-2015/repos","events_url":"https://api.github.com/users/urfu-2015/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2015/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/urfu-2015/javascript-tasks-10","description":"Задача к лекции «DOM и события» – «Котёл алхимика»","fork":false,"url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10","forks_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/forks","keys_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/keys{/key_id}","collaborators_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/teams","hooks_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/hooks","issue_events_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/issues/events{/number}","events_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/events","assignees_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/assignees{/user}","branches_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/branches{/branch}","tags_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/tags","blobs_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/git/refs{/sha}","trees_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/git/trees{/sha}","statuses_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/statuses/{sha}","languages_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/languages","stargazers_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/stargazers","contributors_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/contributors","subscribers_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/subscribers","subscription_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/subscription","commits_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/commits{/sha}","git_commits_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/git/commits{/sha}","comments_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/comments{/number}","issue_comment_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/issues/comments{/number}","contents_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/contents/{+path}","compare_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/compare/{base}...{head}","merges_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/merges","archive_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/downloads","issues_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/issues{/number}","pulls_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/pulls{/number}","milestones_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/milestones{/number}","notifications_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/labels{/name}","releases_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/releases{/id}","created_at":"2015-12-01T13:32:14Z","updated_at":"2015-12-01T13:34:30Z","pushed_at":"2015-12-06T20:00:40Z","git_url":"git://github.com/urfu-2015/javascript-tasks-10.git","ssh_url":"git@github.com:urfu-2015/javascript-tasks-10.git","clone_url":"https://github.com/urfu-2015/javascript-tasks-10.git","svn_url":"https://github.com/urfu-2015/javascript-tasks-10","homepage":"","size":5,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":4,"forks":17,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/pulls/6"},"html":{"href":"https://github.com/urfu-2015/javascript-tasks-10/pull/6"},"issue":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/issues/6"},"comments":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-10/statuses/bfeac9b6be129a84a65869ded070d61c704668c2"}}}}