Skip to content

Commit

Permalink
Partially fixes issue #15, storing a transcipt of user input
Browse files Browse the repository at this point in the history
  • Loading branch information
Baltasarq committed May 10, 2023
1 parent 38e2ac9 commit 6fdc47d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 10 additions & 1 deletion lib/fi.js
Original file line number Diff line number Diff line change
Expand Up @@ -849,12 +849,21 @@ const ctrl = ( function() {

function saveTranscript()
{
// Prepare history
let transcript = history
let lastLinePos = transcript.trim().lastIndexOf( "\n" );

if ( lastLinePos > 0 ) {
transcript = transcript.substring( 0, lastLinePos );
}

// Prepare HTML infraestructure
const link = document.createElement( "a" );

link.id = "hiddenSave";
link.style.display = "none";
link.download = "transcription.txt";
link.href = "data:text/plain," + encodeURI( history );
link.href = "data:text/plain," + encodeURI( transcript );

document.body.appendChild( link );
link.click();
Expand Down
12 changes: 2 additions & 10 deletions lib/verbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2343,16 +2343,8 @@ const transcriptAction = actions.crea( "transcript",
);

transcriptAction.exe = function(s) {
var toret = "";

if ( ctrl.saveTranscript() ) {
toret += "Transcripción guardada.";
} else {
toret += "Error guardando Transcripción \
(localStorage no soportado?).";
}

return toret;
ctrl.saveTranscript();
return "Transcripción guardada.";
}

transcriptAction.doIt = function(s) {
Expand Down

0 comments on commit 6fdc47d

Please sign in to comment.