{"action":"created","comment":{"url":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/comments/38475033","id":38475033,"diff_hunk":"@@ -23,3 +25,103 @@ multiplicação (x), então no input deve aparecer \"1+2x\".\n input;\n - Ao pressionar o botão \"CE\", o input deve ficar zerado.\n */\n+\n+  var $numberInput = doc.querySelector('#number-input');\n+  var $numberBtn = doc.querySelectorAll('.number-btn-item');\n+  var $operationBtn = doc.querySelectorAll('.operation-btn-item');\n+  var $equalBtn = doc.querySelector('.equal-btn');\n+  var $clearBtn = doc.querySelector('.ce-btn');\n+\n+  var inputValue;\n+  var inputSize;\n+\n+  function justNumbers (arr) {\n+    return arr.map( function(element, index) {\n+      return Number(element);\n+    });\n+  }\n+\n+  function numberButton (btn) {\n+    btn.addEventListener('click', function (event) {\n+      $numberInput.value += btn.value;\n+    });\n+  }\n+\n+  function operationButton (btn) {\n+    btn.addEventListener('click', function (event) {\n+      inputValue = $numberInput.value;\n+      inputSize = inputValue.length;\n+      console.log($numberInput.value.charAt(inputSize - 1));\n+\n+      if (inputValue.charAt(inputSize - 1) === '+' ||\n+          inputValue.charAt(inputSize - 1) === '-' ||\n+          inputValue.charAt(inputSize - 1) === 'x' ||\n+          inputValue.charAt(inputSize - 1) === '÷') {\n+\n+        $numberInput.value = inputValue.slice(0, inputSize - 1) + btn.value;\n+\n+      } else {\n+\n+        $numberInput.value += btn.value;\n+\n+      }\n+    });\n+  }\n+\n+  Array.prototype.forEach.call($numberBtn, function (item) {\n+    numberButton(item);\n+  });\n+\n+  Array.prototype.forEach.call($operationBtn, function (item) {\n+    operationButton(item);\n+  });\n+\n+  $equalBtn.addEventListener('click', function (event) {\n+    var op = $numberInput.value.match(/[+\\÷\\-x]/g);\n+    var num = justNumbers($numberInput.value.match(/\\d+/g));\n+\n+    var result = num[0];\n+\n+    if (op === null) {\n+\n+      event.preventDefault();","path":"challenge-23/challenge-23.js","position":69,"original_position":69,"commit_id":"f8b06cf486ed162f6b20269a2789437aa3860280","original_commit_id":"f8b06cf486ed162f6b20269a2789437aa3860280","user":{"login":"fdaciuk","id":487669,"avatar_url":"https://avatars.githubusercontent.com/u/487669?v=3","gravatar_id":"","url":"https://api.github.com/users/fdaciuk","html_url":"https://github.com/fdaciuk","followers_url":"https://api.github.com/users/fdaciuk/followers","following_url":"https://api.github.com/users/fdaciuk/following{/other_user}","gists_url":"https://api.github.com/users/fdaciuk/gists{/gist_id}","starred_url":"https://api.github.com/users/fdaciuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fdaciuk/subscriptions","organizations_url":"https://api.github.com/users/fdaciuk/orgs","repos_url":"https://api.github.com/users/fdaciuk/repos","events_url":"https://api.github.com/users/fdaciuk/events{/privacy}","received_events_url":"https://api.github.com/users/fdaciuk/received_events","type":"User","site_admin":false},"body":"Use o `preventDefault` somente uma vez, e sempre no início da função.","created_at":"2015-09-01T21:33:19Z","updated_at":"2015-09-01T21:33:19Z","html_url":"https://github.com/da2k/curso-javascript-ninja/pull/301#discussion_r38475033","pull_request_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/301","_links":{"self":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/comments/38475033"},"html":{"href":"https://github.com/da2k/curso-javascript-ninja/pull/301#discussion_r38475033"},"pull_request":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/301"}}},"pull_request":{"url":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/301","id":43883256,"html_url":"https://github.com/da2k/curso-javascript-ninja/pull/301","diff_url":"https://github.com/da2k/curso-javascript-ninja/pull/301.diff","patch_url":"https://github.com/da2k/curso-javascript-ninja/pull/301.patch","issue_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/issues/301","number":301,"state":"open","locked":false,"title":"Challenge 23","user":{"login":"MateusJabour","id":11710000,"avatar_url":"https://avatars.githubusercontent.com/u/11710000?v=3","gravatar_id":"","url":"https://api.github.com/users/MateusJabour","html_url":"https://github.com/MateusJabour","followers_url":"https://api.github.com/users/MateusJabour/followers","following_url":"https://api.github.com/users/MateusJabour/following{/other_user}","gists_url":"https://api.github.com/users/MateusJabour/gists{/gist_id}","starred_url":"https://api.github.com/users/MateusJabour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MateusJabour/subscriptions","organizations_url":"https://api.github.com/users/MateusJabour/orgs","repos_url":"https://api.github.com/users/MateusJabour/repos","events_url":"https://api.github.com/users/MateusJabour/events{/privacy}","received_events_url":"https://api.github.com/users/MateusJabour/received_events","type":"User","site_admin":false},"body":"@fdaciuk Pronto, adicionei alguns tratamentos de excessão e um css, poderia corrigir pra mim professor? :D","created_at":"2015-09-01T14:38:21Z","updated_at":"2015-09-01T21:33:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bafeb4d9342e368956187fd08fe75a7f38986c15","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/301/commits","review_comments_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/301/comments","review_comment_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/comments{/number}","comments_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/issues/301/comments","statuses_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/statuses/f8b06cf486ed162f6b20269a2789437aa3860280","head":{"label":"MateusJabour:challenge-23","ref":"challenge-23","sha":"f8b06cf486ed162f6b20269a2789437aa3860280","user":{"login":"MateusJabour","id":11710000,"avatar_url":"https://avatars.githubusercontent.com/u/11710000?v=3","gravatar_id":"","url":"https://api.github.com/users/MateusJabour","html_url":"https://github.com/MateusJabour","followers_url":"https://api.github.com/users/MateusJabour/followers","following_url":"https://api.github.com/users/MateusJabour/following{/other_user}","gists_url":"https://api.github.com/users/MateusJabour/gists{/gist_id}","starred_url":"https://api.github.com/users/MateusJabour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MateusJabour/subscriptions","organizations_url":"https://api.github.com/users/MateusJabour/orgs","repos_url":"https://api.github.com/users/MateusJabour/repos","events_url":"https://api.github.com/users/MateusJabour/events{/privacy}","received_events_url":"https://api.github.com/users/MateusJabour/received_events","type":"User","site_admin":false},"repo":{"id":33206855,"name":"curso-javascript-ninja","full_name":"MateusJabour/curso-javascript-ninja","owner":{"login":"MateusJabour","id":11710000,"avatar_url":"https://avatars.githubusercontent.com/u/11710000?v=3","gravatar_id":"","url":"https://api.github.com/users/MateusJabour","html_url":"https://github.com/MateusJabour","followers_url":"https://api.github.com/users/MateusJabour/followers","following_url":"https://api.github.com/users/MateusJabour/following{/other_user}","gists_url":"https://api.github.com/users/MateusJabour/gists{/gist_id}","starred_url":"https://api.github.com/users/MateusJabour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MateusJabour/subscriptions","organizations_url":"https://api.github.com/users/MateusJabour/orgs","repos_url":"https://api.github.com/users/MateusJabour/repos","events_url":"https://api.github.com/users/MateusJabour/events{/privacy}","received_events_url":"https://api.github.com/users/MateusJabour/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MateusJabour/curso-javascript-ninja","description":"Curso Javascript Ninja","fork":true,"url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja","forks_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/forks","keys_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/teams","hooks_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/hooks","issue_events_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/issues/events{/number}","events_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/events","assignees_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/assignees{/user}","branches_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/branches{/branch}","tags_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/tags","blobs_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/git/refs{/sha}","trees_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/statuses/{sha}","languages_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/languages","stargazers_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/stargazers","contributors_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/contributors","subscribers_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/subscribers","subscription_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/subscription","commits_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/commits{/sha}","git_commits_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/git/commits{/sha}","comments_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/comments{/number}","issue_comment_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/issues/comments{/number}","contents_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/contents/{+path}","compare_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/merges","archive_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/downloads","issues_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/issues{/number}","pulls_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/pulls{/number}","milestones_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/milestones{/number}","notifications_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/labels{/name}","releases_url":"https://api.github.com/repos/MateusJabour/curso-javascript-ninja/releases{/id}","created_at":"2015-03-31T20:01:51Z","updated_at":"2015-05-01T15:46:26Z","pushed_at":"2015-09-01T14:37:09Z","git_url":"git://github.com/MateusJabour/curso-javascript-ninja.git","ssh_url":"git@github.com:MateusJabour/curso-javascript-ninja.git","clone_url":"https://github.com/MateusJabour/curso-javascript-ninja.git","svn_url":"https://github.com/MateusJabour/curso-javascript-ninja","homepage":"http://blog.da2k.com.br/curso-javascript-ninja/","size":423,"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":"da2k:master","ref":"master","sha":"f140e3fd72bc283de18034085da8ef102696d4bb","user":{"login":"da2k","id":11011075,"avatar_url":"https://avatars.githubusercontent.com/u/11011075?v=3","gravatar_id":"","url":"https://api.github.com/users/da2k","html_url":"https://github.com/da2k","followers_url":"https://api.github.com/users/da2k/followers","following_url":"https://api.github.com/users/da2k/following{/other_user}","gists_url":"https://api.github.com/users/da2k/gists{/gist_id}","starred_url":"https://api.github.com/users/da2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/da2k/subscriptions","organizations_url":"https://api.github.com/users/da2k/orgs","repos_url":"https://api.github.com/users/da2k/repos","events_url":"https://api.github.com/users/da2k/events{/privacy}","received_events_url":"https://api.github.com/users/da2k/received_events","type":"Organization","site_admin":false},"repo":{"id":30896610,"name":"curso-javascript-ninja","full_name":"da2k/curso-javascript-ninja","owner":{"login":"da2k","id":11011075,"avatar_url":"https://avatars.githubusercontent.com/u/11011075?v=3","gravatar_id":"","url":"https://api.github.com/users/da2k","html_url":"https://github.com/da2k","followers_url":"https://api.github.com/users/da2k/followers","following_url":"https://api.github.com/users/da2k/following{/other_user}","gists_url":"https://api.github.com/users/da2k/gists{/gist_id}","starred_url":"https://api.github.com/users/da2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/da2k/subscriptions","organizations_url":"https://api.github.com/users/da2k/orgs","repos_url":"https://api.github.com/users/da2k/repos","events_url":"https://api.github.com/users/da2k/events{/privacy}","received_events_url":"https://api.github.com/users/da2k/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/da2k/curso-javascript-ninja","description":"Curso Javascript Ninja","fork":false,"url":"https://api.github.com/repos/da2k/curso-javascript-ninja","forks_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/forks","keys_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/keys{/key_id}","collaborators_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/teams","hooks_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/hooks","issue_events_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/issues/events{/number}","events_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/events","assignees_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/assignees{/user}","branches_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/branches{/branch}","tags_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/tags","blobs_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/git/refs{/sha}","trees_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/git/trees{/sha}","statuses_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/statuses/{sha}","languages_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/languages","stargazers_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/stargazers","contributors_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/contributors","subscribers_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/subscribers","subscription_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/subscription","commits_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/commits{/sha}","git_commits_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/git/commits{/sha}","comments_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/comments{/number}","issue_comment_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/issues/comments{/number}","contents_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/contents/{+path}","compare_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/compare/{base}...{head}","merges_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/merges","archive_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/downloads","issues_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/issues{/number}","pulls_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls{/number}","milestones_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/milestones{/number}","notifications_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/labels{/name}","releases_url":"https://api.github.com/repos/da2k/curso-javascript-ninja/releases{/id}","created_at":"2015-02-17T00:57:58Z","updated_at":"2015-08-28T02:25:52Z","pushed_at":"2015-09-01T14:38:22Z","git_url":"git://github.com/da2k/curso-javascript-ninja.git","ssh_url":"git@github.com:da2k/curso-javascript-ninja.git","clone_url":"https://github.com/da2k/curso-javascript-ninja.git","svn_url":"https://github.com/da2k/curso-javascript-ninja","homepage":"http://blog.da2k.com.br/curso-javascript-ninja/","size":2479,"stargazers_count":36,"watchers_count":36,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":42,"mirror_url":null,"open_issues_count":51,"forks":42,"open_issues":51,"watchers":36,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/301"},"html":{"href":"https://github.com/da2k/curso-javascript-ninja/pull/301"},"issue":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/issues/301"},"comments":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/issues/301/comments"},"review_comments":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/301/comments"},"review_comment":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/pulls/301/commits"},"statuses":{"href":"https://api.github.com/repos/da2k/curso-javascript-ninja/statuses/f8b06cf486ed162f6b20269a2789437aa3860280"}}}}