Skip to content

Commit

Permalink
Add export name getting from download url
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Nov 20, 2023
1 parent fc2027b commit d26815e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion assets/js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,21 @@ $(document).ready(function () {
}
});

function extractFilename(inputString) {
const parts = inputString.split("/");
const filenameWithExtension = parts[parts.length - 1];

const filenameParts = filenameWithExtension.split(".");
const fileExtension = filenameParts[filenameParts.length - 1];
const filenameWithoutExtension = filenameParts.slice(0, -1).join(".");

if (filenameWithoutExtension.includes("_uid_")) {
const uidParts = filenameWithoutExtension.split("_uid_");
return uidParts[0] + "." + fileExtension;
} else {
return filenameWithoutExtension + "." + fileExtension;
}
}
function populate_results(data) {
console.log(data);
area = document.getElementById("summary_response").rows[0].cells;
Expand All @@ -585,7 +600,7 @@ $(document).ready(function () {
'<a id="response_file_download" href="' +
data.download_url +
'">' +
data.file_name +
extractFilename(data.download_url) +
'</a>&nbsp;<span style="cursor: pointer;" onclick="(function(text) {' +
" var dummyTextarea = document.createElement('textarea');" +
" dummyTextarea.value = text;" +
Expand Down

0 comments on commit d26815e

Please sign in to comment.