{"action":"created","comment":{"url":"https://api.github.com/repos/18F/college-choice/pulls/comments/38491408","id":38491408,"diff_hunk":"@@ -0,0 +1,161 @@\n+var ELEMENT_NAME = 'picc-range';\n+var CLASS_PREFIX = ELEMENT_NAME + '-';\n+\n+var LABEL_TYPES = ['min', 'max', 'lower', 'middle', 'upper'];\n+\n+window.PICCRange = document.registerElement(ELEMENT_NAME, {\n+  prototype: Object.create(\n+    HTMLElement.prototype,\n+    {\n+\n+      attachedCallback: {value: function() {\n+        var bar = this.appendChild(document.createElement('div'));\n+        bar.className = CLASS_PREFIX + 'bar';\n+\n+        LABEL_TYPES.forEach(function(type) {\n+          var label = this.appendChild(document.createElement('span'));\n+          label.className = [\n+            CLASS_PREFIX + 'label',\n+            [CLASS_PREFIX, 'label-', type].join('')\n+          ].join(' ');\n+          label.appendChild(document.createElement('span'));\n+        }, this);\n+\n+        this.min = getAttr(this, 'min', 0);\n+        this.max = getAttr(this, 'max', 1);\n+        this.lower = getAttr(this, 'lower');\n+        this.middle = getAttr(this, 'middle');\n+        this.upper = getAttr(this, 'upper');\n+\n+        this.update();\n+      }},\n+\n+      attributeChangedCallback: {value: function(attr, prev, value) {\n+        // pass through attribute settings to properties for min,\n+        // max, lower and upper values\n+        switch (attr) {\n+          case 'min':\n+          case 'max':\n+          case 'lower':\n+          case 'middle':\n+          case 'upper':\n+            this[attr] = value;\n+            return;\n+        }\n+      }},\n+\n+      update: {value: function() {\n+        var min = this.min;\n+        var max = this.max;\n+\n+        var scale = function(v) {\n+          return (v - min) / (max - min);\n+        };\n+\n+        var percent = function(v) {\n+          return (scale(v) * 100).toFixed(1) + '%';\n+        };\n+\n+        var bar = this.querySelector('.' + CLASS_PREFIX + 'bar');\n+        bar.style.setProperty('left', percent(this.lower));\n+        bar.style.setProperty('right', percent(this.min + this.max - this.upper));\n+\n+        LABEL_TYPES.forEach(function(type) {\n+          var label = this.querySelector('.' + CLASS_PREFIX + 'label-' + type);\n+          if (!label) return;\n+\n+          var value = this[type];\n+          if (typeof value !== 'number' || isNaN(value)) {\n+            label.style.setProperty('display', 'none');\n+          } else {\n+            label.style.removeProperty('display');\n+            label.style.setProperty('left', percent(value));\n+            var span = label.querySelector('span');\n+            if (span) {\n+              span.textContent = String(Math.round(value));\n+            }\n+          }\n+        }, this);\n+\n+        delete this.__timeout;\n+      }},\n+\n+      min: {","path":"js/src/components/picc-range.js","position":83,"original_position":83,"commit_id":"d8e36923ddf2ebce7d1ccbc768f46a1d4442ec25","original_commit_id":"d8e36923ddf2ebce7d1ccbc768f46a1d4442ec25","user":{"login":"jmcarp","id":1633460,"avatar_url":"https://avatars.githubusercontent.com/u/1633460?v=3","gravatar_id":"","url":"https://api.github.com/users/jmcarp","html_url":"https://github.com/jmcarp","followers_url":"https://api.github.com/users/jmcarp/followers","following_url":"https://api.github.com/users/jmcarp/following{/other_user}","gists_url":"https://api.github.com/users/jmcarp/gists{/gist_id}","starred_url":"https://api.github.com/users/jmcarp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmcarp/subscriptions","organizations_url":"https://api.github.com/users/jmcarp/orgs","repos_url":"https://api.github.com/users/jmcarp/repos","events_url":"https://api.github.com/users/jmcarp/events{/privacy}","received_events_url":"https://api.github.com/users/jmcarp/received_events","type":"User","site_admin":false},"body":"Oh, I see you already have this. Can it be used here?","created_at":"2015-09-02T01:21:18Z","updated_at":"2015-09-02T01:21:18Z","html_url":"https://github.com/18F/college-choice/pull/969#discussion_r38491408","pull_request_url":"https://api.github.com/repos/18F/college-choice/pulls/969","_links":{"self":{"href":"https://api.github.com/repos/18F/college-choice/pulls/comments/38491408"},"html":{"href":"https://github.com/18F/college-choice/pull/969#discussion_r38491408"},"pull_request":{"href":"https://api.github.com/repos/18F/college-choice/pulls/969"}}},"pull_request":{"url":"https://api.github.com/repos/18F/college-choice/pulls/969","id":43928437,"html_url":"https://github.com/18F/college-choice/pull/969","diff_url":"https://github.com/18F/college-choice/pull/969.diff","patch_url":"https://github.com/18F/college-choice/pull/969.patch","issue_url":"https://api.github.com/repos/18F/college-choice/issues/969","number":969,"state":"closed","locked":false,"title":"Optimize JS","user":{"login":"shawnbot","id":113896,"avatar_url":"https://avatars.githubusercontent.com/u/113896?v=3","gravatar_id":"","url":"https://api.github.com/users/shawnbot","html_url":"https://github.com/shawnbot","followers_url":"https://api.github.com/users/shawnbot/followers","following_url":"https://api.github.com/users/shawnbot/following{/other_user}","gists_url":"https://api.github.com/users/shawnbot/gists{/gist_id}","starred_url":"https://api.github.com/users/shawnbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shawnbot/subscriptions","organizations_url":"https://api.github.com/users/shawnbot/orgs","repos_url":"https://api.github.com/users/shawnbot/repos","events_url":"https://api.github.com/users/shawnbot/events{/privacy}","received_events_url":"https://api.github.com/users/shawnbot/received_events","type":"User","site_admin":false},"body":"This PR introduces a fundamental restructuring of the JavaScript:\r\n\r\n1. All of the source files now reside in `js/src`. These files are *not* excluded in the Jekyll config because they're needed for debugging (see below).\r\n1. We're using [browserify] to create an omnibus build of everything the site needs, across pages, *except* Leaflet (which is big, only used on the school page, and has an external CSS dependency).\r\n1. The build is minified with [UglifyJS][UglifyJS] (via [minifyify]), which makes the JS *really tiny*... and basically illegible. **BUT!** with the magic of [source maps], we can still [debug](https://developer.chrome.com/devtools/docs/javascript-debugging) the JavaScript as though it were running in the original files.\r\n\r\nWith this restructuring, all of the site's functionality (except Leaflet, as noted above) is loaded up front in a single, slim (~250K as of this writing) file. Most of that isn't used on the home page, but loading it there means that it'll be available in the browser cache immediately when the user searches. (:candy: I've also added a `?v{{ site.version }}` suffix to the main script's `src`, so that if we later set `site.version` in the Jekyll config we'll get a rudimentary form of cache busting for free.)\r\n\r\nThis restructuring introduces some commands that you need to run to update the JS as you're working on the source files (in `js/src`):\r\n\r\n##### Build\r\n```\r\nnpm run build\r\n```\r\nRuns a one-off build of `js/picc.js` and its source map, `js/picc.js.map`.\r\n\r\n##### Watch\r\n```\r\nnpm run watch\r\n```\r\nRuns a watch process that rebuilds `js/picc.js` (and its source map) whenever the file changes. Changes to any required file trigger a rebuild, and files are cached so the builds are relatively quick.\r\n\r\n[browserify]: http://browserify.org/\r\n[UglifyJS]: https://github.com/mishoo/UglifyJS2\r\n[minifyify]: https://www.npmjs.com/package/minifyify\r\n[source maps]: http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/","created_at":"2015-09-01T21:22:58Z","updated_at":"2015-09-02T01:21:18Z","closed_at":"2015-09-02T01:07:36Z","merged_at":"2015-09-02T01:07:36Z","merge_commit_sha":"805380594528f19775f9b164743383099951eac2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/18F/college-choice/pulls/969/commits","review_comments_url":"https://api.github.com/repos/18F/college-choice/pulls/969/comments","review_comment_url":"https://api.github.com/repos/18F/college-choice/pulls/comments{/number}","comments_url":"https://api.github.com/repos/18F/college-choice/issues/969/comments","statuses_url":"https://api.github.com/repos/18F/college-choice/statuses/d8e36923ddf2ebce7d1ccbc768f46a1d4442ec25","head":{"label":"18F:optimize-js","ref":"optimize-js","sha":"d8e36923ddf2ebce7d1ccbc768f46a1d4442ec25","user":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"repo":{"id":37279656,"name":"college-choice","full_name":"18F/college-choice","owner":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/18F/college-choice","description":"Project Inform College Choice","fork":false,"url":"https://api.github.com/repos/18F/college-choice","forks_url":"https://api.github.com/repos/18F/college-choice/forks","keys_url":"https://api.github.com/repos/18F/college-choice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/18F/college-choice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/18F/college-choice/teams","hooks_url":"https://api.github.com/repos/18F/college-choice/hooks","issue_events_url":"https://api.github.com/repos/18F/college-choice/issues/events{/number}","events_url":"https://api.github.com/repos/18F/college-choice/events","assignees_url":"https://api.github.com/repos/18F/college-choice/assignees{/user}","branches_url":"https://api.github.com/repos/18F/college-choice/branches{/branch}","tags_url":"https://api.github.com/repos/18F/college-choice/tags","blobs_url":"https://api.github.com/repos/18F/college-choice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/18F/college-choice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/18F/college-choice/git/refs{/sha}","trees_url":"https://api.github.com/repos/18F/college-choice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/18F/college-choice/statuses/{sha}","languages_url":"https://api.github.com/repos/18F/college-choice/languages","stargazers_url":"https://api.github.com/repos/18F/college-choice/stargazers","contributors_url":"https://api.github.com/repos/18F/college-choice/contributors","subscribers_url":"https://api.github.com/repos/18F/college-choice/subscribers","subscription_url":"https://api.github.com/repos/18F/college-choice/subscription","commits_url":"https://api.github.com/repos/18F/college-choice/commits{/sha}","git_commits_url":"https://api.github.com/repos/18F/college-choice/git/commits{/sha}","comments_url":"https://api.github.com/repos/18F/college-choice/comments{/number}","issue_comment_url":"https://api.github.com/repos/18F/college-choice/issues/comments{/number}","contents_url":"https://api.github.com/repos/18F/college-choice/contents/{+path}","compare_url":"https://api.github.com/repos/18F/college-choice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/18F/college-choice/merges","archive_url":"https://api.github.com/repos/18F/college-choice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/18F/college-choice/downloads","issues_url":"https://api.github.com/repos/18F/college-choice/issues{/number}","pulls_url":"https://api.github.com/repos/18F/college-choice/pulls{/number}","milestones_url":"https://api.github.com/repos/18F/college-choice/milestones{/number}","notifications_url":"https://api.github.com/repos/18F/college-choice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/18F/college-choice/labels{/name}","releases_url":"https://api.github.com/repos/18F/college-choice/releases{/id}","created_at":"2015-06-11T18:48:24Z","updated_at":"2015-08-24T01:40:24Z","pushed_at":"2015-09-02T01:16:02Z","git_url":"git://github.com/18F/college-choice.git","ssh_url":"git@github.com:18F/college-choice.git","clone_url":"https://github.com/18F/college-choice.git","svn_url":"https://github.com/18F/college-choice","homepage":"","size":14894,"stargazers_count":3,"watchers_count":3,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":357,"forks":7,"open_issues":357,"watchers":3,"default_branch":"dev"}},"base":{"label":"18F:dev","ref":"dev","sha":"891c32463ce8a77175a565f5c7be410cca6a1f7d","user":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"repo":{"id":37279656,"name":"college-choice","full_name":"18F/college-choice","owner":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/18F/college-choice","description":"Project Inform College Choice","fork":false,"url":"https://api.github.com/repos/18F/college-choice","forks_url":"https://api.github.com/repos/18F/college-choice/forks","keys_url":"https://api.github.com/repos/18F/college-choice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/18F/college-choice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/18F/college-choice/teams","hooks_url":"https://api.github.com/repos/18F/college-choice/hooks","issue_events_url":"https://api.github.com/repos/18F/college-choice/issues/events{/number}","events_url":"https://api.github.com/repos/18F/college-choice/events","assignees_url":"https://api.github.com/repos/18F/college-choice/assignees{/user}","branches_url":"https://api.github.com/repos/18F/college-choice/branches{/branch}","tags_url":"https://api.github.com/repos/18F/college-choice/tags","blobs_url":"https://api.github.com/repos/18F/college-choice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/18F/college-choice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/18F/college-choice/git/refs{/sha}","trees_url":"https://api.github.com/repos/18F/college-choice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/18F/college-choice/statuses/{sha}","languages_url":"https://api.github.com/repos/18F/college-choice/languages","stargazers_url":"https://api.github.com/repos/18F/college-choice/stargazers","contributors_url":"https://api.github.com/repos/18F/college-choice/contributors","subscribers_url":"https://api.github.com/repos/18F/college-choice/subscribers","subscription_url":"https://api.github.com/repos/18F/college-choice/subscription","commits_url":"https://api.github.com/repos/18F/college-choice/commits{/sha}","git_commits_url":"https://api.github.com/repos/18F/college-choice/git/commits{/sha}","comments_url":"https://api.github.com/repos/18F/college-choice/comments{/number}","issue_comment_url":"https://api.github.com/repos/18F/college-choice/issues/comments{/number}","contents_url":"https://api.github.com/repos/18F/college-choice/contents/{+path}","compare_url":"https://api.github.com/repos/18F/college-choice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/18F/college-choice/merges","archive_url":"https://api.github.com/repos/18F/college-choice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/18F/college-choice/downloads","issues_url":"https://api.github.com/repos/18F/college-choice/issues{/number}","pulls_url":"https://api.github.com/repos/18F/college-choice/pulls{/number}","milestones_url":"https://api.github.com/repos/18F/college-choice/milestones{/number}","notifications_url":"https://api.github.com/repos/18F/college-choice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/18F/college-choice/labels{/name}","releases_url":"https://api.github.com/repos/18F/college-choice/releases{/id}","created_at":"2015-06-11T18:48:24Z","updated_at":"2015-08-24T01:40:24Z","pushed_at":"2015-09-02T01:16:02Z","git_url":"git://github.com/18F/college-choice.git","ssh_url":"git@github.com:18F/college-choice.git","clone_url":"https://github.com/18F/college-choice.git","svn_url":"https://github.com/18F/college-choice","homepage":"","size":14894,"stargazers_count":3,"watchers_count":3,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":357,"forks":7,"open_issues":357,"watchers":3,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/18F/college-choice/pulls/969"},"html":{"href":"https://github.com/18F/college-choice/pull/969"},"issue":{"href":"https://api.github.com/repos/18F/college-choice/issues/969"},"comments":{"href":"https://api.github.com/repos/18F/college-choice/issues/969/comments"},"review_comments":{"href":"https://api.github.com/repos/18F/college-choice/pulls/969/comments"},"review_comment":{"href":"https://api.github.com/repos/18F/college-choice/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/18F/college-choice/pulls/969/commits"},"statuses":{"href":"https://api.github.com/repos/18F/college-choice/statuses/d8e36923ddf2ebce7d1ccbc768f46a1d4442ec25"}}}}