Skip to content

Commit

Permalink
first attempt to improve search auto suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
qazbnm456 committed Apr 4, 2017
1 parent a670dfa commit d09c0b6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"main": "./dist/main.js",
"dependencies": {
"babel-runtime": "^6.23.0",
"fetch-jsonp": "^1.0.6",
"vue": "^2.2.6",
"vue-electron": "^1.0.6",
"vue-resource": "^1.2.1",
Expand Down
12 changes: 12 additions & 0 deletions app/src/renderer/components/BrowserMainView/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import Vue from 'vue';
import url from 'url';
import { focus } from 'vue-focus';
import fetchJsonp from 'fetch-jsonp';
import Icon from 'vue-awesome/components/Icon';
import 'vue-awesome/icons/angle-double-left';
Expand Down Expand Up @@ -228,6 +229,17 @@
value: this.value,
});
}
fetchJsonp(`https://suggestqueries.google.com/complete/search?client=youtube&q=${this.value}`)
.then(response => response.json())
.then(data => data[1])
.then((entries) => {
entries.forEach((entry) => {
results.push({
title: entry[0],
value: entry[0],
});
});
});
cb(results);
},
createFilter(queryString) {
Expand Down
4 changes: 4 additions & 0 deletions app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ duplexer3@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2"

fetch-jsonp@^1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/fetch-jsonp/-/fetch-jsonp-1.0.6.tgz#8d2ae174ed14108292f025f43fa07d2078de6736"

get-stream@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14"
Expand Down

0 comments on commit d09c0b6

Please sign in to comment.