{"action":"created","comment":{"url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/pulls/comments/71637003","id":71637003,"diff_hunk":"@@ -0,0 +1,90 @@\n+//Verify if the shortify button is enabled.\n+function isShort() {\n+  return $('#short-and-copy').html() === 'ENCURTAR';\n+}\n+\n+//Validates the input URL, outputs the short URL into the input field.\n+function shortifyEvent(){\n+  var input = $('#input-link');\n+  var clear = $('#clear');\n+  var shortAndCopy = $('#short-and-copy');\n+  var notification = $('#notification');\n+\n+  var link = input.val();\n+  var reg = /^(https?:\\/\\/)?([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w \\.-]*)*\\/?$/;\n+  if(link.search(reg) == -1) {\n+    notification.html('Link inválido!');\n+    return;\n+  }\n+  notification.html('');\n+\n+  //Generates random, short URL\n+  var randomString = Math.random().toString(36).replace(/[^a-z0-9]+/g, '').substr(0, 5);\n+  var shortLink = 'http://chr.dc/' + randomString;\n+\n+  input.val(shortLink);\n+  input.addClass('blink');\n+  clear.removeClass('unclickable');\n+  clear.addClass('blink');\n+  shortAndCopy.text('COPIAR');\n+  shortAndCopy.addClass('blink');\n+}\n+\n+//Fire function with Enter key\n+$('#input-link').keyup(function inputKeyEvent(event){\n+  if(event.keyCode == 13 && isShort()){\n+    shortifyEvent();\n+  }\n+});\n+\n+//Executes the commands when button is clicked.\n+$('#short-and-copy').click(function shortAndCopyEvent(){\n+  if(isShort()) {\n+    shortifyEvent();\n+  } else {\n+    //Copies the output, short URL.\n+    $('#input-link').select();\n+    document.execCommand('copy');\n+    $('#notification').html('Copiado com sucesso!');\n+  }\n+});\n+\n+//Clears the input field, resets color, notification, shortify and clear button.\n+$('#clear').click(function clearTextEvent() {\n+  var input = $('#input-link');\n+  var clear = $('#clear');\n+  var shortAndCopy = $('#short-and-copy');\n+  var notification = $('#notification');\n+  input.val('');\n+  input.removeClass('blink');\n+  notification.html('');\n+  clear.addClass('unclickable');\n+  clear.removeClass('blink');\n+  shortAndCopy.removeClass('blink');\n+  shortAndCopy.html('ENCURTAR');\n+});\n+\n+//Gets URLS from the JSON.\n+(function getURLs(){\n+  $.ajax({\n+    url: 'https://raw.githubusercontent.com/legraeff/frontend-intern-challenge/leticia-graeff/Assets/urls.json',\n+    cache: false,\n+//Sorts the URLS in the JSON by hits. Appends the Top 5 and the sum of total hits into the HTML.\n+    success: function (data){\n+      var urlsData = JSON.parse(data);\n+      urlsData.sort(function(a, b){return b.hits - a.hits;});\n+      for (var i=0; i < 5; i++) {\n+        var urlInfo = urlsData[i];\n+        $('#urls').append('<li><a href=\"' +\n+            urlInfo.url + '\">' +\n+            urlInfo.shortUrl + '</a><span>' +\n+            urlInfo.hits + '</span></li>');\n+      }","path":"project/app/scripts/main.js","position":83,"original_position":82,"commit_id":"df03ae117bc974d5beef596abf8b3d1c0837da1f","original_commit_id":"7980cf7982cf31d26fa78190f3a383895c9752be","user":{"login":"legraeff","id":15527151,"avatar_url":"https://avatars.githubusercontent.com/u/15527151?v=3","gravatar_id":"","url":"https://api.github.com/users/legraeff","html_url":"https://github.com/legraeff","followers_url":"https://api.github.com/users/legraeff/followers","following_url":"https://api.github.com/users/legraeff/following{/other_user}","gists_url":"https://api.github.com/users/legraeff/gists{/gist_id}","starred_url":"https://api.github.com/users/legraeff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/legraeff/subscriptions","organizations_url":"https://api.github.com/users/legraeff/orgs","repos_url":"https://api.github.com/users/legraeff/repos","events_url":"https://api.github.com/users/legraeff/events{/privacy}","received_events_url":"https://api.github.com/users/legraeff/received_events","type":"User","site_admin":false},"body":"Thanks for the tip! Already fixed it!","created_at":"2016-07-21T02:01:43Z","updated_at":"2016-07-21T02:01:43Z","html_url":"https://github.com/chaordic/frontend-intern-challenge/pull/27#discussion_r71637003","pull_request_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/pulls/27","_links":{"self":{"href":"https://api.github.com/repos/chaordic/frontend-intern-challenge/pulls/comments/71637003"},"html":{"href":"https://github.com/chaordic/frontend-intern-challenge/pull/27#discussion_r71637003"},"pull_request":{"href":"https://api.github.com/repos/chaordic/frontend-intern-challenge/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/pulls/27","id":77389754,"html_url":"https://github.com/chaordic/frontend-intern-challenge/pull/27","diff_url":"https://github.com/chaordic/frontend-intern-challenge/pull/27.diff","patch_url":"https://github.com/chaordic/frontend-intern-challenge/pull/27.patch","issue_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/issues/27","number":27,"state":"open","locked":false,"title":"Leticia Graeff","user":{"login":"legraeff","id":15527151,"avatar_url":"https://avatars.githubusercontent.com/u/15527151?v=3","gravatar_id":"","url":"https://api.github.com/users/legraeff","html_url":"https://github.com/legraeff","followers_url":"https://api.github.com/users/legraeff/followers","following_url":"https://api.github.com/users/legraeff/following{/other_user}","gists_url":"https://api.github.com/users/legraeff/gists{/gist_id}","starred_url":"https://api.github.com/users/legraeff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/legraeff/subscriptions","organizations_url":"https://api.github.com/users/legraeff/orgs","repos_url":"https://api.github.com/users/legraeff/repos","events_url":"https://api.github.com/users/legraeff/events{/privacy}","received_events_url":"https://api.github.com/users/legraeff/received_events","type":"User","site_admin":false},"body":"Desafio de estagiário da Chaordic Florianópolis concluído. Pull Request aberto para feedbacks!","created_at":"2016-07-14T02:03:45Z","updated_at":"2016-07-21T02:01:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"552bffb9d265cf95231b8c456a598566598e10f4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/pulls/27/commits","review_comments_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/pulls/27/comments","review_comment_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/issues/27/comments","statuses_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/statuses/df03ae117bc974d5beef596abf8b3d1c0837da1f","head":{"label":"legraeff:leticia-graeff","ref":"leticia-graeff","sha":"df03ae117bc974d5beef596abf8b3d1c0837da1f","user":{"login":"legraeff","id":15527151,"avatar_url":"https://avatars.githubusercontent.com/u/15527151?v=3","gravatar_id":"","url":"https://api.github.com/users/legraeff","html_url":"https://github.com/legraeff","followers_url":"https://api.github.com/users/legraeff/followers","following_url":"https://api.github.com/users/legraeff/following{/other_user}","gists_url":"https://api.github.com/users/legraeff/gists{/gist_id}","starred_url":"https://api.github.com/users/legraeff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/legraeff/subscriptions","organizations_url":"https://api.github.com/users/legraeff/orgs","repos_url":"https://api.github.com/users/legraeff/repos","events_url":"https://api.github.com/users/legraeff/events{/privacy}","received_events_url":"https://api.github.com/users/legraeff/received_events","type":"User","site_admin":false},"repo":{"id":62846059,"name":"frontend-intern-challenge","full_name":"legraeff/frontend-intern-challenge","owner":{"login":"legraeff","id":15527151,"avatar_url":"https://avatars.githubusercontent.com/u/15527151?v=3","gravatar_id":"","url":"https://api.github.com/users/legraeff","html_url":"https://github.com/legraeff","followers_url":"https://api.github.com/users/legraeff/followers","following_url":"https://api.github.com/users/legraeff/following{/other_user}","gists_url":"https://api.github.com/users/legraeff/gists{/gist_id}","starred_url":"https://api.github.com/users/legraeff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/legraeff/subscriptions","organizations_url":"https://api.github.com/users/legraeff/orgs","repos_url":"https://api.github.com/users/legraeff/repos","events_url":"https://api.github.com/users/legraeff/events{/privacy}","received_events_url":"https://api.github.com/users/legraeff/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/legraeff/frontend-intern-challenge","description":"Desafio para os futuros front-end's da Linx+Neemu+Chaordic","fork":true,"url":"https://api.github.com/repos/legraeff/frontend-intern-challenge","forks_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/forks","keys_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/keys{/key_id}","collaborators_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/teams","hooks_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/hooks","issue_events_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/issues/events{/number}","events_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/events","assignees_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/assignees{/user}","branches_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/branches{/branch}","tags_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/tags","blobs_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/git/refs{/sha}","trees_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/git/trees{/sha}","statuses_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/statuses/{sha}","languages_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/languages","stargazers_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/stargazers","contributors_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/contributors","subscribers_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/subscribers","subscription_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/subscription","commits_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/commits{/sha}","git_commits_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/git/commits{/sha}","comments_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/comments{/number}","issue_comment_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/issues/comments{/number}","contents_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/contents/{+path}","compare_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/compare/{base}...{head}","merges_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/merges","archive_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/downloads","issues_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/issues{/number}","pulls_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/pulls{/number}","milestones_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/milestones{/number}","notifications_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/labels{/name}","releases_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/releases{/id}","deployments_url":"https://api.github.com/repos/legraeff/frontend-intern-challenge/deployments","created_at":"2016-07-08T00:14:20Z","updated_at":"2016-06-29T12:40:14Z","pushed_at":"2016-07-21T01:56:28Z","git_url":"git://github.com/legraeff/frontend-intern-challenge.git","ssh_url":"git@github.com:legraeff/frontend-intern-challenge.git","clone_url":"https://github.com/legraeff/frontend-intern-challenge.git","svn_url":"https://github.com/legraeff/frontend-intern-challenge","homepage":"","size":21039,"stargazers_count":0,"watchers_count":0,"language":null,"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":"chaordic:master","ref":"master","sha":"1847fba2a4877b434acb1fc6051e931f414d790b","user":{"login":"chaordic","id":1434501,"avatar_url":"https://avatars.githubusercontent.com/u/1434501?v=3","gravatar_id":"","url":"https://api.github.com/users/chaordic","html_url":"https://github.com/chaordic","followers_url":"https://api.github.com/users/chaordic/followers","following_url":"https://api.github.com/users/chaordic/following{/other_user}","gists_url":"https://api.github.com/users/chaordic/gists{/gist_id}","starred_url":"https://api.github.com/users/chaordic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaordic/subscriptions","organizations_url":"https://api.github.com/users/chaordic/orgs","repos_url":"https://api.github.com/users/chaordic/repos","events_url":"https://api.github.com/users/chaordic/events{/privacy}","received_events_url":"https://api.github.com/users/chaordic/received_events","type":"Organization","site_admin":false},"repo":{"id":54136684,"name":"frontend-intern-challenge","full_name":"chaordic/frontend-intern-challenge","owner":{"login":"chaordic","id":1434501,"avatar_url":"https://avatars.githubusercontent.com/u/1434501?v=3","gravatar_id":"","url":"https://api.github.com/users/chaordic","html_url":"https://github.com/chaordic","followers_url":"https://api.github.com/users/chaordic/followers","following_url":"https://api.github.com/users/chaordic/following{/other_user}","gists_url":"https://api.github.com/users/chaordic/gists{/gist_id}","starred_url":"https://api.github.com/users/chaordic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaordic/subscriptions","organizations_url":"https://api.github.com/users/chaordic/orgs","repos_url":"https://api.github.com/users/chaordic/repos","events_url":"https://api.github.com/users/chaordic/events{/privacy}","received_events_url":"https://api.github.com/users/chaordic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chaordic/frontend-intern-challenge","description":"Desafio para os futuros front-end's da Linx+Neemu+Chaordic","fork":false,"url":"https://api.github.com/repos/chaordic/frontend-intern-challenge","forks_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/forks","keys_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/teams","hooks_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/hooks","issue_events_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/issues/events{/number}","events_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/events","assignees_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/assignees{/user}","branches_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/branches{/branch}","tags_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/tags","blobs_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/git/refs{/sha}","trees_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/statuses/{sha}","languages_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/languages","stargazers_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/stargazers","contributors_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/contributors","subscribers_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/subscribers","subscription_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/subscription","commits_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/commits{/sha}","git_commits_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/git/commits{/sha}","comments_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/comments{/number}","issue_comment_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/issues/comments{/number}","contents_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/contents/{+path}","compare_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/merges","archive_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/downloads","issues_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/issues{/number}","pulls_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/pulls{/number}","milestones_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/milestones{/number}","notifications_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/labels{/name}","releases_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/releases{/id}","deployments_url":"https://api.github.com/repos/chaordic/frontend-intern-challenge/deployments","created_at":"2016-03-17T17:10:32Z","updated_at":"2016-07-20T02:05:49Z","pushed_at":"2016-07-21T01:56:28Z","git_url":"git://github.com/chaordic/frontend-intern-challenge.git","ssh_url":"git@github.com:chaordic/frontend-intern-challenge.git","clone_url":"https://github.com/chaordic/frontend-intern-challenge.git","svn_url":"https://github.com/chaordic/frontend-intern-challenge","homepage":"","size":10873,"stargazers_count":36,"watchers_count":36,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":44,"mirror_url":null,"open_issues_count":7,"forks":44,"open_issues":7,"watchers":36,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chaordic/frontend-intern-challenge/pulls/27"},"html":{"href":"https://github.com/chaordic/frontend-intern-challenge/pull/27"},"issue":{"href":"https://api.github.com/repos/chaordic/frontend-intern-challenge/issues/27"},"comments":{"href":"https://api.github.com/repos/chaordic/frontend-intern-challenge/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/chaordic/frontend-intern-challenge/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/chaordic/frontend-intern-challenge/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chaordic/frontend-intern-challenge/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/chaordic/frontend-intern-challenge/statuses/df03ae117bc974d5beef596abf8b3d1c0837da1f"}}}}
{"actor":{"display_login":"legraeff"}}