X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app.js;h=e79611069f9d779d4a09e969157ec805b0c24628;hb=b317857892921423479b713fb530f5d07d1f5d82;hp=36508abb694ef108fc0ecbfd552f3cda62a71f81;hpb=6eba37a370cdd3c0275d49fa693ab189d8ab8ff2;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() {