Skip to content

Commit

Permalink
fix invalid file handling
Browse files Browse the repository at this point in the history
  • Loading branch information
a-sync committed May 2, 2024
1 parent a0f5c61 commit db0aa6a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 41 deletions.
51 changes: 26 additions & 25 deletions main.css
Original file line number Diff line number Diff line change
Expand Up @@ -443,57 +443,58 @@ dialog+.backdrop {
backdrop-filter: blur(4px);
}

.filepond--label-action {
text-decoration-color: var(--links);
.filepond--drop-label {
cursor: pointer;
}

.filepond--item-panel {
background-color: var(--button-base);

.filepond--drop-label:hover {
border: 2px dashed var(--focus);
border-radius: 0.5em;
}

.filepond--item:hover .filepond--panel .filepond--item-panel {
background-color: var(--focus) !important;
.filepond--drop-label label {
color: var(--text-main);
font-family: 'Black Ops One', Helvetica, Arial, sans-serif;
font-size: 1.5em;
font-weight: 400;
font-variant: small-caps;
text-align: center;
cursor: pointer;
}

.filepond--panel-top:after, .filepond--panel-bottom:before {
background-color: transparent;
.filepond--label-action {
text-decoration-color: var(--links);
}

.filepond--drip-blob {
background-color: var(--button-base);
}

.filepond--file {
color: var(--text-main);
}

.filepond--panel-root {
background-color: var(--background-alt);
}

.filepond--drop-label {
cursor: pointer;
.filepond--item[data-filepond-item-state='idle']:hover .filepond--panel .filepond--item-panel {
background-color: var(--focus) !important;
}

.filepond--drop-label:hover {
border: 2px dashed var(--focus);
border-radius: 0.5em;
.filepond--panel-top:after, .filepond--panel-bottom:before {
background-color: transparent;
}

.filepond--drop-label label {
color: var(--text-main);
font-family: 'Black Ops One', Helvetica, Arial, sans-serif;
font-size: 1.5em;
font-weight: 400;
font-variant: small-caps;
text-align: center;
cursor: pointer;
.filepond--item-panel {
background-color: var(--button-base);
}

.filepond--item[data-filepond-item-state='idle'] {
cursor: pointer;
}

.filepond--file {
color: var(--text-main);
}

@media (prefers-color-scheme: dark) {
#footer a.github {
fill: #c6cbd1;
Expand Down
34 changes: 18 additions & 16 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,24 @@ async function init() {
reader.readAsText(file.slice(0, CHUNK_SIZE));
}),
onactivatefile: (fileItem) => {
const reader = new FileReader();
reader.onload = (event) => {
const content = event.target.result;
const parsedFile = parsePresetFile(content, fileItem.filenameWithoutExtension);
if (DBG) console.log('dbg:fileItem, parsedMods', fileItem, parsedFile);

const originPath = window.location.origin + String(window.location.path || '');
window.open(originPath + '?' + parsedFile.name + '=' + parsedFile.ids.join(','), '_blank');
};

reader.onerror = (err) => {
reject();
console.error('FileReader error:', err);
};

reader.readAsText(fileItem.file);
if (fileItem.status === 2) {
const reader = new FileReader();
reader.onload = (event) => {
const content = event.target.result;
const parsedFile = parsePresetFile(content, fileItem.filenameWithoutExtension);
if (DBG) console.log('dbg:fileItem, parsedMods', fileItem, parsedFile);

const originPath = window.location.origin + String(window.location.path || '');
window.open(originPath + '?' + parsedFile.name + '=' + parsedFile.ids.join(','), '_blank');
};

reader.onerror = (err) => {
reject();
console.error('FileReader error:', err);
};

reader.readAsText(fileItem.file);
}
}
});
}
Expand Down

0 comments on commit db0aa6a

Please sign in to comment.