10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-25 05:43:46 +01:00

Create a root folder for the molecules.zip file (#10)

* Fix broken link

* Fix bug in indexDB

* Fix sourceFile  for each geometry

* Create a root folder for the Zip file

Co-authored-by: Mickaël Véril <mveril@irsamc.ups-tlse.fr>
This commit is contained in:
mveril 2020-12-08 13:43:22 +01:00 committed by GitHub
parent 7838048223
commit 24241a1207
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -725,10 +725,11 @@ draft: false
} }
async function exportGeoms() { async function exportGeoms() {
const folderName = "molecules"
var mols = new Set($("#mol_select").val()) var mols = new Set($("#mol_select").val())
if (mols.size!==0) { if (mols.size!==0) {
const zip = JSZip(); const zip = JSZip();
const root=zip.folder(folderName)
const geomDic=new Map() const geomDic=new Map()
for (const geom of window.geoms) { for (const geom of window.geoms) {
const molecule =geom.parseMetadata().molecule const molecule =geom.parseMetadata().molecule
@ -742,10 +743,10 @@ draft: false
for (const [molecule,geometries] of geomDic) { for (const [molecule,geometries] of geomDic) {
const xyz=Array.from(geometries).join("\n\n") const xyz=Array.from(geometries).join("\n\n")
var blob=new Blob([xyz],{type: 'chemical/x-xyz'}) var blob=new Blob([xyz],{type: 'chemical/x-xyz'})
zip.file(`${mhchemCE.extract(molecule).toLowerCase().replace(" ","_")}.xyz`,blob) root.file(`${mhchemCE.extract(molecule).toLowerCase().replace(" ","_")}.xyz`,blob)
} }
const zipFile = await zip.generateAsync({type: 'blob'}) const zipFile = await zip.generateAsync({type: 'blob'})
saveAs(zipFile, "molecules.zip") saveAs(zipFile, `${folderName}.zip`)
} }
} }
</script> </script>