{"action":"created","comment":{"url":"https://api.github.com/repos/quran/quran.com-frontend/pulls/comments/57782655","id":57782655,"diff_hunk":"@@ -0,0 +1,97 @@\n+import React, { Component, PropTypes } from 'react';\n+import { connect } from 'react-redux';\n+import ApiClient from '../../../helpers/ApiClient';\n+\n+@connect(\n+  state => ({surahs: state.surahs.entities})\n+)\n+\n+export default class SearchAutocomplete extends Component {\n+  constructor(props, context) {\n+    super(props, context);\n+    this.state = { ayat: [], surahs: [] };\n+    this.cached = {};\n+  };\n+\n+  componentWillReceiveProps(nextProps) {\n+    this.suggest(nextProps.value);\n+  };\n+\n+  suggest(value) {\n+    if (value.length >= 2) {\n+      this.handleSurahSuggestions(value);\n+    } else if (this.state.surahs.length > 0) this.setState({ surahs: [] });\n+\n+    if (value.length >= 3) {\n+      this.handleAyahSuggestions(value);\n+    } else if (this.state.ayat.length > 0) this.setState({ ayat: [] });\n+  };\n+\n+  handleSurahSuggestions(value) {\n+    var escaped = value.replace(/[-\\\\^$*+?.()|[\\]{}]/g, \"\\\\$&\");\n+    var matches = [];\n+    for (var surah_id in this.props.surahs) {\n+      var surah = this.props.surahs[surah_id];","path":"src/scripts/components/header/SearchAutocomplete.js","position":34,"original_position":34,"commit_id":"a5c4f700be00c0988007b241f3b433efaefec3a9","original_commit_id":"a5c4f700be00c0988007b241f3b433efaefec3a9","user":{"login":"mmahalwy","id":3749095,"avatar_url":"https://avatars.githubusercontent.com/u/3749095?v=3","gravatar_id":"","url":"https://api.github.com/users/mmahalwy","html_url":"https://github.com/mmahalwy","followers_url":"https://api.github.com/users/mmahalwy/followers","following_url":"https://api.github.com/users/mmahalwy/following{/other_user}","gists_url":"https://api.github.com/users/mmahalwy/gists{/gist_id}","starred_url":"https://api.github.com/users/mmahalwy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmahalwy/subscriptions","organizations_url":"https://api.github.com/users/mmahalwy/orgs","repos_url":"https://api.github.com/users/mmahalwy/repos","events_url":"https://api.github.com/users/mmahalwy/events{/privacy}","received_events_url":"https://api.github.com/users/mmahalwy/received_events","type":"User","site_admin":false},"body":"const","created_at":"2016-03-29T19:12:33Z","updated_at":"2016-03-29T19:12:33Z","html_url":"https://github.com/quran/quran.com-frontend/pull/231#discussion_r57782655","pull_request_url":"https://api.github.com/repos/quran/quran.com-frontend/pulls/231","_links":{"self":{"href":"https://api.github.com/repos/quran/quran.com-frontend/pulls/comments/57782655"},"html":{"href":"https://github.com/quran/quran.com-frontend/pull/231#discussion_r57782655"},"pull_request":{"href":"https://api.github.com/repos/quran/quran.com-frontend/pulls/231"}}},"pull_request":{"url":"https://api.github.com/repos/quran/quran.com-frontend/pulls/231","id":64484390,"html_url":"https://github.com/quran/quran.com-frontend/pull/231","diff_url":"https://github.com/quran/quran.com-frontend/pull/231.diff","patch_url":"https://github.com/quran/quran.com-frontend/pull/231.patch","issue_url":"https://api.github.com/repos/quran/quran.com-frontend/issues/231","number":231,"state":"open","locked":false,"title":"quran/quran.com-frontend#224 - adds search autocomplete to the new re…","user":{"login":"sharabash","id":21639,"avatar_url":"https://avatars.githubusercontent.com/u/21639?v=3","gravatar_id":"","url":"https://api.github.com/users/sharabash","html_url":"https://github.com/sharabash","followers_url":"https://api.github.com/users/sharabash/followers","following_url":"https://api.github.com/users/sharabash/following{/other_user}","gists_url":"https://api.github.com/users/sharabash/gists{/gist_id}","starred_url":"https://api.github.com/users/sharabash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharabash/subscriptions","organizations_url":"https://api.github.com/users/sharabash/orgs","repos_url":"https://api.github.com/users/sharabash/repos","events_url":"https://api.github.com/users/sharabash/events{/privacy}","received_events_url":"https://api.github.com/users/sharabash/received_events","type":"User","site_admin":false},"body":"…dux code; surah matching is not working because i dont know how to get the surahs object anymore; i cant refactor request out because i dont know how to use api client.\r\n\r\n@mmahalwy","created_at":"2016-03-29T15:28:32Z","updated_at":"2016-03-29T19:12:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"535be0c861acab53da38c8d032910843546d1092","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/quran/quran.com-frontend/pulls/231/commits","review_comments_url":"https://api.github.com/repos/quran/quran.com-frontend/pulls/231/comments","review_comment_url":"https://api.github.com/repos/quran/quran.com-frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/quran/quran.com-frontend/issues/231/comments","statuses_url":"https://api.github.com/repos/quran/quran.com-frontend/statuses/a5c4f700be00c0988007b241f3b433efaefec3a9","head":{"label":"sharabash:search-as-you-type-2","ref":"search-as-you-type-2","sha":"a5c4f700be00c0988007b241f3b433efaefec3a9","user":{"login":"sharabash","id":21639,"avatar_url":"https://avatars.githubusercontent.com/u/21639?v=3","gravatar_id":"","url":"https://api.github.com/users/sharabash","html_url":"https://github.com/sharabash","followers_url":"https://api.github.com/users/sharabash/followers","following_url":"https://api.github.com/users/sharabash/following{/other_user}","gists_url":"https://api.github.com/users/sharabash/gists{/gist_id}","starred_url":"https://api.github.com/users/sharabash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharabash/subscriptions","organizations_url":"https://api.github.com/users/sharabash/orgs","repos_url":"https://api.github.com/users/sharabash/repos","events_url":"https://api.github.com/users/sharabash/events{/privacy}","received_events_url":"https://api.github.com/users/sharabash/received_events","type":"User","site_admin":false},"repo":{"id":54313074,"name":"quran.com-frontend","full_name":"sharabash/quran.com-frontend","owner":{"login":"sharabash","id":21639,"avatar_url":"https://avatars.githubusercontent.com/u/21639?v=3","gravatar_id":"","url":"https://api.github.com/users/sharabash","html_url":"https://github.com/sharabash","followers_url":"https://api.github.com/users/sharabash/followers","following_url":"https://api.github.com/users/sharabash/following{/other_user}","gists_url":"https://api.github.com/users/sharabash/gists{/gist_id}","starred_url":"https://api.github.com/users/sharabash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharabash/subscriptions","organizations_url":"https://api.github.com/users/sharabash/orgs","repos_url":"https://api.github.com/users/sharabash/repos","events_url":"https://api.github.com/users/sharabash/events{/privacy}","received_events_url":"https://api.github.com/users/sharabash/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sharabash/quran.com-frontend","description":"I am sorry... @mmahalwy isn't fun anymore...","fork":true,"url":"https://api.github.com/repos/sharabash/quran.com-frontend","forks_url":"https://api.github.com/repos/sharabash/quran.com-frontend/forks","keys_url":"https://api.github.com/repos/sharabash/quran.com-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sharabash/quran.com-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sharabash/quran.com-frontend/teams","hooks_url":"https://api.github.com/repos/sharabash/quran.com-frontend/hooks","issue_events_url":"https://api.github.com/repos/sharabash/quran.com-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/sharabash/quran.com-frontend/events","assignees_url":"https://api.github.com/repos/sharabash/quran.com-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/sharabash/quran.com-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/sharabash/quran.com-frontend/tags","blobs_url":"https://api.github.com/repos/sharabash/quran.com-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sharabash/quran.com-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sharabash/quran.com-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/sharabash/quran.com-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sharabash/quran.com-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/sharabash/quran.com-frontend/languages","stargazers_url":"https://api.github.com/repos/sharabash/quran.com-frontend/stargazers","contributors_url":"https://api.github.com/repos/sharabash/quran.com-frontend/contributors","subscribers_url":"https://api.github.com/repos/sharabash/quran.com-frontend/subscribers","subscription_url":"https://api.github.com/repos/sharabash/quran.com-frontend/subscription","commits_url":"https://api.github.com/repos/sharabash/quran.com-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/sharabash/quran.com-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/sharabash/quran.com-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/sharabash/quran.com-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/sharabash/quran.com-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/sharabash/quran.com-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sharabash/quran.com-frontend/merges","archive_url":"https://api.github.com/repos/sharabash/quran.com-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sharabash/quran.com-frontend/downloads","issues_url":"https://api.github.com/repos/sharabash/quran.com-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/sharabash/quran.com-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/sharabash/quran.com-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/sharabash/quran.com-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sharabash/quran.com-frontend/labels{/name}","releases_url":"https://api.github.com/repos/sharabash/quran.com-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/sharabash/quran.com-frontend/deployments","created_at":"2016-03-20T11:03:46Z","updated_at":"2016-03-20T11:03:48Z","pushed_at":"2016-03-29T19:11:00Z","git_url":"git://github.com/sharabash/quran.com-frontend.git","ssh_url":"git@github.com:sharabash/quran.com-frontend.git","clone_url":"https://github.com/sharabash/quran.com-frontend.git","svn_url":"https://github.com/sharabash/quran.com-frontend","homepage":"https://quran.com","size":266142,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"quran:master","ref":"master","sha":"7c10463c5b66da8439d050360a848aa8894b12e9","user":{"login":"quran","id":21640,"avatar_url":"https://avatars.githubusercontent.com/u/21640?v=3","gravatar_id":"","url":"https://api.github.com/users/quran","html_url":"https://github.com/quran","followers_url":"https://api.github.com/users/quran/followers","following_url":"https://api.github.com/users/quran/following{/other_user}","gists_url":"https://api.github.com/users/quran/gists{/gist_id}","starred_url":"https://api.github.com/users/quran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quran/subscriptions","organizations_url":"https://api.github.com/users/quran/orgs","repos_url":"https://api.github.com/users/quran/repos","events_url":"https://api.github.com/users/quran/events{/privacy}","received_events_url":"https://api.github.com/users/quran/received_events","type":"Organization","site_admin":false},"repo":{"id":31837006,"name":"quran.com-frontend","full_name":"quran/quran.com-frontend","owner":{"login":"quran","id":21640,"avatar_url":"https://avatars.githubusercontent.com/u/21640?v=3","gravatar_id":"","url":"https://api.github.com/users/quran","html_url":"https://github.com/quran","followers_url":"https://api.github.com/users/quran/followers","following_url":"https://api.github.com/users/quran/following{/other_user}","gists_url":"https://api.github.com/users/quran/gists{/gist_id}","starred_url":"https://api.github.com/users/quran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quran/subscriptions","organizations_url":"https://api.github.com/users/quran/orgs","repos_url":"https://api.github.com/users/quran/repos","events_url":"https://api.github.com/users/quran/events{/privacy}","received_events_url":"https://api.github.com/users/quran/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/quran/quran.com-frontend","description":"I am sorry... @mmahalwy isn't fun anymore...","fork":false,"url":"https://api.github.com/repos/quran/quran.com-frontend","forks_url":"https://api.github.com/repos/quran/quran.com-frontend/forks","keys_url":"https://api.github.com/repos/quran/quran.com-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quran/quran.com-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quran/quran.com-frontend/teams","hooks_url":"https://api.github.com/repos/quran/quran.com-frontend/hooks","issue_events_url":"https://api.github.com/repos/quran/quran.com-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/quran/quran.com-frontend/events","assignees_url":"https://api.github.com/repos/quran/quran.com-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/quran/quran.com-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/quran/quran.com-frontend/tags","blobs_url":"https://api.github.com/repos/quran/quran.com-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quran/quran.com-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quran/quran.com-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/quran/quran.com-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quran/quran.com-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/quran/quran.com-frontend/languages","stargazers_url":"https://api.github.com/repos/quran/quran.com-frontend/stargazers","contributors_url":"https://api.github.com/repos/quran/quran.com-frontend/contributors","subscribers_url":"https://api.github.com/repos/quran/quran.com-frontend/subscribers","subscription_url":"https://api.github.com/repos/quran/quran.com-frontend/subscription","commits_url":"https://api.github.com/repos/quran/quran.com-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/quran/quran.com-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/quran/quran.com-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/quran/quran.com-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/quran/quran.com-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/quran/quran.com-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quran/quran.com-frontend/merges","archive_url":"https://api.github.com/repos/quran/quran.com-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quran/quran.com-frontend/downloads","issues_url":"https://api.github.com/repos/quran/quran.com-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/quran/quran.com-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/quran/quran.com-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/quran/quran.com-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quran/quran.com-frontend/labels{/name}","releases_url":"https://api.github.com/repos/quran/quran.com-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/quran/quran.com-frontend/deployments","created_at":"2015-03-08T03:30:03Z","updated_at":"2016-03-15T12:56:10Z","pushed_at":"2016-03-29T19:11:00Z","git_url":"git://github.com/quran/quran.com-frontend.git","ssh_url":"git@github.com:quran/quran.com-frontend.git","clone_url":"https://github.com/quran/quran.com-frontend.git","svn_url":"https://github.com/quran/quran.com-frontend","homepage":"https://quran.com","size":266147,"stargazers_count":28,"watchers_count":28,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":59,"forks":17,"open_issues":59,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/quran/quran.com-frontend/pulls/231"},"html":{"href":"https://github.com/quran/quran.com-frontend/pull/231"},"issue":{"href":"https://api.github.com/repos/quran/quran.com-frontend/issues/231"},"comments":{"href":"https://api.github.com/repos/quran/quran.com-frontend/issues/231/comments"},"review_comments":{"href":"https://api.github.com/repos/quran/quran.com-frontend/pulls/231/comments"},"review_comment":{"href":"https://api.github.com/repos/quran/quran.com-frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/quran/quran.com-frontend/pulls/231/commits"},"statuses":{"href":"https://api.github.com/repos/quran/quran.com-frontend/statuses/a5c4f700be00c0988007b241f3b433efaefec3a9"}}}}