]> git.immae.eu Git - github/bastienwirtz/homer.git/blobdiff - app.js
Merge pull request #60 from sylv-io/html-title
[github/bastienwirtz/homer.git] / app.js
diff --git a/app.js b/app.js
index 36508abb694ef108fc0ecbfd552f3cda62a71f81..9e6bdd9a12d813efec730f25613701cb41a45389 100644 (file)
--- a/app.js
+++ b/app.js
@@ -21,7 +21,7 @@ const app = new Vue({
         this.checkOffline();
         try {
             this.config =  await this.getConfig();
-            document.title = this.config.title + ' | Homer';
+            document.title = this.config.title + ' | ' + this.config.subtitle;
         } catch (error) {
             this.offline = true;
         }
@@ -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() {