fix game PWA icons
This commit is contained in:
parent
53fd0eae7a
commit
5e0260767d
|
@ -4,6 +4,18 @@ var Prefs = SalaMuseoGames.Prefs;
|
||||||
var Software = SalaMuseoGames.page.software_data;
|
var Software = SalaMuseoGames.page.software_data;
|
||||||
var Screen = (Software && Software.screen);
|
var Screen = (Software && Software.screen);
|
||||||
var Site = SalaMuseoGames.site;
|
var Site = SalaMuseoGames.site;
|
||||||
|
var iconUrl = SalaMuseoGames.page.icon;
|
||||||
|
var sitePath = (Site.url + Site.baseurl);
|
||||||
|
|
||||||
|
function absoluteUrlFromRelative (url) {
|
||||||
|
if (url.startsWith('/')) {
|
||||||
|
return (sitePath + url);
|
||||||
|
} else if (url.startsWith('./') || url.startsWith('../')) {
|
||||||
|
return (location.href + url);
|
||||||
|
} else {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Prefs.pwaManifests.value) {
|
if (Prefs.pwaManifests.value) {
|
||||||
var manifestData;
|
var manifestData;
|
||||||
|
@ -29,12 +41,11 @@ if (Prefs.pwaManifests.value) {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var pageUrl = (Site.url + Site.baseurl);
|
|
||||||
manifestData = {
|
manifestData = {
|
||||||
name: ldData.name,
|
name: ldData.name,
|
||||||
description: ldData.description,
|
description: ldData.description,
|
||||||
start_url: pageUrl,
|
start_url: sitePath,
|
||||||
scope: pageUrl,
|
scope: sitePath,
|
||||||
display: "standalone",
|
display: "standalone",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -42,7 +53,7 @@ if (Prefs.pwaManifests.value) {
|
||||||
scope: location.href,
|
scope: location.href,
|
||||||
background_color: (Software && Software.background_color || getComputedStyle(document.body).backgroundColor),
|
background_color: (Software && Software.background_color || getComputedStyle(document.body).backgroundColor),
|
||||||
icons: [{
|
icons: [{
|
||||||
src: (SalaMuseoGames.page.icon || (Site.url + Site.baseurl + '/assets/img/icons/mediumtile.png')),
|
src: (iconUrl ? absoluteUrlFromRelative(iconUrl) : (sitePath + '/assets/img/icons/mediumtile.png')),
|
||||||
sizes: "any",
|
sizes: "any",
|
||||||
purpose: "any",
|
purpose: "any",
|
||||||
}],
|
}],
|
||||||
|
|
Loading…
Reference in New Issue