Skip to content

Commit

Permalink
fix game PWA icons
Browse files Browse the repository at this point in the history
  • Loading branch information
octospacc committed Apr 4, 2024
1 parent 53fd0ea commit 5e02607
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions assets/js/pwa.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ var Prefs = SalaMuseoGames.Prefs;
var Software = SalaMuseoGames.page.software_data;
var Screen = (Software && Software.screen);
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) {
var manifestData;
Expand All @@ -29,20 +41,19 @@ if (Prefs.pwaManifests.value) {
break;
};
}
var pageUrl = (Site.url + Site.baseurl);
manifestData = {
name: ldData.name,
description: ldData.description,
start_url: pageUrl,
scope: pageUrl,
start_url: sitePath,
scope: sitePath,
display: "standalone",
};
}
manifestData = Object.assign(manifestData, {
scope: location.href,
background_color: (Software && Software.background_color || getComputedStyle(document.body).backgroundColor),
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",
purpose: "any",
}],
Expand Down

0 comments on commit 5e02607

Please sign in to comment.