Skip to content

Commit

Permalink
Fixes valid file check, adds user feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
alderg committed May 27, 2024
1 parent c69c48c commit 3edd4bb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tools/convert.html
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,10 @@
{
try
{
var value = document.getElementById('textarea').value;

var value = document.getElementById('textarea').value.trim();
// Checks if file ends with </mxfile>
if (value.substring(value.length - 8) != '</mxfile>')
if (value.substring(value.length - 9) != '</mxfile>')
{
// Finds last </diagram>
var index = value.lastIndexOf('</diagram>');
Expand All @@ -432,6 +432,14 @@
document.getElementById('textarea').value = value;
alert('File corrected');
}
else
{
alert('Invalid file');
}
}
else
{
alert('File already correct');
}
}
catch (e)
Expand All @@ -445,7 +453,7 @@
{
var a = document.createElement('a');
a.href = URL.createObjectURL(new Blob([document.getElementById('textarea').value], {type: 'text/plain'}));
a.download = 'download.txt';
a.download = 'download.drawio';
document.body.appendChild(a);
a.click();
};
Expand Down

1 comment on commit 3edd4bb

@davidjgraph
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed.

Please sign in to comment.