]> git.immae.eu Git - github/bastienwirtz/homer.git/blobdiff - app.js
Remove config.yml from service worker to avoid caching issues
[github/bastienwirtz/homer.git] / app.js
diff --git a/app.js b/app.js
index 93902d803cbef8e1c4e72e9f2997b645198fae55..6c8307436749b5a33e039aafefc5aaed994b6805 100644 (file)
--- a/app.js
+++ b/app.js
@@ -5,27 +5,29 @@ const app = new Vue({
         offline: false,
         filter: '',
         vlayout: true,
-        isDark: null
+        isDark: null,
+        showMenu: false
     },
     created: async function () {
         let that = this;
 
-        this.isDark = 'overrideDark' in localStorage ? 
+        this.isDark = 'overrideDark' in localStorage ?
             JSON.parse(localStorage.overrideDark) : matchMedia("(prefers-color-scheme: dark)").matches;
 
         if ('vlayout' in localStorage) {
             this.vlayout = JSON.parse(localStorage.vlayout)
         }
-        
+
         this.checkOffline();
         try {
             this.config =  await this.getConfig();
+            document.title = this.config.title + ' | Homer';
         } catch (error) {
             this.offline = true;
         }
 
         // Look for a new message if an endpoint is provided.
-        if (this.config.message.url) {
+        if (this.config.message && this.config.message.url) {
             this.getMessage(this.config.message.url).then(function(message){
                 // keep the original config value if no value is provided by the endpoint
                 for (const prop of ['title','style','content']) {
@@ -78,8 +80,11 @@ const app = new Vue({
         }, 
         toggleLayout: function() {
             this.vlayout = !this.vlayout;
-            localStorage.vlayout = this.vlayout; 
-        }, 
+            localStorage.vlayout = this.vlayout;
+        },
+        toggleMenu: function() {
+            this.showMenu = !this.showMenu;
+        }
     }
 });
 
@@ -87,7 +92,7 @@ Vue.component('service', {
     props: ['item'],
     template: `<div>
     <div class="card">
-        <a :href="item.url">
+        <a :href="item.url" :target="item.target">
             <div class="card-content">
                 <div class="media">
                     <div v-if="item.logo" class="media-left">
@@ -115,6 +120,6 @@ Vue.component('service', {
 
 if ('serviceWorker' in navigator) {
     window.addEventListener('load', function () {
-        navigator.serviceWorker.register('/worker.js');
+        navigator.serviceWorker.register('worker.js');
     });
 }