Skip to content

Commit

Permalink
fix fav, logo handling
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed Jun 5, 2024
1 parent 62d3352 commit 01935a8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
23 changes: 5 additions & 18 deletions src/js/fileupload2.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function addIconAndLogo(siteUrl) {
.attr(
'href',
siteUrl +
'/javax.faces.resource/images/fav/apple-touch-icon.png.xhtml'))
'/jakarta.faces.resource/images/fav/apple-touch-icon.png.xhtml'))
.append(
$('<link/>')
.attr('type', 'image/png')
Expand All @@ -145,7 +145,7 @@ function addIconAndLogo(siteUrl) {
.attr(
'href',
siteUrl +
'/javax.faces.resource/images/fav/favicon-16x16.png.xhtml'))
'/jakarta.faces.resource/images/fav/favicon-16x16.png.xhtml'))
.append(
$('<link/>')
.attr('type', 'image/png')
Expand All @@ -154,7 +154,7 @@ function addIconAndLogo(siteUrl) {
.attr(
'href',
siteUrl +
'/javax.faces.resource/images/fav/favicon-32x32.png.xhtml'))
'/jakarta.faces.resource/images/fav/favicon-32x32.png.xhtml'))

.append(
$('<link/>')
Expand All @@ -163,7 +163,7 @@ function addIconAndLogo(siteUrl) {
.attr(
'href',
siteUrl +
'/javax.faces.resource/images/fav/safari-pinned-tab.svg.xhtml'))
'/jakarta.faces.resource/images/fav/safari-pinned-tab.svg.xhtml'))
.append(
$('<meta/>')
.attr('content', '#da532c')
Expand All @@ -174,8 +174,7 @@ function addIconAndLogo(siteUrl) {
.attr('name', 'theme-color'));
$('#logo')
.attr('src', siteUrl + '/logos/preview_logo.svg')
.attr('onerror', "handleImageError(this)");

.attr('onerror', "handleImageError(this,'".concat(siteUrl).concat("')"));
}
function initTranslation() {
initSpanTxt('title-text', 'title');
Expand Down Expand Up @@ -1030,16 +1029,4 @@ function getChecksum(blob, cbProgress) {
}
});
});
}
function handleImageError(image) {
let currentFallback = parseInt(image.getAttribute('data-fallback-index') || '0');

if(currentFallback == 0){
image.src = siteUrl + '/logos/preview_logo.png';
image.dataset.fallbackIndex = 1;
}
else{
image.src = 'images/logo_placeholder.png';
image.onerror = null;
}
}
12 changes: 12 additions & 0 deletions src/js/logoHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function handleImageError(image, siteUrl) {
let currentFallback = parseInt(image.getAttribute('data-fallback-index') || '0');

if(currentFallback == 0){
image.src = siteUrl + '/logos/preview_logo.png';
image.dataset.fallbackIndex = 1;
}
else{
image.src = 'images/logo_placeholder.png';
image.onerror = null;
}
}

0 comments on commit 01935a8

Please sign in to comment.