X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app.js;h=e79611069f9d779d4a09e969157ec805b0c24628;hb=a4de4a3a71e460141b740564ef22d1c79760db4e;hp=36508abb694ef108fc0ecbfd552f3cda62a71f81;hpb=0503e77861fcdfeaf20e1cc06dbc2f49d06bc45b;p=github%2Fbastienwirtz%2Fhomer.git 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({ }, toggleMenu: function() { this.showMenu = !this.showMenu; + }, + matchesFilter: function(item) { + return (item.name.toLowerCase().includes(this.filter.toLowerCase()) + || (item.tag && item.tag.toLowerCase().includes(this.filter.toLowerCase()))) + }, + firstMatchingService: function() { + for (group of this.config.services) { + for (item of group.items) { + if (this.matchesFilter(item)) { + return item; + } + } + } + return null; + }, + navigateToFirstService: function(target) { + service = this.firstMatchingService(); + if (service) { + window.open(service.url, target || service.target || '_self'); + } } }, mounted() {