{"action":"created","comment":{"url":"https://api.github.com/repos/lfields90/Study-Buddy/pulls/comments/34297266","id":34297266,"diff_hunk":"@@ -16,3 +16,83 @@\n //= require_tree .\n \n $(function(){ $(document).foundation(); });\n+\n+function vote(n, yesno) {\n+  var revoke = document.getElementsByClassName(\"revoke\");\n+  var upvote = document.getElementsByClassName(\"upvote\");\n+  var downvote = document.getElementsByClassName(\"downvote\");\n+  var spots = document.getElementsByClassName(\"spot_number\");\n+  var reviews = document.getElementsByClassName(\"review_number\");\n+  var vote = document.getElementsByClassName(\"votes\");\n+  var votes = parseInt(vote[n].innerHTML);\n+  vote[n].innerHTML = (votes += yesno);\n+  $.ajax({\n+    type: 'PATCH',\n+    url:  \"/spots/\" + spots[n].innerHTML + \"/reviews/\" + reviews[n].innerHTML + \"/downvote\"\n+  });\n+  var data = {\n+    \"user_id\": parseInt(document.getElementById(\"user_number\").innerHTML),\n+    \"review_id\": parseInt(reviews[n].innerHTML),\n+    \"spot_id\": parseInt(spots[n].innerHTML),\n+    \"vote_value\": yesno\n+  };\n+  $.ajax({\n+    type: 'POST',\n+    url:  \"/votes\",\n+    contentType: \"application/json\",\n+        dataType: \"json\",\n+        data: JSON.stringify(data),\n+        success: function(response) {\n+            console.log(response);\n+        },\n+        error: function(response) {\n+            console.log(response);\n+        }\n+  });\n+  revoke[n].style.display = \"inline-block\";\n+  upvote[n].style.display = \"none\";\n+  downvote[n].style.display = \"none\";\n+};\n+\n+\n+\n+function revoke(n) {\n+  var reviews = document.getElementsByClassName(\"review_number\");\n+  $.ajax({\n+    type: 'DELETE',\n+    url:  \"/votes/\" + reviews[n].innerHTML,\n+    success: function(response) {\n+        console.log(response);\n+        if (Number(response.statusText) < 0) {\n+          var spots = document.getElementsByClassName(\"spot_number\");\n+          var reviews = document.getElementsByClassName(\"review_number\");\n+          var vote = document.getElementsByClassName(\"votes\");\n+          var votes = parseInt(vote[n].innerHTML);\n+          vote[n].innerHTML = (votes += 1);\n+          $.ajax({\n+            type: 'PATCH',\n+            url:  \"/spots/\" + spots[n].innerHTML + \"/reviews/\" + reviews[n].innerHTML + \"/upvote\"\n+          });\n+        } else {\n+          var spots = document.getElementsByClassName(\"spot_number\");\n+          var reviews = document.getElementsByClassName(\"review_number\");\n+          var vote = document.getElementsByClassName(\"votes\");\n+          var votes = (parseInt(vote[n].innerHTML));\n+          vote[n].innerHTML = (votes -= 1);\n+          $.ajax({\n+            type: 'PATCH',","path":"app/assets/javascripts/application.js","position":68,"original_position":68,"commit_id":"e84d6c05212dc0e054b2a162d960172e2b9e3e6e","original_commit_id":"e84d6c05212dc0e054b2a162d960172e2b9e3e6e","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Mixed double and single quotes.","created_at":"2015-07-09T20:05:30Z","updated_at":"2015-07-09T20:05:30Z","html_url":"https://github.com/lfields90/Study-Buddy/pull/18#discussion_r34297266","pull_request_url":"https://api.github.com/repos/lfields90/Study-Buddy/pulls/18","_links":{"self":{"href":"https://api.github.com/repos/lfields90/Study-Buddy/pulls/comments/34297266"},"html":{"href":"https://github.com/lfields90/Study-Buddy/pull/18#discussion_r34297266"},"pull_request":{"href":"https://api.github.com/repos/lfields90/Study-Buddy/pulls/18"}}},"pull_request":{"url":"https://api.github.com/repos/lfields90/Study-Buddy/pulls/18","id":39621705,"html_url":"https://github.com/lfields90/Study-Buddy/pull/18","diff_url":"https://github.com/lfields90/Study-Buddy/pull/18.diff","patch_url":"https://github.com/lfields90/Study-Buddy/pull/18.patch","issue_url":"https://api.github.com/repos/lfields90/Study-Buddy/issues/18","number":18,"state":"open","locked":false,"title":"Upvote and tests","user":{"login":"NoraDelaney","id":11383263,"avatar_url":"https://avatars.githubusercontent.com/u/11383263?v=3","gravatar_id":"","url":"https://api.github.com/users/NoraDelaney","html_url":"https://github.com/NoraDelaney","followers_url":"https://api.github.com/users/NoraDelaney/followers","following_url":"https://api.github.com/users/NoraDelaney/following{/other_user}","gists_url":"https://api.github.com/users/NoraDelaney/gists{/gist_id}","starred_url":"https://api.github.com/users/NoraDelaney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NoraDelaney/subscriptions","organizations_url":"https://api.github.com/users/NoraDelaney/orgs","repos_url":"https://api.github.com/users/NoraDelaney/repos","events_url":"https://api.github.com/users/NoraDelaney/events{/privacy}","received_events_url":"https://api.github.com/users/NoraDelaney/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-09T19:55:28Z","updated_at":"2015-07-09T20:05:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f53b0ef5ce2d074c0398529be61eef3fff0c43be","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lfields90/Study-Buddy/pulls/18/commits","review_comments_url":"https://api.github.com/repos/lfields90/Study-Buddy/pulls/18/comments","review_comment_url":"https://api.github.com/repos/lfields90/Study-Buddy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lfields90/Study-Buddy/issues/18/comments","statuses_url":"https://api.github.com/repos/lfields90/Study-Buddy/statuses/e84d6c05212dc0e054b2a162d960172e2b9e3e6e","head":{"label":"lfields90:upvote","ref":"upvote","sha":"e84d6c05212dc0e054b2a162d960172e2b9e3e6e","user":{"login":"lfields90","id":11277816,"avatar_url":"https://avatars.githubusercontent.com/u/11277816?v=3","gravatar_id":"","url":"https://api.github.com/users/lfields90","html_url":"https://github.com/lfields90","followers_url":"https://api.github.com/users/lfields90/followers","following_url":"https://api.github.com/users/lfields90/following{/other_user}","gists_url":"https://api.github.com/users/lfields90/gists{/gist_id}","starred_url":"https://api.github.com/users/lfields90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lfields90/subscriptions","organizations_url":"https://api.github.com/users/lfields90/orgs","repos_url":"https://api.github.com/users/lfields90/repos","events_url":"https://api.github.com/users/lfields90/events{/privacy}","received_events_url":"https://api.github.com/users/lfields90/received_events","type":"User","site_admin":false},"repo":{"id":38254796,"name":"Study-Buddy","full_name":"lfields90/Study-Buddy","owner":{"login":"lfields90","id":11277816,"avatar_url":"https://avatars.githubusercontent.com/u/11277816?v=3","gravatar_id":"","url":"https://api.github.com/users/lfields90","html_url":"https://github.com/lfields90","followers_url":"https://api.github.com/users/lfields90/followers","following_url":"https://api.github.com/users/lfields90/following{/other_user}","gists_url":"https://api.github.com/users/lfields90/gists{/gist_id}","starred_url":"https://api.github.com/users/lfields90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lfields90/subscriptions","organizations_url":"https://api.github.com/users/lfields90/orgs","repos_url":"https://api.github.com/users/lfields90/repos","events_url":"https://api.github.com/users/lfields90/events{/privacy}","received_events_url":"https://api.github.com/users/lfields90/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lfields90/Study-Buddy","description":"Small Group Project","fork":false,"url":"https://api.github.com/repos/lfields90/Study-Buddy","forks_url":"https://api.github.com/repos/lfields90/Study-Buddy/forks","keys_url":"https://api.github.com/repos/lfields90/Study-Buddy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lfields90/Study-Buddy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lfields90/Study-Buddy/teams","hooks_url":"https://api.github.com/repos/lfields90/Study-Buddy/hooks","issue_events_url":"https://api.github.com/repos/lfields90/Study-Buddy/issues/events{/number}","events_url":"https://api.github.com/repos/lfields90/Study-Buddy/events","assignees_url":"https://api.github.com/repos/lfields90/Study-Buddy/assignees{/user}","branches_url":"https://api.github.com/repos/lfields90/Study-Buddy/branches{/branch}","tags_url":"https://api.github.com/repos/lfields90/Study-Buddy/tags","blobs_url":"https://api.github.com/repos/lfields90/Study-Buddy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lfields90/Study-Buddy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lfields90/Study-Buddy/git/refs{/sha}","trees_url":"https://api.github.com/repos/lfields90/Study-Buddy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lfields90/Study-Buddy/statuses/{sha}","languages_url":"https://api.github.com/repos/lfields90/Study-Buddy/languages","stargazers_url":"https://api.github.com/repos/lfields90/Study-Buddy/stargazers","contributors_url":"https://api.github.com/repos/lfields90/Study-Buddy/contributors","subscribers_url":"https://api.github.com/repos/lfields90/Study-Buddy/subscribers","subscription_url":"https://api.github.com/repos/lfields90/Study-Buddy/subscription","commits_url":"https://api.github.com/repos/lfields90/Study-Buddy/commits{/sha}","git_commits_url":"https://api.github.com/repos/lfields90/Study-Buddy/git/commits{/sha}","comments_url":"https://api.github.com/repos/lfields90/Study-Buddy/comments{/number}","issue_comment_url":"https://api.github.com/repos/lfields90/Study-Buddy/issues/comments{/number}","contents_url":"https://api.github.com/repos/lfields90/Study-Buddy/contents/{+path}","compare_url":"https://api.github.com/repos/lfields90/Study-Buddy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lfields90/Study-Buddy/merges","archive_url":"https://api.github.com/repos/lfields90/Study-Buddy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lfields90/Study-Buddy/downloads","issues_url":"https://api.github.com/repos/lfields90/Study-Buddy/issues{/number}","pulls_url":"https://api.github.com/repos/lfields90/Study-Buddy/pulls{/number}","milestones_url":"https://api.github.com/repos/lfields90/Study-Buddy/milestones{/number}","notifications_url":"https://api.github.com/repos/lfields90/Study-Buddy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lfields90/Study-Buddy/labels{/name}","releases_url":"https://api.github.com/repos/lfields90/Study-Buddy/releases{/id}","created_at":"2015-06-29T15:22:31Z","updated_at":"2015-07-07T03:25:52Z","pushed_at":"2015-07-09T20:05:18Z","git_url":"git://github.com/lfields90/Study-Buddy.git","ssh_url":"git@github.com:lfields90/Study-Buddy.git","clone_url":"https://github.com/lfields90/Study-Buddy.git","svn_url":"https://github.com/lfields90/Study-Buddy","homepage":null,"size":536,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":2,"default_branch":"master"}},"base":{"label":"lfields90:master","ref":"master","sha":"d9591487a8dc623840690c623196644fd0761a71","user":{"login":"lfields90","id":11277816,"avatar_url":"https://avatars.githubusercontent.com/u/11277816?v=3","gravatar_id":"","url":"https://api.github.com/users/lfields90","html_url":"https://github.com/lfields90","followers_url":"https://api.github.com/users/lfields90/followers","following_url":"https://api.github.com/users/lfields90/following{/other_user}","gists_url":"https://api.github.com/users/lfields90/gists{/gist_id}","starred_url":"https://api.github.com/users/lfields90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lfields90/subscriptions","organizations_url":"https://api.github.com/users/lfields90/orgs","repos_url":"https://api.github.com/users/lfields90/repos","events_url":"https://api.github.com/users/lfields90/events{/privacy}","received_events_url":"https://api.github.com/users/lfields90/received_events","type":"User","site_admin":false},"repo":{"id":38254796,"name":"Study-Buddy","full_name":"lfields90/Study-Buddy","owner":{"login":"lfields90","id":11277816,"avatar_url":"https://avatars.githubusercontent.com/u/11277816?v=3","gravatar_id":"","url":"https://api.github.com/users/lfields90","html_url":"https://github.com/lfields90","followers_url":"https://api.github.com/users/lfields90/followers","following_url":"https://api.github.com/users/lfields90/following{/other_user}","gists_url":"https://api.github.com/users/lfields90/gists{/gist_id}","starred_url":"https://api.github.com/users/lfields90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lfields90/subscriptions","organizations_url":"https://api.github.com/users/lfields90/orgs","repos_url":"https://api.github.com/users/lfields90/repos","events_url":"https://api.github.com/users/lfields90/events{/privacy}","received_events_url":"https://api.github.com/users/lfields90/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lfields90/Study-Buddy","description":"Small Group Project","fork":false,"url":"https://api.github.com/repos/lfields90/Study-Buddy","forks_url":"https://api.github.com/repos/lfields90/Study-Buddy/forks","keys_url":"https://api.github.com/repos/lfields90/Study-Buddy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lfields90/Study-Buddy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lfields90/Study-Buddy/teams","hooks_url":"https://api.github.com/repos/lfields90/Study-Buddy/hooks","issue_events_url":"https://api.github.com/repos/lfields90/Study-Buddy/issues/events{/number}","events_url":"https://api.github.com/repos/lfields90/Study-Buddy/events","assignees_url":"https://api.github.com/repos/lfields90/Study-Buddy/assignees{/user}","branches_url":"https://api.github.com/repos/lfields90/Study-Buddy/branches{/branch}","tags_url":"https://api.github.com/repos/lfields90/Study-Buddy/tags","blobs_url":"https://api.github.com/repos/lfields90/Study-Buddy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lfields90/Study-Buddy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lfields90/Study-Buddy/git/refs{/sha}","trees_url":"https://api.github.com/repos/lfields90/Study-Buddy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lfields90/Study-Buddy/statuses/{sha}","languages_url":"https://api.github.com/repos/lfields90/Study-Buddy/languages","stargazers_url":"https://api.github.com/repos/lfields90/Study-Buddy/stargazers","contributors_url":"https://api.github.com/repos/lfields90/Study-Buddy/contributors","subscribers_url":"https://api.github.com/repos/lfields90/Study-Buddy/subscribers","subscription_url":"https://api.github.com/repos/lfields90/Study-Buddy/subscription","commits_url":"https://api.github.com/repos/lfields90/Study-Buddy/commits{/sha}","git_commits_url":"https://api.github.com/repos/lfields90/Study-Buddy/git/commits{/sha}","comments_url":"https://api.github.com/repos/lfields90/Study-Buddy/comments{/number}","issue_comment_url":"https://api.github.com/repos/lfields90/Study-Buddy/issues/comments{/number}","contents_url":"https://api.github.com/repos/lfields90/Study-Buddy/contents/{+path}","compare_url":"https://api.github.com/repos/lfields90/Study-Buddy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lfields90/Study-Buddy/merges","archive_url":"https://api.github.com/repos/lfields90/Study-Buddy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lfields90/Study-Buddy/downloads","issues_url":"https://api.github.com/repos/lfields90/Study-Buddy/issues{/number}","pulls_url":"https://api.github.com/repos/lfields90/Study-Buddy/pulls{/number}","milestones_url":"https://api.github.com/repos/lfields90/Study-Buddy/milestones{/number}","notifications_url":"https://api.github.com/repos/lfields90/Study-Buddy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lfields90/Study-Buddy/labels{/name}","releases_url":"https://api.github.com/repos/lfields90/Study-Buddy/releases{/id}","created_at":"2015-06-29T15:22:31Z","updated_at":"2015-07-07T03:25:52Z","pushed_at":"2015-07-09T20:05:18Z","git_url":"git://github.com/lfields90/Study-Buddy.git","ssh_url":"git@github.com:lfields90/Study-Buddy.git","clone_url":"https://github.com/lfields90/Study-Buddy.git","svn_url":"https://github.com/lfields90/Study-Buddy","homepage":null,"size":536,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lfields90/Study-Buddy/pulls/18"},"html":{"href":"https://github.com/lfields90/Study-Buddy/pull/18"},"issue":{"href":"https://api.github.com/repos/lfields90/Study-Buddy/issues/18"},"comments":{"href":"https://api.github.com/repos/lfields90/Study-Buddy/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/lfields90/Study-Buddy/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/lfields90/Study-Buddy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lfields90/Study-Buddy/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/lfields90/Study-Buddy/statuses/e84d6c05212dc0e054b2a162d960172e2b9e3e6e"}}}}