{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/browser.html/pulls/comments/26095181","id":26095181,"diff_hunk":"@@ -0,0 +1,109 @@\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+define((require, exports, module) => {\n+\n+  'use strict';\n+\n+  const {DOM} = require('react')\n+  const {fromJS} = require('immutable');\n+  const Component = require('omniscient');\n+  const {navigateTo, hideTabStrip} = require('./actions');\n+\n+  const Awesomebar = Component('Awesomebar', ({\n+    tabStripCursor, isTabStripVisible, suggestionsCursor, inputCursor, webViewerCursor, theme}) => {\n+\n+    if (!isTabStripVisible) {\n+      return null;\n+    }\n+\n+    const go = href => {\n+      navigateTo({inputCursor, webViewerCursor}, href, true);\n+      hideTabStrip(tabStripCursor);\n+    }\n+\n+    let suggestions = [];\n+    ['search', 'history'].forEach(type =>\n+      suggestions = [...suggestions, ...suggestionsCursor\n+                        .get(type)\n+                        .toArray()\n+                        .map((entry, index) => DOM.p({\n+                          className: `suggestion ${type}`,\n+                          key: type + index,\n+                          onClick: e => go(entry.get('href'))\n+                        }, entry.get('text')))])\n+\n+    return DOM.div({\n+      className: 'suggestionscontainer',\n+      key: 'suggestionscontainer',\n+      style: {\n+        backgroundColor: theme.tabstrip.backgroundColor,\n+        color: theme.titleText.color\n+      }\n+    }, [\n+      DOM.div({\n+        className: 'suggestions',\n+        key: 'suggestions'\n+      }, suggestions)\n+    ])\n+  });\n+\n+\n+  const MAX_RESULTS = 3;\n+  let xhrSearch;\n+  let xhrHistory;\n+\n+  const ComputeSuggestions = (textInput, suggestionsCursor) => {\n+\n+    if (xhrSearch) xhrSearch.abort();\n+    if (xhrHistory) xhrHistory.abort();\n+\n+    textInput = textInput.trim();\n+\n+    if (!textInput) {\n+      suggestionsCursor.set('search', fromJS([]));\n+      suggestionsCursor.set('history', fromJS([]));\n+      return;\n+    }\n+\n+    xhrSearch = new XMLHttpRequest({mozSystem: true});\n+    xhrSearch.open('GET', `https://ac.duckduckgo.com/ac/?q=${textInput}&type=list`, true);\n+    xhrSearch.send();\n+    xhrSearch.onload = () => {\n+      try {\n+        const json = JSON.parse(xhrSearch.response);","path":"src/browser/awesomebar.js","position":75,"original_position":75,"commit_id":"cc76a3edd1579039d3aef561aacdcd8268f5e764","original_commit_id":"cc76a3edd1579039d3aef561aacdcd8268f5e764","user":{"login":"fabricedesre","id":984767,"avatar_url":"https://avatars.githubusercontent.com/u/984767?v=3","gravatar_id":"","url":"https://api.github.com/users/fabricedesre","html_url":"https://github.com/fabricedesre","followers_url":"https://api.github.com/users/fabricedesre/followers","following_url":"https://api.github.com/users/fabricedesre/following{/other_user}","gists_url":"https://api.github.com/users/fabricedesre/gists{/gist_id}","starred_url":"https://api.github.com/users/fabricedesre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabricedesre/subscriptions","organizations_url":"https://api.github.com/users/fabricedesre/orgs","repos_url":"https://api.github.com/users/fabricedesre/repos","events_url":"https://api.github.com/users/fabricedesre/events{/privacy}","received_events_url":"https://api.github.com/users/fabricedesre/received_events","type":"User","site_admin":false},"body":"set xhr.responseType = 'json' to save you this parsing.","created_at":"2015-03-10T02:32:53Z","updated_at":"2015-03-10T02:32:53Z","html_url":"https://github.com/mozilla/browser.html/pull/207#discussion_r26095181","pull_request_url":"https://api.github.com/repos/mozilla/browser.html/pulls/207","_links":{"self":{"href":"https://api.github.com/repos/mozilla/browser.html/pulls/comments/26095181"},"html":{"href":"https://github.com/mozilla/browser.html/pull/207#discussion_r26095181"},"pull_request":{"href":"https://api.github.com/repos/mozilla/browser.html/pulls/207"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/browser.html/pulls/207","id":30817091,"html_url":"https://github.com/mozilla/browser.html/pull/207","diff_url":"https://github.com/mozilla/browser.html/pull/207.diff","patch_url":"https://github.com/mozilla/browser.html/pull/207.patch","issue_url":"https://api.github.com/repos/mozilla/browser.html/issues/207","number":207,"state":"open","locked":false,"title":"basic awesomebar","user":{"login":"paulrouget","id":373579,"avatar_url":"https://avatars.githubusercontent.com/u/373579?v=3","gravatar_id":"","url":"https://api.github.com/users/paulrouget","html_url":"https://github.com/paulrouget","followers_url":"https://api.github.com/users/paulrouget/followers","following_url":"https://api.github.com/users/paulrouget/following{/other_user}","gists_url":"https://api.github.com/users/paulrouget/gists{/gist_id}","starred_url":"https://api.github.com/users/paulrouget/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulrouget/subscriptions","organizations_url":"https://api.github.com/users/paulrouget/orgs","repos_url":"https://api.github.com/users/paulrouget/repos","events_url":"https://api.github.com/users/paulrouget/events{/privacy}","received_events_url":"https://api.github.com/users/paulrouget/received_events","type":"User","site_admin":false},"body":"This basic awesomebar implements Gordon's design. To feed the awesomebar, I use duckduckgo search completion and alexa top 500 list. This is a temporary solution, but it's good enough. There are some bugs related to input component and the tabstrip that we will fix later.","created_at":"2015-03-10T02:03:48Z","updated_at":"2015-03-10T02:32:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3f89eeaa549e98441600ff9c5f3d55c08d713943","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/browser.html/pulls/207/commits","review_comments_url":"https://api.github.com/repos/mozilla/browser.html/pulls/207/comments","review_comment_url":"https://api.github.com/repos/mozilla/browser.html/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/browser.html/issues/207/comments","statuses_url":"https://api.github.com/repos/mozilla/browser.html/statuses/cc76a3edd1579039d3aef561aacdcd8268f5e764","head":{"label":"paulrouget:basicAwesomebar","ref":"basicAwesomebar","sha":"cc76a3edd1579039d3aef561aacdcd8268f5e764","user":{"login":"paulrouget","id":373579,"avatar_url":"https://avatars.githubusercontent.com/u/373579?v=3","gravatar_id":"","url":"https://api.github.com/users/paulrouget","html_url":"https://github.com/paulrouget","followers_url":"https://api.github.com/users/paulrouget/followers","following_url":"https://api.github.com/users/paulrouget/following{/other_user}","gists_url":"https://api.github.com/users/paulrouget/gists{/gist_id}","starred_url":"https://api.github.com/users/paulrouget/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulrouget/subscriptions","organizations_url":"https://api.github.com/users/paulrouget/orgs","repos_url":"https://api.github.com/users/paulrouget/repos","events_url":"https://api.github.com/users/paulrouget/events{/privacy}","received_events_url":"https://api.github.com/users/paulrouget/received_events","type":"User","site_admin":false},"repo":{"id":30219371,"name":"browser.html","full_name":"paulrouget/browser.html","owner":{"login":"paulrouget","id":373579,"avatar_url":"https://avatars.githubusercontent.com/u/373579?v=3","gravatar_id":"","url":"https://api.github.com/users/paulrouget","html_url":"https://github.com/paulrouget","followers_url":"https://api.github.com/users/paulrouget/followers","following_url":"https://api.github.com/users/paulrouget/following{/other_user}","gists_url":"https://api.github.com/users/paulrouget/gists{/gist_id}","starred_url":"https://api.github.com/users/paulrouget/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulrouget/subscriptions","organizations_url":"https://api.github.com/users/paulrouget/orgs","repos_url":"https://api.github.com/users/paulrouget/repos","events_url":"https://api.github.com/users/paulrouget/events{/privacy}","received_events_url":"https://api.github.com/users/paulrouget/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/paulrouget/browser.html","description":"Experimental browser built in HTML","fork":true,"url":"https://api.github.com/repos/paulrouget/browser.html","forks_url":"https://api.github.com/repos/paulrouget/browser.html/forks","keys_url":"https://api.github.com/repos/paulrouget/browser.html/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paulrouget/browser.html/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paulrouget/browser.html/teams","hooks_url":"https://api.github.com/repos/paulrouget/browser.html/hooks","issue_events_url":"https://api.github.com/repos/paulrouget/browser.html/issues/events{/number}","events_url":"https://api.github.com/repos/paulrouget/browser.html/events","assignees_url":"https://api.github.com/repos/paulrouget/browser.html/assignees{/user}","branches_url":"https://api.github.com/repos/paulrouget/browser.html/branches{/branch}","tags_url":"https://api.github.com/repos/paulrouget/browser.html/tags","blobs_url":"https://api.github.com/repos/paulrouget/browser.html/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paulrouget/browser.html/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paulrouget/browser.html/git/refs{/sha}","trees_url":"https://api.github.com/repos/paulrouget/browser.html/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paulrouget/browser.html/statuses/{sha}","languages_url":"https://api.github.com/repos/paulrouget/browser.html/languages","stargazers_url":"https://api.github.com/repos/paulrouget/browser.html/stargazers","contributors_url":"https://api.github.com/repos/paulrouget/browser.html/contributors","subscribers_url":"https://api.github.com/repos/paulrouget/browser.html/subscribers","subscription_url":"https://api.github.com/repos/paulrouget/browser.html/subscription","commits_url":"https://api.github.com/repos/paulrouget/browser.html/commits{/sha}","git_commits_url":"https://api.github.com/repos/paulrouget/browser.html/git/commits{/sha}","comments_url":"https://api.github.com/repos/paulrouget/browser.html/comments{/number}","issue_comment_url":"https://api.github.com/repos/paulrouget/browser.html/issues/comments{/number}","contents_url":"https://api.github.com/repos/paulrouget/browser.html/contents/{+path}","compare_url":"https://api.github.com/repos/paulrouget/browser.html/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paulrouget/browser.html/merges","archive_url":"https://api.github.com/repos/paulrouget/browser.html/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paulrouget/browser.html/downloads","issues_url":"https://api.github.com/repos/paulrouget/browser.html/issues{/number}","pulls_url":"https://api.github.com/repos/paulrouget/browser.html/pulls{/number}","milestones_url":"https://api.github.com/repos/paulrouget/browser.html/milestones{/number}","notifications_url":"https://api.github.com/repos/paulrouget/browser.html/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paulrouget/browser.html/labels{/name}","releases_url":"https://api.github.com/repos/paulrouget/browser.html/releases{/id}","created_at":"2015-02-03T01:55:27Z","updated_at":"2015-02-03T01:55:27Z","pushed_at":"2015-03-10T02:10:44Z","git_url":"git://github.com/paulrouget/browser.html.git","ssh_url":"git@github.com:paulrouget/browser.html.git","clone_url":"https://github.com/paulrouget/browser.html.git","svn_url":"https://github.com/paulrouget/browser.html","homepage":null,"size":7108,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"551ce5b5548f2a13270e5f67a77ee51e389c8701","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":28800891,"name":"browser.html","full_name":"mozilla/browser.html","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/browser.html","description":"Experimental browser built in HTML","fork":false,"url":"https://api.github.com/repos/mozilla/browser.html","forks_url":"https://api.github.com/repos/mozilla/browser.html/forks","keys_url":"https://api.github.com/repos/mozilla/browser.html/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/browser.html/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/browser.html/teams","hooks_url":"https://api.github.com/repos/mozilla/browser.html/hooks","issue_events_url":"https://api.github.com/repos/mozilla/browser.html/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/browser.html/events","assignees_url":"https://api.github.com/repos/mozilla/browser.html/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/browser.html/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/browser.html/tags","blobs_url":"https://api.github.com/repos/mozilla/browser.html/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/browser.html/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/browser.html/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/browser.html/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/browser.html/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/browser.html/languages","stargazers_url":"https://api.github.com/repos/mozilla/browser.html/stargazers","contributors_url":"https://api.github.com/repos/mozilla/browser.html/contributors","subscribers_url":"https://api.github.com/repos/mozilla/browser.html/subscribers","subscription_url":"https://api.github.com/repos/mozilla/browser.html/subscription","commits_url":"https://api.github.com/repos/mozilla/browser.html/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/browser.html/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/browser.html/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/browser.html/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/browser.html/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/browser.html/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/browser.html/merges","archive_url":"https://api.github.com/repos/mozilla/browser.html/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/browser.html/downloads","issues_url":"https://api.github.com/repos/mozilla/browser.html/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/browser.html/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/browser.html/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/browser.html/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/browser.html/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/browser.html/releases{/id}","created_at":"2015-01-05T06:39:24Z","updated_at":"2015-03-09T19:49:07Z","pushed_at":"2015-03-09T19:49:07Z","git_url":"git://github.com/mozilla/browser.html.git","ssh_url":"git@github.com:mozilla/browser.html.git","clone_url":"https://github.com/mozilla/browser.html.git","svn_url":"https://github.com/mozilla/browser.html","homepage":null,"size":10296,"stargazers_count":192,"watchers_count":192,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":26,"mirror_url":null,"open_issues_count":70,"forks":26,"open_issues":70,"watchers":192,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/browser.html/pulls/207"},"html":{"href":"https://github.com/mozilla/browser.html/pull/207"},"issue":{"href":"https://api.github.com/repos/mozilla/browser.html/issues/207"},"comments":{"href":"https://api.github.com/repos/mozilla/browser.html/issues/207/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/browser.html/pulls/207/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/browser.html/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/browser.html/pulls/207/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/browser.html/statuses/cc76a3edd1579039d3aef561aacdcd8268f5e764"}}}}