Convert file downloads to UTF-8 when running in a browser.

master
Pacman Ghost 3 years ago
parent 692c7fd33b
commit 8bf314248e
  1. 2
      vasl_templates/webapp/static/lfa.js
  2. 2
      vasl_templates/webapp/static/scenario-upload.js
  3. 2
      vasl_templates/webapp/static/snippets.js
  4. 6
      vasl_templates/webapp/static/utils.js

@ -1890,7 +1890,7 @@ function onDownloadData()
if ( gWebChannelHandler )
gWebChannelHandler.save_log_file_analysis( data ) ;
else
download( data, "analysis.csv", "application/text" ) ;
download( toUTF8(data), "analysis.csv", "application/text" ) ;
}
}

@ -275,7 +275,7 @@ function uploadFiles( asaScenarioId )
// prepare the upload
var formData = new FormData() ;
var vtSetupJson = JSON.stringify( vtSetup, null, 4 ) ;
var vtSetupJsonUTF8 = (new TextEncoder()).encode( vtSetupJson ) ;
var vtSetupJsonUTF8 = toUTF8( vtSetupJson ) ;
formData.append( "vt_setup",
makeBlob( vtSetupJsonUTF8, "application/json" ),
prefix + "|" + "scenario.json"

@ -1842,7 +1842,7 @@ function on_save_scenario()
}
// return the parameters to the user as a downloadable file
download( data, save_fname, "application/json" ) ;
download( toUTF8(data), save_fname, "application/json" ) ;
// NOTE: We get no indication if the download was successful, so we can't show feedback :-/
// Also, if the download didn't actually happen (e.g. because it was cancelled), then setting

@ -498,6 +498,12 @@ function addUrlParam( url, param, val )
return url + "?" + param + "=" + encodeURIComponent(val) ;
}
function toUTF8( val )
{
// convert the value to UTF-8 (nb: returns a Uint8Array)
return (new TextEncoder()).encode( val ) ;
}
function escapeHTML( val ) { return new Option(val).innerHTML ; }
function trimString( val ) { return val ? val.trim() : val ; }
function fpFmt( val, nDigits ) { return val.toFixed( nDigits ) ; }

Loading…
Cancel
Save