{"action":"created","comment":{"url":"https://api.github.com/repos/square/metrics/pulls/comments/33330205","id":33330205,"diff_hunk":"@@ -0,0 +1,400 @@\n+// Copyright 2015 Square Inc.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+// http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+window.Autocom = (function(){\n+\"use strict\";\n+\n+// Creates an Autocompleting textarea within the given HTML element.\n+// The element should be relative/absolute/fixed position to render correctly.\n+// CSS classes can select the following elements:\n+//   * autocom-tooltip-line       a single line within the tooltip\n+//   * autocom-tooltip-selected   the selected line within the tooltip\n+//   * autocom-tooltip-box        the box which contains the lines for the tooltip\n+\n+// Example JS:\n+/*\n+\t// Select a textarea\n+\tvar input = document.getElementById(\"color_entry\");\n+\n+\t// Create an Autocom object\n+\tvar colorCom = new Autocom(input);\n+\n+\t// Assign the options for our Autocom\n+\tcolorCom.options = [\"red\", \"orange\", \"yellow\", \"yellow-green\", \"green\", \"cyan\", \"blue\", \"purple\"];\n+\t\n+\t// Add the hyphen to the possible set of letters\n+\tcolorCom.letters = \"[a-z\\\\-]\";\n+\n+\t// Adjust the tooltip position offset\n+\tcolorCom.tooltipX = 25;\n+\tcolorCom.tooltipY = 0;\n+\n+\t// Configure the number of shown options  \n+\tcolorCom.config.count = 3;\n+*/\n+\n+/*\n+Fields:\n+\n+\telements: a set of the HTML elements associated with the Autocom form.\n+\t\tinput: the input textarea\n+\t\tshadow: an invisible (0-height) div used to calculate the marker location\n+\t\tprior: a span inside shadow used to calculate the marker position\n+\t\tmarker: a span inside shadow used to calculate cursor position\n+\t\tafter: a span inside shadow used to calculate marker position\n+\t\tholder: the element originally passed as an argument which holds all of these\n+\t\ttooltip: the tooltip elements which shows the suggests\n+\t\n+\toptions: (default []) an array of strings; these are the options which autocomplete suggests\n+\t\n+\tletter: (default \"[a-zA-Z]\") the regex to match a single non-separator\n+\n+\tconfig:\n+\t\tthreshold: (default 0)    // Autocomplete score threshold required to show (for fuzzy suggestions)\n+\t\tskipGiven: (default 2)    // Penalty for skipping a letter in the input\n+\t\tskipWord:  (default 0.25) // Pentalty for skipping a prefixed letter in the suggestion\n+\t\tcount:     (default 8)    // The maximum number of autocomplete suggestions shown \n+\n+\ttooltipX: (default 0) the X offset for the tooltip (relative to the cursor)\n+\ttooltipY: (default 0) the Y offset for the tooltip (relative to the cursor)\n+\n+Methods:\n+\n+\trefresh(): redraw the tooltip (or hide it) taking into account any changes to focus or fields.\n+\t         (this rarely needs to be called)\n+\n+*/\n+\n+// scoreTable uses the table for memoization and computes a modified LCS on A and B.\n+// The config contains parameters for this procedure.\n+function scoreTable(table, A, B, i, j, config) {\n+\tif (i >= A.length || j >= B.length) {\n+\t\treturn config.skipGiven * (i - A.length); // Don't penalize for the end of the second word\n+\t}\n+\tif (table[i][j] !== null) {\n+\t\treturn table[i][j];\n+\t}\n+\tif (A[i] == B[j]) {\n+\t\treturn table[i][j] = 1 / Math.sqrt(j+1) + scoreTable(table, A, B, i+1, j+1, config);\n+\t}\n+\tif (A[i].toLowerCase() === B[j].toLowerCase()) {\n+\t\treturn table[i][j] = 1 / Math.sqrt(j+1) * 0.5 + scoreTable(table, A, B, i+1, j+1, config);\n+\t}\n+\n+\t// Skipping letters in the left are penalized (but penalized less if they're special characters).\n+\tvar advanceI = scoreTable(table, A, B, i+1, j, config) - config.skipGiven;\n+\tvar advanceJ = scoreTable(table, A, B, i, j+1, config) - config.skipWord;\n+\n+\treturn table[i][j] = Math.max( advanceI, advanceJ );\n+}\n+\n+// scoreAgainst computes how well the \"letters\" match \"word\" (this is not commutative).\n+// The config contains parameters for the algorithm.\n+function scoreAgainst(letters, word, config) {\n+\tvar table = [];\n+\tfor (var i = 0; i < letters.length; i++) {\n+\t\ttable[i] = [];\n+\t\t\tfor (var j = 0; j < word.length; j++) {\n+\t\t\ttable[i][j] = null;\n+\t\t}\n+\t}\n+\tvar s = scoreTable(table, letters, word, 0, 0, config);\n+\treturn s;\n+}\n+\n+// generateElements creates the elements needed by an Autocom, based on the given input.\n+function generateElements(input) {\n+\tvar holder = input.parentElement;\n+\n+\tvar hider = document.createElement(\"div\");\n+\t// Hider completely hides its contents\n+\thider.style.width = \"0\";\n+\thider.style.height = \"0\";\n+\thider.style.margin = \"0\";\n+\thider.style.padding = \"0\";\n+\thider.style.outline = \"0\";\n+\thider.style.border = \"0\";\n+\thider.style.overflowX = \"hidden\";\n+\thider.style.overflowY = \"hidden\";\n+\tholder.insertBefore(hider, input);\n+\n+\tvar shadow = document.createElement(\"div\");\n+\t// Flow can be made possible simpler/more predictable if we insert before our input.\n+\thider.appendChild(shadow);\n+\n+\tvar prior = document.createElement(\"span\");\n+\tshadow.appendChild(prior);\n+\n+\tvar marker = document.createElement(\"span\");\n+\tshadow.appendChild(marker);\n+\n+\tvar after = document.createElement(\"span\");\n+\tshadow.appendChild(after);\n+\n+\tvar tooltip = document.createElement(\"div\");\n+\ttooltip.className = \"autocom-tooltip-box\";\n+\tholder.appendChild(tooltip);\n+\n+\treturn {\n+\t\tinput:   input,\n+\t\tholder:  holder,\n+\t\thider:   hider,\n+\t\tshadow:  shadow,\n+\t\tprior:   prior,\n+\t\tmarker:  marker,\n+\t\tafter:   after,\n+\t\ttooltip: tooltip\n+\t};\n+}\n+\n+// predictReady determines whether or not the input is ready for prediction,\n+// and it asks for something that matches non-separators.\n+function predictReady(input, letter) {\n+\tif (input.selectionStart !== input.selectionEnd) {\n+\t\treturn false;\n+\t}\n+\tvar at = input.selectionStart;\n+\tif (input.value.substring(at).match(\"^\" + letter)) {\n+\t\t// Can't be going from the middle of a word.\n+\t\treturn false;\n+\t}\n+\t// Must be a word prior to the cursor.\n+\tvar before = input.value.substring(0, at).match(\"(\" + letter + \")+$\");\n+\tif (before && before.length > 0) {\n+\t\treturn {from: at - before[0].length, word: before[0], to: at};\n+\t}\n+\treturn false;\n+}\n+\n+// filterCandidates finds a list of candidates, pursuant to the config, among the options\n+// from the given prefix `word`.\n+function filterCandidates(word, options, config) {","path":"main/static/autocom.js","position":181,"original_position":181,"commit_id":"bf35304faeb76a20f33d89324d474d45ff42c446","original_commit_id":"bf35304faeb76a20f33d89324d474d45ff42c446","user":{"login":"jeeyoungk","id":232784,"avatar_url":"https://avatars.githubusercontent.com/u/232784?v=3","gravatar_id":"","url":"https://api.github.com/users/jeeyoungk","html_url":"https://github.com/jeeyoungk","followers_url":"https://api.github.com/users/jeeyoungk/followers","following_url":"https://api.github.com/users/jeeyoungk/following{/other_user}","gists_url":"https://api.github.com/users/jeeyoungk/gists{/gist_id}","starred_url":"https://api.github.com/users/jeeyoungk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeeyoungk/subscriptions","organizations_url":"https://api.github.com/users/jeeyoungk/orgs","repos_url":"https://api.github.com/users/jeeyoungk/repos","events_url":"https://api.github.com/users/jeeyoungk/events{/privacy}","received_events_url":"https://api.github.com/users/jeeyoungk/received_events","type":"User","site_admin":false},"body":"rather return array all the time - much easier to deal with.","created_at":"2015-06-26T05:51:46Z","updated_at":"2015-06-26T05:51:46Z","html_url":"https://github.com/square/metrics/pull/124#discussion_r33330205","pull_request_url":"https://api.github.com/repos/square/metrics/pulls/124","_links":{"self":{"href":"https://api.github.com/repos/square/metrics/pulls/comments/33330205"},"html":{"href":"https://github.com/square/metrics/pull/124#discussion_r33330205"},"pull_request":{"href":"https://api.github.com/repos/square/metrics/pulls/124"}}},"pull_request":{"url":"https://api.github.com/repos/square/metrics/pulls/124","id":38598361,"html_url":"https://github.com/square/metrics/pull/124","diff_url":"https://github.com/square/metrics/pull/124.diff","patch_url":"https://github.com/square/metrics/pull/124.patch","issue_url":"https://api.github.com/repos/square/metrics/issues/124","number":124,"state":"open","locked":false,"title":"Autocomplete","user":{"login":"Nathan-Fenner","id":6179181,"avatar_url":"https://avatars.githubusercontent.com/u/6179181?v=3","gravatar_id":"","url":"https://api.github.com/users/Nathan-Fenner","html_url":"https://github.com/Nathan-Fenner","followers_url":"https://api.github.com/users/Nathan-Fenner/followers","following_url":"https://api.github.com/users/Nathan-Fenner/following{/other_user}","gists_url":"https://api.github.com/users/Nathan-Fenner/gists{/gist_id}","starred_url":"https://api.github.com/users/Nathan-Fenner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nathan-Fenner/subscriptions","organizations_url":"https://api.github.com/users/Nathan-Fenner/orgs","repos_url":"https://api.github.com/users/Nathan-Fenner/repos","events_url":"https://api.github.com/users/Nathan-Fenner/events{/privacy}","received_events_url":"https://api.github.com/users/Nathan-Fenner/received_events","type":"User","site_admin":false},"body":"Autocomplete only knows about keywords right now (and some of the functions).","created_at":"2015-06-25T22:00:11Z","updated_at":"2015-06-26T05:51:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"67e6e87c132f463fb289c8e8902b07d53c8ee693","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/square/metrics/pulls/124/commits","review_comments_url":"https://api.github.com/repos/square/metrics/pulls/124/comments","review_comment_url":"https://api.github.com/repos/square/metrics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/metrics/issues/124/comments","statuses_url":"https://api.github.com/repos/square/metrics/statuses/bf35304faeb76a20f33d89324d474d45ff42c446","head":{"label":"square:nathanf-autocomplete","ref":"nathanf-autocomplete","sha":"bf35304faeb76a20f33d89324d474d45ff42c446","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":34279409,"name":"metrics","full_name":"square/metrics","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/metrics","description":"Metrics Query Engine","fork":false,"url":"https://api.github.com/repos/square/metrics","forks_url":"https://api.github.com/repos/square/metrics/forks","keys_url":"https://api.github.com/repos/square/metrics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/metrics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/metrics/teams","hooks_url":"https://api.github.com/repos/square/metrics/hooks","issue_events_url":"https://api.github.com/repos/square/metrics/issues/events{/number}","events_url":"https://api.github.com/repos/square/metrics/events","assignees_url":"https://api.github.com/repos/square/metrics/assignees{/user}","branches_url":"https://api.github.com/repos/square/metrics/branches{/branch}","tags_url":"https://api.github.com/repos/square/metrics/tags","blobs_url":"https://api.github.com/repos/square/metrics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/metrics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/metrics/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/metrics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/metrics/statuses/{sha}","languages_url":"https://api.github.com/repos/square/metrics/languages","stargazers_url":"https://api.github.com/repos/square/metrics/stargazers","contributors_url":"https://api.github.com/repos/square/metrics/contributors","subscribers_url":"https://api.github.com/repos/square/metrics/subscribers","subscription_url":"https://api.github.com/repos/square/metrics/subscription","commits_url":"https://api.github.com/repos/square/metrics/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/metrics/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/metrics/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/metrics/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/metrics/contents/{+path}","compare_url":"https://api.github.com/repos/square/metrics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/metrics/merges","archive_url":"https://api.github.com/repos/square/metrics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/metrics/downloads","issues_url":"https://api.github.com/repos/square/metrics/issues{/number}","pulls_url":"https://api.github.com/repos/square/metrics/pulls{/number}","milestones_url":"https://api.github.com/repos/square/metrics/milestones{/number}","notifications_url":"https://api.github.com/repos/square/metrics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/metrics/labels{/name}","releases_url":"https://api.github.com/repos/square/metrics/releases{/id}","created_at":"2015-04-20T18:43:35Z","updated_at":"2015-06-25T07:59:06Z","pushed_at":"2015-06-26T00:29:34Z","git_url":"git://github.com/square/metrics.git","ssh_url":"git@github.com:square/metrics.git","clone_url":"https://github.com/square/metrics.git","svn_url":"https://github.com/square/metrics","homepage":"","size":4437,"stargazers_count":9,"watchers_count":9,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":9,"default_branch":"master"}},"base":{"label":"square:master","ref":"master","sha":"c36c2cb6980864ff8e2518c3588f5086d9497825","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":34279409,"name":"metrics","full_name":"square/metrics","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/metrics","description":"Metrics Query Engine","fork":false,"url":"https://api.github.com/repos/square/metrics","forks_url":"https://api.github.com/repos/square/metrics/forks","keys_url":"https://api.github.com/repos/square/metrics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/metrics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/metrics/teams","hooks_url":"https://api.github.com/repos/square/metrics/hooks","issue_events_url":"https://api.github.com/repos/square/metrics/issues/events{/number}","events_url":"https://api.github.com/repos/square/metrics/events","assignees_url":"https://api.github.com/repos/square/metrics/assignees{/user}","branches_url":"https://api.github.com/repos/square/metrics/branches{/branch}","tags_url":"https://api.github.com/repos/square/metrics/tags","blobs_url":"https://api.github.com/repos/square/metrics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/metrics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/metrics/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/metrics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/metrics/statuses/{sha}","languages_url":"https://api.github.com/repos/square/metrics/languages","stargazers_url":"https://api.github.com/repos/square/metrics/stargazers","contributors_url":"https://api.github.com/repos/square/metrics/contributors","subscribers_url":"https://api.github.com/repos/square/metrics/subscribers","subscription_url":"https://api.github.com/repos/square/metrics/subscription","commits_url":"https://api.github.com/repos/square/metrics/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/metrics/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/metrics/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/metrics/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/metrics/contents/{+path}","compare_url":"https://api.github.com/repos/square/metrics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/metrics/merges","archive_url":"https://api.github.com/repos/square/metrics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/metrics/downloads","issues_url":"https://api.github.com/repos/square/metrics/issues{/number}","pulls_url":"https://api.github.com/repos/square/metrics/pulls{/number}","milestones_url":"https://api.github.com/repos/square/metrics/milestones{/number}","notifications_url":"https://api.github.com/repos/square/metrics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/metrics/labels{/name}","releases_url":"https://api.github.com/repos/square/metrics/releases{/id}","created_at":"2015-04-20T18:43:35Z","updated_at":"2015-06-25T07:59:06Z","pushed_at":"2015-06-26T00:29:34Z","git_url":"git://github.com/square/metrics.git","ssh_url":"git@github.com:square/metrics.git","clone_url":"https://github.com/square/metrics.git","svn_url":"https://github.com/square/metrics","homepage":"","size":4437,"stargazers_count":9,"watchers_count":9,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/metrics/pulls/124"},"html":{"href":"https://github.com/square/metrics/pull/124"},"issue":{"href":"https://api.github.com/repos/square/metrics/issues/124"},"comments":{"href":"https://api.github.com/repos/square/metrics/issues/124/comments"},"review_comments":{"href":"https://api.github.com/repos/square/metrics/pulls/124/comments"},"review_comment":{"href":"https://api.github.com/repos/square/metrics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/metrics/pulls/124/commits"},"statuses":{"href":"https://api.github.com/repos/square/metrics/statuses/bf35304faeb76a20f33d89324d474d45ff42c446"}}}}