aboutsummaryrefslogtreecommitdiffhomepage
path: root/app.js
diff options
context:
space:
mode:
authorBastien Wirtz <bastien.wirtz@gmail.com>2020-04-13 09:46:48 -0700
committerGitHub <noreply@github.com>2020-04-13 09:46:48 -0700
commitd2bf5e5f62c2a8d94b27529424a96066ead3e5b1 (patch)
treef7934df7d7daae99b03441cad8f192aa7dbed033 /app.js
parent0503e77861fcdfeaf20e1cc06dbc2f49d06bc45b (diff)
parenta4de4a3a71e460141b740564ef22d1c79760db4e (diff)
downloadhomer-d2bf5e5f62c2a8d94b27529424a96066ead3e5b1.tar.gz
homer-d2bf5e5f62c2a8d94b27529424a96066ead3e5b1.tar.zst
homer-d2bf5e5f62c2a8d94b27529424a96066ead3e5b1.zip
Merge pull request #37 from jozefs/master
Add keyboard shortcuts to navigate to the first search result.
Diffstat (limited to 'app.js')
-rw-r--r--app.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/app.js b/app.js
index 36508ab..e796110 100644
--- a/app.js
+++ b/app.js
@@ -84,6 +84,26 @@ const app = new Vue({
84 }, 84 },
85 toggleMenu: function() { 85 toggleMenu: function() {
86 this.showMenu = !this.showMenu; 86 this.showMenu = !this.showMenu;
87 },
88 matchesFilter: function(item) {
89 return (item.name.toLowerCase().includes(this.filter.toLowerCase())
90 || (item.tag && item.tag.toLowerCase().includes(this.filter.toLowerCase())))
91 },
92 firstMatchingService: function() {
93 for (group of this.config.services) {
94 for (item of group.items) {
95 if (this.matchesFilter(item)) {
96 return item;
97 }
98 }
99 }
100 return null;
101 },
102 navigateToFirstService: function(target) {
103 service = this.firstMatchingService();
104 if (service) {
105 window.open(service.url, target || service.target || '_self');
106 }
87 } 107 }
88 }, 108 },
89 mounted() { 109 mounted() {