]>
git.immae.eu Git - github/bastienwirtz/homer.git/blob - app.js
10 created: async
function () {
13 this.isDark
= 'overrideDark' in localStorage
?
14 JSON
.parse(localStorage
.overrideDark
) : matchMedia("(prefers-color-scheme: dark)").matches
;
16 if ('vlayout' in localStorage
) {
17 this.vlayout
= JSON
.parse(localStorage
.vlayout
)
22 this.config
= await
this.getConfig();
23 document
.title
= this.config
.title
+ ' | Homer';
28 // Look for a new message if an endpoint is provided.
29 if (this.config
.message
&& this.config
.message
.url
) {
30 this.getMessage(this.config
.message
.url
).then(function(message
){
31 // keep the original config value if no value is provided by the endpoint
32 for (const prop
of ['title','style','content']) {
33 if (prop
in message
&& message
[prop
] !== null) {
34 that
.config
.message
[prop
] = message
[prop
];
40 document
.addEventListener('visibilitychange', function () {
41 if (document
.visibilityState
== "visible") {
47 checkOffline: function () {
49 return fetch(window
.location
.href
+ "?alive", {
54 }).catch(function () {
58 getConfig: function (event
) {
59 return fetch('config.yml').then(function (response
) {
60 if (response
.status
!= 200) {
63 return response
.text().then(function (body
) {
64 return jsyaml
.load(body
);
68 getMessage: function (url
) {
69 return fetch(url
).then(function (response
) {
70 if (response
.status
!= 200) {
73 return response
.json();
76 toggleTheme: function() {
77 this.isDark
= !this.isDark
;
78 localStorage
.overrideDark
= this.isDark
;
80 toggleLayout: function() {
81 this.vlayout
= !this.vlayout
;
82 localStorage
.vlayout
= this.vlayout
;
87 Vue
.component('service', {
91 <a :href="item.url" :target="item.target">
92 <div class="card-content">
94 <div v-if="item.logo" class="media-left">
95 <figure class="image is-48x48">
96 <img :src="item.logo" />
99 <div v-if="item.icon" class="media-left">
100 <figure class="image is-48x48">
101 <i style="font-size: 35px" :class="item.icon"></i>
104 <div class="media-content">
105 <p class="title is-4">{{ item.name }}</p>
106 <p class="subtitle is-6">{{ item.subtitle }}</p>
109 <div class="tag" :class="item.tagstyle" v-if="item.tag">
110 <strong class="tag-text">#{{ item.tag }}</strong>
117 if ('serviceWorker' in navigator
) {
118 window
.addEventListener('load', function () {
119 navigator
.serviceWorker
.register('worker.js');