mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-28 10:08:20 -05:00
Filter files to only plain-text
This commit is contained in:
parent
30abc91a5c
commit
d0b61ed23e
1 changed files with 14 additions and 4 deletions
|
@ -22,18 +22,15 @@ export default Em.Component.extend({
|
||||||
|
|
||||||
$this.on('dragover', function(e) {
|
$this.on('dragover', function(e) {
|
||||||
if (e.preventDefault) e.preventDefault();
|
if (e.preventDefault) e.preventDefault();
|
||||||
//self.set('hover', true);
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$this.on('dragenter', function(e) {
|
$this.on('dragenter', function(e) {
|
||||||
if (e.preventDefault) e.preventDefault();
|
if (e.preventDefault) e.preventDefault();
|
||||||
console.log('dragenter');
|
|
||||||
self.set('hover', self.get('hover') + 1);
|
self.set('hover', self.get('hover') + 1);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$this.on('dragleave', function(e) {
|
$this.on('dragleave', function(e) {
|
||||||
if (e.preventDefault) e.preventDefault();
|
if (e.preventDefault) e.preventDefault();
|
||||||
console.log('dragleave');
|
|
||||||
self.set('hover', self.get('hover') - 1);
|
self.set('hover', self.get('hover') - 1);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@ -78,7 +75,20 @@ export default Em.Component.extend({
|
||||||
|
|
||||||
fileSelected(fileList) {
|
fileSelected(fileList) {
|
||||||
const self = this;
|
const self = this;
|
||||||
const numFiles = fileList.length;
|
let files = [];
|
||||||
|
for (let i = 0; i < fileList.length; i++) {
|
||||||
|
files[i] = fileList[i];
|
||||||
|
}
|
||||||
|
const fileNameRegex = /\.(json|txt)$/;
|
||||||
|
files = files.filter(function(file) {
|
||||||
|
if (fileNameRegex.test(file.name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (file.type === "text/plain") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
const firstFile = fileList[0];
|
const firstFile = fileList[0];
|
||||||
|
|
||||||
this.set('loading', true);
|
this.set('loading', true);
|
||||||
|
|
Loading…
Reference in a new issue