]>
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();
27 // Look for a new message if an endpoint is provided.
28 if (this.config
.message
.url
) {
29 this.getMessage(this.config
.message
.url
).then(function(message
){
30 // keep the original config value if no value is provided by the endpoint
31 for (const prop
of ['title','style','content']) {
32 if (prop
in message
&& message
[prop
] !== null) {
33 that
.config
.message
[prop
] = message
[prop
];
39 document
.addEventListener('visibilitychange', function () {
40 if (document
.visibilityState
== "visible") {
46 checkOffline: function () {
48 return fetch(window
.location
.href
+ "?alive", {
53 }).catch(function () {
57 getConfig: function (event
) {
58 return fetch('config.yml').then(function (response
) {
59 if (response
.status
!= 200) {
62 return response
.text().then(function (body
) {
63 return jsyaml
.load(body
);
67 getMessage: function (url
) {
68 return fetch(url
).then(function (response
) {
69 if (response
.status
!= 200) {
72 return response
.json();
75 toggleTheme: function() {
76 this.isDark
= !this.isDark
;
77 localStorage
.overrideDark
= this.isDark
;
79 toggleLayout: function() {
80 this.vlayout
= !this.vlayout
;
81 localStorage
.vlayout
= this.vlayout
;
86 Vue
.component('service', {
91 <div class="card-content">
93 <div v-if="item.logo" class="media-left">
94 <figure class="image is-48x48">
95 <img :src="item.logo" />
98 <div v-if="item.icon" class="media-left">
99 <figure class="image is-48x48">
100 <i style="font-size: 35px" :class="item.icon"></i>
103 <div class="media-content">
104 <p class="title is-4">{{ item.name }}</p>
105 <p class="subtitle is-6">{{ item.subtitle }}</p>
108 <div class="tag" :class="item.tagstyle" v-if="item.tag">
109 <strong class="tag-text">#{{ item.tag }}</strong>
116 if ('serviceWorker' in navigator
) {
117 window
.addEventListener('load', function () {
118 navigator
.serviceWorker
.register('worker.js');