Skip to content
This repository has been archived by the owner on Sep 3, 2018. It is now read-only.

Commit

Permalink
Fixed #57
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSGill committed Jan 31, 2015
1 parent e718631 commit 5e64499
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 16 deletions.
11 changes: 10 additions & 1 deletion WebApp/src/css/_default_styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,10 @@ form

.filePicker input
{
width: 310px;
width: 405px;
margin-top: 5px;
background: @filters-separator;
font-style: italic;
}

.filePicker button
Expand All @@ -857,6 +859,13 @@ form
font-size: larger;
}

.importDetails
{
color: @todo-priority-default;
font-family: 'Courier New', monospace;
text-align: center;
}

.dragOver
{
border-color: @import-border-hover;
Expand Down
40 changes: 26 additions & 14 deletions WebApp/src/js/views/importing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ module TodoTxtJs.View
$dropTargetChild.on('dragover', this.dragOver);
$dropTargetChild.on('dragleave', this.dragLeave);
$dropTargetChild.on('drop', this.drop);

$('#filePicker').on('change', this.onChange_filePicker);
});
}

Expand All @@ -90,11 +92,6 @@ module TodoTxtJs.View
this._resetImportData();
}

public onClick_PickFile()
{

}

public onClick_Import()
{
if (this.replaceImport())
Expand All @@ -107,6 +104,16 @@ module TodoTxtJs.View
this._dialog.dialog("close");
}

public onChange_filePicker = (event): boolean =>
{
if (event.target.files.length > 0)
{
var file = event.target.files[0];
this._readFile(file);
}
return false;
};

private _resetImportData()
{
this._enableImportButton(false);
Expand Down Expand Up @@ -148,17 +155,22 @@ module TodoTxtJs.View
if (files.length > 0)
{
var file = files[0];
var reader = new FileReader();
this._readFile(file);
}
};

reader.onloadend = (event): void =>
{
this._importData = (<any>event.target).result.split(/\r?\n/);
this.importDetails("Ready to import " + this._importData.length + " entries.");
this._enableImportButton();
};
private _readFile = (file) =>
{
var reader = new FileReader();

reader.readAsText(file, 'UTF-8');
}
reader.onloadend = (event): void =>
{
this._importData = (<any>event.target).result.split(/\r?\n/);
this.importDetails("Ready to import " + this._importData.length + " entries.");
this._enableImportButton();
};

reader.readAsText(file, 'UTF-8');
};

private _enableImportButton(enable:boolean = true)
Expand Down
2 changes: 1 addition & 1 deletion WebApp/src/todotxt.html
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ <h1>Display</h1>
</div>
<div class="fileAlternative">or</div>
<div class="filePicker">
<label><input type="text" readonly></label><button data-bind="click: onClick_PickFile">Pick File</button>
<label><input id="filePicker" type="file" /></label>
</div>
<div class="importDetails" data-bind="text: importDetails">

Expand Down

0 comments on commit 5e64499

Please sign in to comment.