Added encoding selecting options
This commit is contained in:
parent
c16fc1204e
commit
6a352f9c44
@ -127,6 +127,12 @@
|
||||
<input type="text" name="separator" value="," class="spam1"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">Encoding</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="encoding" value="UTF-8" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">Import »</button>
|
||||
</div>
|
||||
|
||||
@ -128,7 +128,8 @@ function setupLoader(callback) {
|
||||
var $file = $form.find('input[type="file"]')[0];
|
||||
var file = $file.files[0];
|
||||
var options = {
|
||||
separator : $form.find('input[name="separator"]').val()
|
||||
separator : $form.find('input[name="separator"]').val(),
|
||||
encoding : $form.find('input[name="encoding"]').val()
|
||||
};
|
||||
recline.Backend.loadFromCSVFile(file, function(dataset) {
|
||||
callback(dataset)
|
||||
|
||||
@ -3,6 +3,8 @@ this.recline.Backend = this.recline.Backend || {};
|
||||
|
||||
(function($, my) {
|
||||
my.loadFromCSVFile = function(file, callback, options) {
|
||||
var encoding = options.encoding || 'UTF-8';
|
||||
|
||||
var metadata = {
|
||||
id: file.name,
|
||||
file: file
|
||||
@ -16,7 +18,7 @@ this.recline.Backend = this.recline.Backend || {};
|
||||
reader.onerror = function (e) {
|
||||
alert('Failed to load file. Code: ' + e.target.error.code);
|
||||
};
|
||||
reader.readAsText(file);
|
||||
reader.readAsText(file, encoding);
|
||||
};
|
||||
|
||||
my.csvToDataset = function(csvString, options) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user