{"action":"created","comment":{"url":"https://api.github.com/repos/sf-interns/mathswipe/pulls/comments/36220061","id":36220061,"diff_hunk":"@@ -0,0 +1,66 @@\n+$ = require 'jquery'\n+\n+class ClickHandler\n+\n+  constructor: (@board, two, @clicked = []) ->\n+    return unless @board.cells?\n+    for row in @board.cells\n+      break if row.length is 0\n+      for cell in row\n+        (@addToClicked cell) if cell.isSelected\n+\n+  bindDefaultClick: (board) ->\n+    $('body').click (e) =>\n+      e.preventDefault()\n+      @resetClicked()\n+\n+  bindClickTo: (cells) ->\n+    if cells.bindClick?\n+      cells.bindClick() \n+      return\n+    for row in cells\n+      if row.bindClick?\n+        row.bindClick()\n+        return\n+      for cell in row\n+        if cell.bindClick?\n+          cell.bindClick()\n+        else\n+          console.log 'WARN: object not 2D arrays or simpler or no BindClick method'\n+\n+  addToClicked: (cell) ->\n+    return if cell.isDeleted\n+    @clicked.push cell\n+\n+  removeFromClicked: (cell) ->\n+    @clicked.pop()\n+\n+  resetClicked: ->\n+    @unclickCell @lastClicked() for numClicked in [@clicked.length...0]\n+\n+  firstClicked: ->\n+    @clicked[0]\n+\n+  lastClicked: ->\n+    @clicked[@clicked.length - 1]\n+\n+  clickCell: (cell) ->\n+    # if cell is adjacent to lastClicked\n+    if @clicked.length is 0 or @areAdjacent cell, @lastClicked()\n+      return if @cell in @clicked\n+      cell.select()\n+      @addToClicked cell\n+    else\n+      @resetClicked()\n+      @clickCell cell\n+\n+  areAdjacent: (cell, otherCell) ->\n+    return Math.abs(cell.row - otherCell.row) <= 1 and Math.abs(cell.col - otherCell.col) <= 1\n+\n+  unclickCell: (cell) ->\n+    last = @lastClicked()\n+    return null unless cell is @lastClicked()\n+    cell.unSelect()\n+    @removeFromClicked cell","path":"app/services/ClickHandler.coffee","position":64,"original_position":64,"commit_id":"8061711c487b8bc6425a5482d2e9a2a36584c1e7","original_commit_id":"8061711c487b8bc6425a5482d2e9a2a36584c1e7","user":{"login":"s-gogna","id":8852959,"avatar_url":"https://avatars.githubusercontent.com/u/8852959?v=3","gravatar_id":"","url":"https://api.github.com/users/s-gogna","html_url":"https://github.com/s-gogna","followers_url":"https://api.github.com/users/s-gogna/followers","following_url":"https://api.github.com/users/s-gogna/following{/other_user}","gists_url":"https://api.github.com/users/s-gogna/gists{/gist_id}","starred_url":"https://api.github.com/users/s-gogna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s-gogna/subscriptions","organizations_url":"https://api.github.com/users/s-gogna/orgs","repos_url":"https://api.github.com/users/s-gogna/repos","events_url":"https://api.github.com/users/s-gogna/events{/privacy}","received_events_url":"https://api.github.com/users/s-gogna/received_events","type":"User","site_admin":false},"body":"```\r\nif cell is @lastClicked()\r\n  cell.unSelect()\r\n  @removeFromClicked cell\r\nelse return null\r\n```","created_at":"2015-08-04T17:58:46Z","updated_at":"2015-08-04T17:58:46Z","html_url":"https://github.com/sf-interns/mathswipe/pull/23#discussion_r36220061","pull_request_url":"https://api.github.com/repos/sf-interns/mathswipe/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/sf-interns/mathswipe/pulls/comments/36220061"},"html":{"href":"https://github.com/sf-interns/mathswipe/pull/23#discussion_r36220061"},"pull_request":{"href":"https://api.github.com/repos/sf-interns/mathswipe/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/sf-interns/mathswipe/pulls/23","id":41532354,"html_url":"https://github.com/sf-interns/mathswipe/pull/23","diff_url":"https://github.com/sf-interns/mathswipe/pull/23.diff","patch_url":"https://github.com/sf-interns/mathswipe/pull/23.patch","issue_url":"https://api.github.com/repos/sf-interns/mathswipe/issues/23","number":23,"state":"open","locked":false,"title":"EC Mouse Events","user":{"login":"ericthewry","id":10351855,"avatar_url":"https://avatars.githubusercontent.com/u/10351855?v=3","gravatar_id":"","url":"https://api.github.com/users/ericthewry","html_url":"https://github.com/ericthewry","followers_url":"https://api.github.com/users/ericthewry/followers","following_url":"https://api.github.com/users/ericthewry/following{/other_user}","gists_url":"https://api.github.com/users/ericthewry/gists{/gist_id}","starred_url":"https://api.github.com/users/ericthewry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericthewry/subscriptions","organizations_url":"https://api.github.com/users/ericthewry/orgs","repos_url":"https://api.github.com/users/ericthewry/repos","events_url":"https://api.github.com/users/ericthewry/events{/privacy}","received_events_url":"https://api.github.com/users/ericthewry/received_events","type":"User","site_admin":false},"body":"[WIP] This mostly works.. A bug or two just needs fixing.  Feel free to leave style comments","created_at":"2015-08-04T03:54:59Z","updated_at":"2015-08-04T17:58:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9c57b96eb33c970ec133da5fcfbf1d715bdeb3a9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sf-interns/mathswipe/pulls/23/commits","review_comments_url":"https://api.github.com/repos/sf-interns/mathswipe/pulls/23/comments","review_comment_url":"https://api.github.com/repos/sf-interns/mathswipe/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sf-interns/mathswipe/issues/23/comments","statuses_url":"https://api.github.com/repos/sf-interns/mathswipe/statuses/8061711c487b8bc6425a5482d2e9a2a36584c1e7","head":{"label":"sf-interns:ec-mouse-events","ref":"ec-mouse-events","sha":"8061711c487b8bc6425a5482d2e9a2a36584c1e7","user":{"login":"sf-interns","id":13339620,"avatar_url":"https://avatars.githubusercontent.com/u/13339620?v=3","gravatar_id":"","url":"https://api.github.com/users/sf-interns","html_url":"https://github.com/sf-interns","followers_url":"https://api.github.com/users/sf-interns/followers","following_url":"https://api.github.com/users/sf-interns/following{/other_user}","gists_url":"https://api.github.com/users/sf-interns/gists{/gist_id}","starred_url":"https://api.github.com/users/sf-interns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sf-interns/subscriptions","organizations_url":"https://api.github.com/users/sf-interns/orgs","repos_url":"https://api.github.com/users/sf-interns/repos","events_url":"https://api.github.com/users/sf-interns/events{/privacy}","received_events_url":"https://api.github.com/users/sf-interns/received_events","type":"Organization","site_admin":false},"repo":{"id":39095076,"name":"mathswipe","full_name":"sf-interns/mathswipe","owner":{"login":"sf-interns","id":13339620,"avatar_url":"https://avatars.githubusercontent.com/u/13339620?v=3","gravatar_id":"","url":"https://api.github.com/users/sf-interns","html_url":"https://github.com/sf-interns","followers_url":"https://api.github.com/users/sf-interns/followers","following_url":"https://api.github.com/users/sf-interns/following{/other_user}","gists_url":"https://api.github.com/users/sf-interns/gists{/gist_id}","starred_url":"https://api.github.com/users/sf-interns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sf-interns/subscriptions","organizations_url":"https://api.github.com/users/sf-interns/orgs","repos_url":"https://api.github.com/users/sf-interns/repos","events_url":"https://api.github.com/users/sf-interns/events{/privacy}","received_events_url":"https://api.github.com/users/sf-interns/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sf-interns/mathswipe","description":"A game with numbers","fork":false,"url":"https://api.github.com/repos/sf-interns/mathswipe","forks_url":"https://api.github.com/repos/sf-interns/mathswipe/forks","keys_url":"https://api.github.com/repos/sf-interns/mathswipe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sf-interns/mathswipe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sf-interns/mathswipe/teams","hooks_url":"https://api.github.com/repos/sf-interns/mathswipe/hooks","issue_events_url":"https://api.github.com/repos/sf-interns/mathswipe/issues/events{/number}","events_url":"https://api.github.com/repos/sf-interns/mathswipe/events","assignees_url":"https://api.github.com/repos/sf-interns/mathswipe/assignees{/user}","branches_url":"https://api.github.com/repos/sf-interns/mathswipe/branches{/branch}","tags_url":"https://api.github.com/repos/sf-interns/mathswipe/tags","blobs_url":"https://api.github.com/repos/sf-interns/mathswipe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sf-interns/mathswipe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sf-interns/mathswipe/git/refs{/sha}","trees_url":"https://api.github.com/repos/sf-interns/mathswipe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sf-interns/mathswipe/statuses/{sha}","languages_url":"https://api.github.com/repos/sf-interns/mathswipe/languages","stargazers_url":"https://api.github.com/repos/sf-interns/mathswipe/stargazers","contributors_url":"https://api.github.com/repos/sf-interns/mathswipe/contributors","subscribers_url":"https://api.github.com/repos/sf-interns/mathswipe/subscribers","subscription_url":"https://api.github.com/repos/sf-interns/mathswipe/subscription","commits_url":"https://api.github.com/repos/sf-interns/mathswipe/commits{/sha}","git_commits_url":"https://api.github.com/repos/sf-interns/mathswipe/git/commits{/sha}","comments_url":"https://api.github.com/repos/sf-interns/mathswipe/comments{/number}","issue_comment_url":"https://api.github.com/repos/sf-interns/mathswipe/issues/comments{/number}","contents_url":"https://api.github.com/repos/sf-interns/mathswipe/contents/{+path}","compare_url":"https://api.github.com/repos/sf-interns/mathswipe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sf-interns/mathswipe/merges","archive_url":"https://api.github.com/repos/sf-interns/mathswipe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sf-interns/mathswipe/downloads","issues_url":"https://api.github.com/repos/sf-interns/mathswipe/issues{/number}","pulls_url":"https://api.github.com/repos/sf-interns/mathswipe/pulls{/number}","milestones_url":"https://api.github.com/repos/sf-interns/mathswipe/milestones{/number}","notifications_url":"https://api.github.com/repos/sf-interns/mathswipe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sf-interns/mathswipe/labels{/name}","releases_url":"https://api.github.com/repos/sf-interns/mathswipe/releases{/id}","created_at":"2015-07-14T19:09:17Z","updated_at":"2015-08-02T06:55:09Z","pushed_at":"2015-08-04T17:45:14Z","git_url":"git://github.com/sf-interns/mathswipe.git","ssh_url":"git@github.com:sf-interns/mathswipe.git","clone_url":"https://github.com/sf-interns/mathswipe.git","svn_url":"https://github.com/sf-interns/mathswipe","homepage":"https://sf-interns.github.io/mathswipe","size":700,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"sf-interns:master","ref":"master","sha":"3483bd6e2228447a02fe8742b1701f90b18a19d2","user":{"login":"sf-interns","id":13339620,"avatar_url":"https://avatars.githubusercontent.com/u/13339620?v=3","gravatar_id":"","url":"https://api.github.com/users/sf-interns","html_url":"https://github.com/sf-interns","followers_url":"https://api.github.com/users/sf-interns/followers","following_url":"https://api.github.com/users/sf-interns/following{/other_user}","gists_url":"https://api.github.com/users/sf-interns/gists{/gist_id}","starred_url":"https://api.github.com/users/sf-interns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sf-interns/subscriptions","organizations_url":"https://api.github.com/users/sf-interns/orgs","repos_url":"https://api.github.com/users/sf-interns/repos","events_url":"https://api.github.com/users/sf-interns/events{/privacy}","received_events_url":"https://api.github.com/users/sf-interns/received_events","type":"Organization","site_admin":false},"repo":{"id":39095076,"name":"mathswipe","full_name":"sf-interns/mathswipe","owner":{"login":"sf-interns","id":13339620,"avatar_url":"https://avatars.githubusercontent.com/u/13339620?v=3","gravatar_id":"","url":"https://api.github.com/users/sf-interns","html_url":"https://github.com/sf-interns","followers_url":"https://api.github.com/users/sf-interns/followers","following_url":"https://api.github.com/users/sf-interns/following{/other_user}","gists_url":"https://api.github.com/users/sf-interns/gists{/gist_id}","starred_url":"https://api.github.com/users/sf-interns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sf-interns/subscriptions","organizations_url":"https://api.github.com/users/sf-interns/orgs","repos_url":"https://api.github.com/users/sf-interns/repos","events_url":"https://api.github.com/users/sf-interns/events{/privacy}","received_events_url":"https://api.github.com/users/sf-interns/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sf-interns/mathswipe","description":"A game with numbers","fork":false,"url":"https://api.github.com/repos/sf-interns/mathswipe","forks_url":"https://api.github.com/repos/sf-interns/mathswipe/forks","keys_url":"https://api.github.com/repos/sf-interns/mathswipe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sf-interns/mathswipe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sf-interns/mathswipe/teams","hooks_url":"https://api.github.com/repos/sf-interns/mathswipe/hooks","issue_events_url":"https://api.github.com/repos/sf-interns/mathswipe/issues/events{/number}","events_url":"https://api.github.com/repos/sf-interns/mathswipe/events","assignees_url":"https://api.github.com/repos/sf-interns/mathswipe/assignees{/user}","branches_url":"https://api.github.com/repos/sf-interns/mathswipe/branches{/branch}","tags_url":"https://api.github.com/repos/sf-interns/mathswipe/tags","blobs_url":"https://api.github.com/repos/sf-interns/mathswipe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sf-interns/mathswipe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sf-interns/mathswipe/git/refs{/sha}","trees_url":"https://api.github.com/repos/sf-interns/mathswipe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sf-interns/mathswipe/statuses/{sha}","languages_url":"https://api.github.com/repos/sf-interns/mathswipe/languages","stargazers_url":"https://api.github.com/repos/sf-interns/mathswipe/stargazers","contributors_url":"https://api.github.com/repos/sf-interns/mathswipe/contributors","subscribers_url":"https://api.github.com/repos/sf-interns/mathswipe/subscribers","subscription_url":"https://api.github.com/repos/sf-interns/mathswipe/subscription","commits_url":"https://api.github.com/repos/sf-interns/mathswipe/commits{/sha}","git_commits_url":"https://api.github.com/repos/sf-interns/mathswipe/git/commits{/sha}","comments_url":"https://api.github.com/repos/sf-interns/mathswipe/comments{/number}","issue_comment_url":"https://api.github.com/repos/sf-interns/mathswipe/issues/comments{/number}","contents_url":"https://api.github.com/repos/sf-interns/mathswipe/contents/{+path}","compare_url":"https://api.github.com/repos/sf-interns/mathswipe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sf-interns/mathswipe/merges","archive_url":"https://api.github.com/repos/sf-interns/mathswipe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sf-interns/mathswipe/downloads","issues_url":"https://api.github.com/repos/sf-interns/mathswipe/issues{/number}","pulls_url":"https://api.github.com/repos/sf-interns/mathswipe/pulls{/number}","milestones_url":"https://api.github.com/repos/sf-interns/mathswipe/milestones{/number}","notifications_url":"https://api.github.com/repos/sf-interns/mathswipe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sf-interns/mathswipe/labels{/name}","releases_url":"https://api.github.com/repos/sf-interns/mathswipe/releases{/id}","created_at":"2015-07-14T19:09:17Z","updated_at":"2015-08-02T06:55:09Z","pushed_at":"2015-08-04T17:45:14Z","git_url":"git://github.com/sf-interns/mathswipe.git","ssh_url":"git@github.com:sf-interns/mathswipe.git","clone_url":"https://github.com/sf-interns/mathswipe.git","svn_url":"https://github.com/sf-interns/mathswipe","homepage":"https://sf-interns.github.io/mathswipe","size":700,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sf-interns/mathswipe/pulls/23"},"html":{"href":"https://github.com/sf-interns/mathswipe/pull/23"},"issue":{"href":"https://api.github.com/repos/sf-interns/mathswipe/issues/23"},"comments":{"href":"https://api.github.com/repos/sf-interns/mathswipe/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/sf-interns/mathswipe/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/sf-interns/mathswipe/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sf-interns/mathswipe/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/sf-interns/mathswipe/statuses/8061711c487b8bc6425a5482d2e9a2a36584c1e7"}}}}