{"action":"created","comment":{"url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/pulls/comments/68261372","id":68261372,"diff_hunk":"@@ -108,42 +87,82 @@ function ddg_spice_detect_lang (api_result) {\n \n         return langs[language] || \"\";\n     };\n-    Handlebars.registerHelper(\"DetectLang_expandLang\", expandLang);\n \n-    if(expandLang(api_result.data.detections[0].language) === \"\") {\n-        return;\n+    var formatTitle = function (first) {\n+        var title = \"This text is\";\n+        if (first.isReliable) {\n+            title += \" definitely \";\n+        } else {\n+            title += \" probably \";\n+        }\n+        title += expandLang(first.language);\n+        title += \" (\" + getPercentConfidence(first.confidence) + \").\";\n+        return title;\n     }\n \n-    var d0 = api_result.data.detections[0],\n-        d1 = null;\n-\n-    if (api_result.data.detections.length > 1) {\n-        d1 = api_result.data.detections[1];\n+    var formatSubtitle = function (second) {\n+        var subtitle = \"\";\n+        if (!second) {","path":"share/spice/detect_lang/detect_lang.js","position":66,"original_position":66,"commit_id":"0fa7e930aa9e8b95c30fc64f756561e82324de74","original_commit_id":"0fa7e930aa9e8b95c30fc64f756561e82324de74","user":{"login":"moollaza","id":873785,"avatar_url":"https://avatars.githubusercontent.com/u/873785?v=3","gravatar_id":"","url":"https://api.github.com/users/moollaza","html_url":"https://github.com/moollaza","followers_url":"https://api.github.com/users/moollaza/followers","following_url":"https://api.github.com/users/moollaza/following{/other_user}","gists_url":"https://api.github.com/users/moollaza/gists{/gist_id}","starred_url":"https://api.github.com/users/moollaza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moollaza/subscriptions","organizations_url":"https://api.github.com/users/moollaza/orgs","repos_url":"https://api.github.com/users/moollaza/repos","events_url":"https://api.github.com/users/moollaza/events{/privacy}","received_events_url":"https://api.github.com/users/moollaza/received_events","type":"User","site_admin":false},"body":"nit: if you make the check `if (second) {` you'll only need 1 `return` statement:\r\n\r\n```js\r\nvar subtitle = \"\";\r\nif (second) {\r\n  subtitle += \"...\";\r\n}\r\nreturn subtitle;\r\n```","created_at":"2016-06-23T15:53:25Z","updated_at":"2016-06-23T15:53:25Z","html_url":"https://github.com/duckduckgo/zeroclickinfo-spice/pull/2806#discussion_r68261372","pull_request_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/pulls/2806","_links":{"self":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/pulls/comments/68261372"},"html":{"href":"https://github.com/duckduckgo/zeroclickinfo-spice/pull/2806#discussion_r68261372"},"pull_request":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/pulls/2806"}}},"pull_request":{"url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/pulls/2806","id":73472182,"html_url":"https://github.com/duckduckgo/zeroclickinfo-spice/pull/2806","diff_url":"https://github.com/duckduckgo/zeroclickinfo-spice/pull/2806.diff","patch_url":"https://github.com/duckduckgo/zeroclickinfo-spice/pull/2806.patch","issue_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/issues/2806","number":2806,"state":"open","locked":false,"title":"DetectLang: Update code to new format and changed template to text","user":{"login":"sahildua2305","id":5206277,"avatar_url":"https://avatars.githubusercontent.com/u/5206277?v=3","gravatar_id":"","url":"https://api.github.com/users/sahildua2305","html_url":"https://github.com/sahildua2305","followers_url":"https://api.github.com/users/sahildua2305/followers","following_url":"https://api.github.com/users/sahildua2305/following{/other_user}","gists_url":"https://api.github.com/users/sahildua2305/gists{/gist_id}","starred_url":"https://api.github.com/users/sahildua2305/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sahildua2305/subscriptions","organizations_url":"https://api.github.com/users/sahildua2305/orgs","repos_url":"https://api.github.com/users/sahildua2305/repos","events_url":"https://api.github.com/users/sahildua2305/events{/privacy}","received_events_url":"https://api.github.com/users/sahildua2305/received_events","type":"User","site_admin":false},"body":"###### What does your Pull Request do (check all that apply)?\r\n\r\nChoose the most relevant items and use the following title template to name\r\nyour Pull Request.\r\n\r\n- [x] Improvement\r\n    - [x] Bug fix: **`DetectLang: Fix #988 for this IA`**\r\n\r\n###### Description of changes\r\nUpdate the code to new format having spice call in a closure\r\n\r\n###### Which issues (if any) does this fix?\r\n\r\nFixes #988 for this IA\r\n\r\n###### People to notify (@mention interested parties)\r\n@moollaza \r\n\r\n---\r\n\r\nInstant Answer Page: https://duck.co/ia/view/detect_lang\r\n\r\n[Maintainer](http://docs.duckduckhack.com/maintaining/guidelines.html): @ghedo \r\n\r\n","created_at":"2016-06-11T16:33:53Z","updated_at":"2016-06-23T15:53:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4cca1eb1e5652769b611b8ba6c1c553d77bffe21","assignee":{"login":"ghedo","id":117643,"avatar_url":"https://avatars.githubusercontent.com/u/117643?v=3","gravatar_id":"","url":"https://api.github.com/users/ghedo","html_url":"https://github.com/ghedo","followers_url":"https://api.github.com/users/ghedo/followers","following_url":"https://api.github.com/users/ghedo/following{/other_user}","gists_url":"https://api.github.com/users/ghedo/gists{/gist_id}","starred_url":"https://api.github.com/users/ghedo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ghedo/subscriptions","organizations_url":"https://api.github.com/users/ghedo/orgs","repos_url":"https://api.github.com/users/ghedo/repos","events_url":"https://api.github.com/users/ghedo/events{/privacy}","received_events_url":"https://api.github.com/users/ghedo/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/pulls/2806/commits","review_comments_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/pulls/2806/comments","review_comment_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/pulls/comments{/number}","comments_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/issues/2806/comments","statuses_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/statuses/0fa7e930aa9e8b95c30fc64f756561e82324de74","head":{"label":"sahildua2305:detectlang-improve","ref":"detectlang-improve","sha":"0fa7e930aa9e8b95c30fc64f756561e82324de74","user":{"login":"sahildua2305","id":5206277,"avatar_url":"https://avatars.githubusercontent.com/u/5206277?v=3","gravatar_id":"","url":"https://api.github.com/users/sahildua2305","html_url":"https://github.com/sahildua2305","followers_url":"https://api.github.com/users/sahildua2305/followers","following_url":"https://api.github.com/users/sahildua2305/following{/other_user}","gists_url":"https://api.github.com/users/sahildua2305/gists{/gist_id}","starred_url":"https://api.github.com/users/sahildua2305/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sahildua2305/subscriptions","organizations_url":"https://api.github.com/users/sahildua2305/orgs","repos_url":"https://api.github.com/users/sahildua2305/repos","events_url":"https://api.github.com/users/sahildua2305/events{/privacy}","received_events_url":"https://api.github.com/users/sahildua2305/received_events","type":"User","site_admin":false},"repo":{"id":60915991,"name":"zeroclickinfo-spice","full_name":"sahildua2305/zeroclickinfo-spice","owner":{"login":"sahildua2305","id":5206277,"avatar_url":"https://avatars.githubusercontent.com/u/5206277?v=3","gravatar_id":"","url":"https://api.github.com/users/sahildua2305","html_url":"https://github.com/sahildua2305","followers_url":"https://api.github.com/users/sahildua2305/followers","following_url":"https://api.github.com/users/sahildua2305/following{/other_user}","gists_url":"https://api.github.com/users/sahildua2305/gists{/gist_id}","starred_url":"https://api.github.com/users/sahildua2305/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sahildua2305/subscriptions","organizations_url":"https://api.github.com/users/sahildua2305/orgs","repos_url":"https://api.github.com/users/sahildua2305/repos","events_url":"https://api.github.com/users/sahildua2305/events{/privacy}","received_events_url":"https://api.github.com/users/sahildua2305/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sahildua2305/zeroclickinfo-spice","description":"DuckDuckGo Instant Answers based on JavaScript (JSON) APIs","fork":true,"url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice","forks_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/forks","keys_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/teams","hooks_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/hooks","issue_events_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/issues/events{/number}","events_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/events","assignees_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/assignees{/user}","branches_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/branches{/branch}","tags_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/tags","blobs_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/git/refs{/sha}","trees_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/statuses/{sha}","languages_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/languages","stargazers_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/stargazers","contributors_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/contributors","subscribers_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/subscribers","subscription_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/subscription","commits_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/commits{/sha}","git_commits_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/git/commits{/sha}","comments_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/comments{/number}","issue_comment_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/issues/comments{/number}","contents_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/contents/{+path}","compare_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/merges","archive_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/downloads","issues_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/issues{/number}","pulls_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/pulls{/number}","milestones_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/milestones{/number}","notifications_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/labels{/name}","releases_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/releases{/id}","deployments_url":"https://api.github.com/repos/sahildua2305/zeroclickinfo-spice/deployments","created_at":"2016-06-11T16:16:27Z","updated_at":"2016-06-11T16:16:32Z","pushed_at":"2016-06-22T18:07:31Z","git_url":"git://github.com/sahildua2305/zeroclickinfo-spice.git","ssh_url":"git@github.com:sahildua2305/zeroclickinfo-spice.git","clone_url":"https://github.com/sahildua2305/zeroclickinfo-spice.git","svn_url":"https://github.com/sahildua2305/zeroclickinfo-spice","homepage":"http://duckduckhack.com/","size":19563,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"duckduckgo:master","ref":"master","sha":"0171288f7a0eea1ad0808dcb258b65068059023e","user":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"repo":{"id":1997671,"name":"zeroclickinfo-spice","full_name":"duckduckgo/zeroclickinfo-spice","owner":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/duckduckgo/zeroclickinfo-spice","description":"DuckDuckGo Instant Answers based on JavaScript (JSON) APIs","fork":false,"url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice","forks_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/forks","keys_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/teams","hooks_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/hooks","issue_events_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/issues/events{/number}","events_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/events","assignees_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/assignees{/user}","branches_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/branches{/branch}","tags_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/tags","blobs_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/git/refs{/sha}","trees_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/statuses/{sha}","languages_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/languages","stargazers_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/stargazers","contributors_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/contributors","subscribers_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/subscribers","subscription_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/subscription","commits_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/commits{/sha}","git_commits_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/git/commits{/sha}","comments_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/comments{/number}","issue_comment_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/issues/comments{/number}","contents_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/contents/{+path}","compare_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/merges","archive_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/downloads","issues_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/issues{/number}","pulls_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/pulls{/number}","milestones_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/milestones{/number}","notifications_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/labels{/name}","releases_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/releases{/id}","deployments_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/deployments","created_at":"2011-07-04T22:08:37Z","updated_at":"2016-06-20T16:07:55Z","pushed_at":"2016-06-23T13:46:52Z","git_url":"git://github.com/duckduckgo/zeroclickinfo-spice.git","ssh_url":"git@github.com:duckduckgo/zeroclickinfo-spice.git","clone_url":"https://github.com/duckduckgo/zeroclickinfo-spice.git","svn_url":"https://github.com/duckduckgo/zeroclickinfo-spice","homepage":"http://duckduckhack.com/","size":28248,"stargazers_count":348,"watchers_count":348,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":930,"mirror_url":null,"open_issues_count":192,"forks":930,"open_issues":192,"watchers":348,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/pulls/2806"},"html":{"href":"https://github.com/duckduckgo/zeroclickinfo-spice/pull/2806"},"issue":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/issues/2806"},"comments":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/issues/2806/comments"},"review_comments":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/pulls/2806/comments"},"review_comment":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/pulls/2806/commits"},"statuses":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-spice/statuses/0fa7e930aa9e8b95c30fc64f756561e82324de74"}}}}
{"actor":{"display_login":"moollaza"}}