 				biomToStore.date = d.getUTCFullYear() + "-" + (d.getUTCMonth() + 1) + "-" + d.getUTCDate() + "T" + d.getUTCHours() + ":" + d.getUTCMinutes() + ":" + d.getUTCSeconds() + " UTC"
 				console.log @
 				if JSON.parse(biomToStore.data).format.indexOf("Biological Observation Matrix") != -1
-					@server.biom.add(biomToStore).done (item) => 
+					@server.biom.add(biomToStore).done (item) =>
 						@currentData = item
 						setTimeout( "window.location.href = 'preview.html'", 2000)
-				else 
+				else
 					alert "Incorrect biom format field! Please check your file content!"
 		reader.readAsBinaryString(file)
 
 	# list 10 most recent files uploaded to this browser
-	listRecentFiles: () => 
+	listRecentFiles: () =>
 		@server.biom.query().all().execute().done (results) =>
 			if results.length > 0
 				for p in [0..results.length-1]

						$('#reload_' + k).click( @reloadRow )
						$('#del_' + k).click( @removeRow )

	# allows users to reload old files 
	reloadRow: (evt) =>
		i = @currentData.length - 1 - evt.currentTarget.id.replace("reload_","") # reverse order id 
		biomToStore = {}
		biomToStore.name = @currentData[i].name
		biomToStore.size = @currentData[i].size
		biomToStore.data = @currentData[i].data
		d = new Date();
		biomToStore.date = d.getUTCFullYear() + "-" + (d.getUTCMonth() + 1) + "-" + d.getUTCDate() + "T" + d.getUTCHours() + ":" + d.getUTCMinutes() + ":" + d.getUTCSeconds() + " UTC"
		@server.biom.add(biomToStore).done (item) -> 
			@currentData = item
			setTimeout( "window.location.href = 'preview.html'", 1000)


	checkFile: (files) ->
		if files.length == 0
			alert "Please select a file!"
		else
			filetype = files[0].name.split("").reverse().join("").split(".")[0].toLowerCase()
			acceptable_filetype = ["moib",  "txt"]
			if acceptable_filetype.indexOf(filetype) == -1
				alert "Please upload .biom or or .txt file!"
			else
				@readBlob(files[0])

	handleFileSelect: (evt) =>
		progress.style.width = '0%'
		reader.onerror = @errorHandler
		reader.onprogress = @updateProgress
		reader.onabort = (e) -> alert "File loading cancelled!"
		reader.onloadstart = (e) -> document.getElementById('progress_bar').className = 'loading'
		reader.onload = (e) ->
			progress.style.width = '100%'
			setTimeout("document.getElementById('progress_bar').className='';", 8000)

	errorHandler: (evt) ->
		switch evt.target.error.code
			when evt.target.error.NOT_FOUND_ERR then alert "File Not Found!"
			when evt.target.error.NOT_READABLE_ERR then alert "File Not Readable!"
			else alert "File Not Readable!"

	updateProgress: (evt) ->
		if evt.lengthComputable
			percentLoaded = Math.round((evt.loaded / evt.total) * 100)
			if percentLoaded < 100
				progress.style.width = percentLoaded + '%'

	dragFileProc: (evt) =>
		evt.stopPropagation()
		evt.preventDefault()
		switch evt.type
