Skip to content

Commit bbcc2b6

Browse files
committed
add logo export
1 parent 96dd453 commit bbcc2b6

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

assets/raffle.html

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ <h1 id="mainTitle">BeJUG Raffle</h1>
450450
// Security: Input sanitization function
451451
function sanitizeInput(input) {
452452
if (typeof input !== 'string') return '';
453-
return input.replace(/[<>\"'&]/g, function(match) {
453+
return input.replace(/[<>"'&]/g, function(match) {
454454
const escapeMap = {
455455
'<': '&lt;',
456456
'>': '&gt;',
@@ -486,7 +486,7 @@ <h1 id="mainTitle">BeJUG Raffle</h1>
486486
// Security: Validate file types more strictly
487487
function isValidImageFile(file) {
488488
const allowedTypes = ['image/png', 'image/jpeg', 'image/gif', 'image/webp'];
489-
return allowedTypes.includes(file.type) && file.size < 5 * 1024 * 1024; // 5MB limit
489+
return allowedTypes.includes(file.type) && file.size < 1024 *1024;
490490
}
491491

492492
function isValidCSVFile(file) {
@@ -539,7 +539,8 @@ <h1 id="mainTitle">BeJUG Raffle</h1>
539539
};
540540
reader.readAsDataURL(file);
541541
} else if (file) {
542-
showFileMessage("Please select a valid image file (PNG, JPEG, GIF, WebP, max 5MB).", "error");
542+
showFileMessage("Please select a valid image file (PNG, JPEG, GIF, WebP, max 1MB).", "error");
543+
alert("Please select a valid image file (PNG, JPEG, GIF, WebP, max 1MB).");
543544
}
544545
});
545546

@@ -787,18 +788,18 @@ <h1 id="mainTitle">BeJUG Raffle</h1>
787788
}
788789

789790
function saveSettings() {
790-
const settings = {
791+
window.currentSettings = {
791792
title: mainTitle.textContent,
792793
logoSrc: mainLogo.src.startsWith('data:') ? mainLogo.src : '',
793794
customCSS: cssInput.value
794795
};
795-
window.currentSettings = settings;
796796
}
797797

798798
function exportSettings() {
799799
const settings = {
800800
title: sanitizeInput(mainTitle.textContent),
801-
customCSS: sanitizeCSS(cssInput.value)
801+
customCSS: sanitizeCSS(cssInput.value),
802+
logoSrc: mainLogo.src.startsWith('data:') ? mainLogo.src : ''
802803
};
803804

804805
const dataStr = JSON.stringify(settings, null, 2);
@@ -815,7 +816,6 @@ <h1 id="mainTitle">BeJUG Raffle</h1>
815816
const file = importSettingsFile.files[0];
816817
if (!file) {
817818
alert("Please select a settings file to import.");
818-
return;
819819
}
820820
}
821821

@@ -830,6 +830,11 @@ <h1 id="mainTitle">BeJUG Raffle</h1>
830830
updateCSS();
831831
}
832832

833+
if(settings.logoSrc && typeof settings.logoSrc === 'string') {
834+
mainLogo.src = settings.logoSrc;
835+
mainLogo.style.display = 'block';
836+
}
837+
833838
alert("Settings imported successfully!");
834839
}
835840

0 commit comments

Comments
 (0)