export class FileImportHelper { static importCriteria ( elementId , reader , isUploadListenerNotAdded ) { let uploadElm = document . getElementById ( elementId ) ; if ( isUploadListenerNotAdded ) { uploadElm . addEventListener ( 'change' , ( event ) => FileImportHelper . fileUpload ( event , reader ) , false ) ; } uploadElm [ 'value' ] = '' ; uploadElm . click ( ) ; } static fileUpload ( event , reader ) { let file = event . target . files [ 0 ] ; reader . readAsText ( file ) ; } static getFile ( elementId ) { return ( < HTMLInputElement > document . getElementById ( elementId ) ) . files [ 0 ] ; } static isTextFile ( file ) { return file . type === 'text/plain' || file . type === 'text/tab-separated-values' || file . type === 'text/csv' || ( file . type === '' && file . name . split ( '.' ) . pop ( ) !== 'json' ) ; } static isJsonFile ( file ) { return file . type === 'application/json' || file . name . split ( '.' ) . pop ( ) === 'json' ; } }