- Timestamp:
- 2021-09-15T11:42:33+12:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/TranscriptionItem.vue
r35399 r35400 119 119 }, 120 120 downloadAsText() { 121 const extensionIndex = this.transcription.fileName.lastIndexOf("."); 122 let fileName = this.transcription.fileName.slice(0, extensionIndex); 123 fileName += "_transcription.txt"; 121 const fileName = buildDownloadableFileName(this.transcription.fileName, "txt"); 124 122 125 123 const blob = new Blob([ this.transcription.transcription ], { type: "text/plain;charset=utf-8" }); 124 saveAs(blob, fileName); 125 }, 126 downloadAsJson() { 127 const fileName = buildDownloadableFileName(this.transcription.fileName, "json"); 128 const toDownload = (({ fileName, transcription, metadata }) => ({ fileName, transcription, metadata }))(this.transcription); 129 130 const blob = new Blob([ JSON.stringify(toDownload, null, 4) ], { type: "application/json;charset=utf-8" }); 126 131 saveAs(blob, fileName); 127 132 } 128 133 } 129 134 } 135 136 /** 137 * Builds a file name for a download. 138 * @param {String} transcriptionFileName The name of the transcription that will be downloaded. 139 * @param {String} extension The file extension of the download. Do not include a period. 140 * @returns {String} The file name. 141 */ 142 function buildDownloadableFileName(transcriptionFileName, extension) { 143 const extensionIndex = transcriptionFileName.lastIndexOf("."); 144 let fileName = transcriptionFileName.slice(0, extensionIndex); 145 fileName += "_transcription." + extension; 146 147 return fileName; 148 } 130 149 </script>
Note:
See TracChangeset
for help on using the changeset viewer.