{"action":"created","comment":{"url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/pulls/comments/61787105","id":61787105,"diff_hunk":"@@ -0,0 +1,432 @@\n+require('file?name=page.html!./page.html');\n+require('file?name=pig.svg!./pig.svg');\n+require('./page.css');\n+\n+function printVal(state, param) {\n+    var idNode = document.getElementById(param);\n+    idNode.innerHTML = state[param];\n+}\n+\n+// Изменение состояния объекта\n+function changeVal(dir, state, param) {\n+    if (dir === 'inc') {\n+        if (state[param] < 100) {\n+            state[param] += 1;\n+        }\n+    }\n+    if (dir === 'dec') {\n+        if (state[param] > 0) {\n+            state[param] -= 1;\n+        }\n+    }\n+    //console.log(state);\n+}\n+\n+define('page', ['./svgLoad.js', './browserAPI.js'], function (svgLoad, browserAPI) {\n+    svgLoad.then((s) => {\n+        var state;\n+        var satietyChanger;\n+        var energyChanger;\n+        var moodChanger;\n+        var decSpeed = 3000;\n+        var incSpeed = 1000;\n+\n+        var EventEmitter = require('wolfy87-eventemitter');\n+        var ee = new EventEmitter();\n+\n+        // Кнопка для возвращения к начальному состоянию\n+        var startOverButton = document.getElementById('start-over');\n+        startOverButton.onclick = () => {\n+            localStorage.removeItem('pig-state');\n+            clearInterval(energyChanger);\n+            clearInterval(satietyChanger);\n+            clearInterval(moodChanger);\n+            if (state.isDead) {\n+                reanimatePigAnimation();\n+            }\n+            preparePig();\n+        };\n+\n+        // Подготовка начального состояния\n+        function preparePig() {\n+            state = {\n+                // Показатели хрюнделя\n+                satiety: 100,\n+                energy: 100,\n+                mood: 100,\n+                // Состояния хрюнделя\n+                isSleeping: false,\n+                isIdle: true,\n+                isEating: false,\n+                isListening: false,\n+                isDead: false\n+            };\n+            printVal(state, 'satiety');\n+            printVal(state, 'energy');\n+            printVal(state, 'mood');\n+\n+            listeningHandler('stop');\n+            sleepingHandler('stop');\n+            eatingHandler('stop');\n+        }\n+\n+        // Проверим, доступно ли хранилище\n+        var isLocalAvailable = false;\n+        try {\n+            localStorage.setItem('key', 'value');\n+            localStorage.removeItem('key');\n+            isLocalAvailable = true;\n+        } catch (error) {\n+            console.log('Local Storage не доступен');\n+        }\n+        if (isLocalAvailable) {\n+            // Если доступно - попробуем восстановить предыдущее состояние\n+            var stateString = localStorage.getItem('pig-state');\n+            if (stateString) {\n+                state = JSON.parse(stateString);\n+                console.log(state);\n+\n+                if (!state.isDead) {\n+                    // Теперь восстановим движение всех характеристик\n+                    state.isEating ? eatingHandler('start') : eatingHandler('stop');\n+                    state.isListening ? listeningHandler('start') : listeningHandler('stop');\n+                    state.isSleeping ? sleepingHandler('start') : sleepingHandler('stop');\n+                } else {\n+                    deadAnimation();\n+                }\n+\n+                printVal(state, 'satiety');\n+                printVal(state, 'energy');\n+                printVal(state, 'mood');\n+            }\n+        }\n+\n+        //Сохранение текущего состояния\n+        function saveState() {\n+            if (isLocalAvailable) {\n+                localStorage.setItem('pig-state', JSON.stringify(state));\n+            }\n+        }\n+\n+        // Если не смогли получить пердыдущее состояние - грузим стандартное\n+        if (!state) {\n+            preparePig();\n+        }\n+\n+        // Анимации состояний и переходов в состояния\n+        function wakingUpAnimation() {\n+            var sleep = s.select('#Sleep');\n+            if (sleep.attr('opacity') === '1') {\n+                sleep.animate({\n+                    opacity: '0'\n+                }, 100, mina.easeinout);\n+            }\n+        }\n+\n+        function sleepingAnimation() {\n+            var sleep = s.select('#Sleep');\n+            if (sleep.attr('opacity') === '0') {\n+                sleep.attr({opacity: 1});\n+            }\n+            sleep.animate({\n+                transform: 'scale(1.5, 1.5)'\n+            }, 500, mina.easeinout, () => {\n+                sleep.animate({\n+                    transform: 'scale(0.5, 0.5)'\n+                }, 500, mina.easeinout)\n+            });\n+        }\n+\n+        function stopEatingAnimation() {\n+            var mouth = s.select('#mouth');\n+            mouth.animate({\n+                transform: 'translate(38, 91)'\n+            }, 250);\n+        }\n+\n+        function eatingAnimation() {\n+            var mouth = s.select('#mouth');\n+            mouth.animate({\n+                transform: 'translate(38, 80)'\n+            }, 250, mina.easeinout, () => {\n+                mouth.animate({\n+                    transform: 'translate(25, 85)'\n+                }, 250, mina.easeinout, () => {\n+                    mouth.animate({\n+                        transform: 'translate(38, 80)'\n+                    }, 250, mina.easeinout, () => {\n+                        mouth.animate({\n+                            transform: 'translate(51, 85)'\n+                        }, 250, mina.easeinout, () => {\n+                            mouth.animate({\n+                                transform: 'translate(38, 91)'","path":"bundles/page/page.js","position":162,"original_position":162,"commit_id":"1015caa811b8f3fc63ab5658e847072f7cc2be94","original_commit_id":"1015caa811b8f3fc63ab5658e847072f7cc2be94","user":{"login":"mokhov","id":357689,"avatar_url":"https://avatars.githubusercontent.com/u/357689?v=3","gravatar_id":"","url":"https://api.github.com/users/mokhov","html_url":"https://github.com/mokhov","followers_url":"https://api.github.com/users/mokhov/followers","following_url":"https://api.github.com/users/mokhov/following{/other_user}","gists_url":"https://api.github.com/users/mokhov/gists{/gist_id}","starred_url":"https://api.github.com/users/mokhov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mokhov/subscriptions","organizations_url":"https://api.github.com/users/mokhov/orgs","repos_url":"https://api.github.com/users/mokhov/repos","events_url":"https://api.github.com/users/mokhov/events{/privacy}","received_events_url":"https://api.github.com/users/mokhov/received_events","type":"User","site_admin":false},"body":"Адок","created_at":"2016-05-02T19:10:55Z","updated_at":"2016-05-02T19:10:55Z","html_url":"https://github.com/urfu-2015/webdev-tasks-7/pull/5#discussion_r61787105","pull_request_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/pulls/comments/61787105"},"html":{"href":"https://github.com/urfu-2015/webdev-tasks-7/pull/5#discussion_r61787105"},"pull_request":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/pulls/5","id":68110542,"html_url":"https://github.com/urfu-2015/webdev-tasks-7/pull/5","diff_url":"https://github.com/urfu-2015/webdev-tasks-7/pull/5.diff","patch_url":"https://github.com/urfu-2015/webdev-tasks-7/pull/5.patch","issue_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/issues/5","number":5,"state":"open","locked":false,"title":"Миронов Данил","user":{"login":"danmir","id":1074336,"avatar_url":"https://avatars.githubusercontent.com/u/1074336?v=3","gravatar_id":"","url":"https://api.github.com/users/danmir","html_url":"https://github.com/danmir","followers_url":"https://api.github.com/users/danmir/followers","following_url":"https://api.github.com/users/danmir/following{/other_user}","gists_url":"https://api.github.com/users/danmir/gists{/gist_id}","starred_url":"https://api.github.com/users/danmir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danmir/subscriptions","organizations_url":"https://api.github.com/users/danmir/orgs","repos_url":"https://api.github.com/users/danmir/repos","events_url":"https://api.github.com/users/danmir/events{/privacy}","received_events_url":"https://api.github.com/users/danmir/received_events","type":"User","site_admin":false},"body":"Первая версия хрюнделя","created_at":"2016-04-27T19:28:26Z","updated_at":"2016-05-02T19:10:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"756dc3774cd4f46963c84ba616c9101220c81828","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/pulls/5/commits","review_comments_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/pulls/5/comments","review_comment_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/pulls/comments{/number}","comments_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/issues/5/comments","statuses_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/statuses/1015caa811b8f3fc63ab5658e847072f7cc2be94","head":{"label":"danmir:master","ref":"master","sha":"1015caa811b8f3fc63ab5658e847072f7cc2be94","user":{"login":"danmir","id":1074336,"avatar_url":"https://avatars.githubusercontent.com/u/1074336?v=3","gravatar_id":"","url":"https://api.github.com/users/danmir","html_url":"https://github.com/danmir","followers_url":"https://api.github.com/users/danmir/followers","following_url":"https://api.github.com/users/danmir/following{/other_user}","gists_url":"https://api.github.com/users/danmir/gists{/gist_id}","starred_url":"https://api.github.com/users/danmir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danmir/subscriptions","organizations_url":"https://api.github.com/users/danmir/orgs","repos_url":"https://api.github.com/users/danmir/repos","events_url":"https://api.github.com/users/danmir/events{/privacy}","received_events_url":"https://api.github.com/users/danmir/received_events","type":"User","site_admin":false},"repo":{"id":56789298,"name":"webdev-tasks-7","full_name":"danmir/webdev-tasks-7","owner":{"login":"danmir","id":1074336,"avatar_url":"https://avatars.githubusercontent.com/u/1074336?v=3","gravatar_id":"","url":"https://api.github.com/users/danmir","html_url":"https://github.com/danmir","followers_url":"https://api.github.com/users/danmir/followers","following_url":"https://api.github.com/users/danmir/following{/other_user}","gists_url":"https://api.github.com/users/danmir/gists{/gist_id}","starred_url":"https://api.github.com/users/danmir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danmir/subscriptions","organizations_url":"https://api.github.com/users/danmir/orgs","repos_url":"https://api.github.com/users/danmir/repos","events_url":"https://api.github.com/users/danmir/events{/privacy}","received_events_url":"https://api.github.com/users/danmir/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danmir/webdev-tasks-7","description":"","fork":true,"url":"https://api.github.com/repos/danmir/webdev-tasks-7","forks_url":"https://api.github.com/repos/danmir/webdev-tasks-7/forks","keys_url":"https://api.github.com/repos/danmir/webdev-tasks-7/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danmir/webdev-tasks-7/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danmir/webdev-tasks-7/teams","hooks_url":"https://api.github.com/repos/danmir/webdev-tasks-7/hooks","issue_events_url":"https://api.github.com/repos/danmir/webdev-tasks-7/issues/events{/number}","events_url":"https://api.github.com/repos/danmir/webdev-tasks-7/events","assignees_url":"https://api.github.com/repos/danmir/webdev-tasks-7/assignees{/user}","branches_url":"https://api.github.com/repos/danmir/webdev-tasks-7/branches{/branch}","tags_url":"https://api.github.com/repos/danmir/webdev-tasks-7/tags","blobs_url":"https://api.github.com/repos/danmir/webdev-tasks-7/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danmir/webdev-tasks-7/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danmir/webdev-tasks-7/git/refs{/sha}","trees_url":"https://api.github.com/repos/danmir/webdev-tasks-7/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danmir/webdev-tasks-7/statuses/{sha}","languages_url":"https://api.github.com/repos/danmir/webdev-tasks-7/languages","stargazers_url":"https://api.github.com/repos/danmir/webdev-tasks-7/stargazers","contributors_url":"https://api.github.com/repos/danmir/webdev-tasks-7/contributors","subscribers_url":"https://api.github.com/repos/danmir/webdev-tasks-7/subscribers","subscription_url":"https://api.github.com/repos/danmir/webdev-tasks-7/subscription","commits_url":"https://api.github.com/repos/danmir/webdev-tasks-7/commits{/sha}","git_commits_url":"https://api.github.com/repos/danmir/webdev-tasks-7/git/commits{/sha}","comments_url":"https://api.github.com/repos/danmir/webdev-tasks-7/comments{/number}","issue_comment_url":"https://api.github.com/repos/danmir/webdev-tasks-7/issues/comments{/number}","contents_url":"https://api.github.com/repos/danmir/webdev-tasks-7/contents/{+path}","compare_url":"https://api.github.com/repos/danmir/webdev-tasks-7/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danmir/webdev-tasks-7/merges","archive_url":"https://api.github.com/repos/danmir/webdev-tasks-7/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danmir/webdev-tasks-7/downloads","issues_url":"https://api.github.com/repos/danmir/webdev-tasks-7/issues{/number}","pulls_url":"https://api.github.com/repos/danmir/webdev-tasks-7/pulls{/number}","milestones_url":"https://api.github.com/repos/danmir/webdev-tasks-7/milestones{/number}","notifications_url":"https://api.github.com/repos/danmir/webdev-tasks-7/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danmir/webdev-tasks-7/labels{/name}","releases_url":"https://api.github.com/repos/danmir/webdev-tasks-7/releases{/id}","deployments_url":"https://api.github.com/repos/danmir/webdev-tasks-7/deployments","created_at":"2016-04-21T16:27:34Z","updated_at":"2016-04-27T19:27:09Z","pushed_at":"2016-05-01T12:04:49Z","git_url":"git://github.com/danmir/webdev-tasks-7.git","ssh_url":"git@github.com:danmir/webdev-tasks-7.git","clone_url":"https://github.com/danmir/webdev-tasks-7.git","svn_url":"https://github.com/danmir/webdev-tasks-7","homepage":null,"size":148,"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":"94dfd1b88425abc73ad85dd3ec04577243138255","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":56763594,"name":"webdev-tasks-7","full_name":"urfu-2015/webdev-tasks-7","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/webdev-tasks-7","description":"","fork":false,"url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7","forks_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/forks","keys_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/keys{/key_id}","collaborators_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/teams","hooks_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/hooks","issue_events_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/issues/events{/number}","events_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/events","assignees_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/assignees{/user}","branches_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/branches{/branch}","tags_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/tags","blobs_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/git/refs{/sha}","trees_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/git/trees{/sha}","statuses_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/statuses/{sha}","languages_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/languages","stargazers_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/stargazers","contributors_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/contributors","subscribers_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/subscribers","subscription_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/subscription","commits_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/commits{/sha}","git_commits_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/git/commits{/sha}","comments_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/comments{/number}","issue_comment_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/issues/comments{/number}","contents_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/contents/{+path}","compare_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/compare/{base}...{head}","merges_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/merges","archive_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/downloads","issues_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/issues{/number}","pulls_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/pulls{/number}","milestones_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/milestones{/number}","notifications_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/labels{/name}","releases_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/releases{/id}","deployments_url":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/deployments","created_at":"2016-04-21T10:08:23Z","updated_at":"2016-04-27T13:06:51Z","pushed_at":"2016-05-02T19:08:32Z","git_url":"git://github.com/urfu-2015/webdev-tasks-7.git","ssh_url":"git@github.com:urfu-2015/webdev-tasks-7.git","clone_url":"https://github.com/urfu-2015/webdev-tasks-7.git","svn_url":"https://github.com/urfu-2015/webdev-tasks-7","homepage":null,"size":3,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":14,"forks":26,"open_issues":14,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/pulls/5"},"html":{"href":"https://github.com/urfu-2015/webdev-tasks-7/pull/5"},"issue":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/issues/5"},"comments":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/urfu-2015/webdev-tasks-7/statuses/1015caa811b8f3fc63ab5658e847072f7cc2be94"}}}}