Skip to content

Commit

Permalink
(feature/upload_text) Add a feature to read an upload client side
Browse files Browse the repository at this point in the history
  • Loading branch information
PonteIneptique committed Aug 10, 2020
1 parent bff0ed7 commit a129625
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/templates/main/corpus_new.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ <h1>Create a new corpus</h1>

<fieldset class="form-fieldset">
<legend>Data</legend>
<div class="form-group row">
<div class="col-md-3">
<label for="upload">Text file</label>
<small id="upload_help" class="form-text form-group">Upload a text file (.txt) which will be read</small>
</div>
<div class="col-md-9">
<input type="file" id="upload" placeholder="Text file" />
</div>
</div>
<div class="form-group">
<label for="tokens">Tokens (as TSV content)</label>
<small id="tsvHelp" class="form-text text-muted">The TSV should at least have the headers : form, lemma, POS, morph</small>
Expand Down Expand Up @@ -178,6 +187,19 @@ <h1>Create a new corpus</h1>
<script type="text/javascript">

$(document).ready(function() {

document.getElementById('upload').addEventListener('change', readFile, false);

function readFile (evt) {
var files = evt.target.files;
var file = files[0];
var reader = new FileReader();
reader.onload = function(event) {
document.getElementById('tokens').value = event.target.result;
};
reader.readAsText(file);
}

$("#submit-model").on("click", function(event) {
event.preventDefault();
// Get the parameters
Expand Down

0 comments on commit a129625

Please sign in to comment.