 	# 	)
 
 
-@App.FeedsView = Ember.View.extend {
+@App.FeedsView = Ember.View.extend
 	classNames: ['inmiddle']
-}
 
 @App.NewFeedView = Ember.View.extend
 	click: ->

@App.FeedsController = Ember.ArrayController.extend
	newFeedUrl: null
	urlPrompt: false
	selectFeed: (feed)->
		@get('content').forEach( (i)->
			i.set('selected', false)

	keyUp: (e)->
		url = @get('controller.newFeedUrl')
		view = @
		if e.keyCode == 13 && !!url && !@get('isProcessing')
			@set('isProcessing', true)
			@$('input').attr('disabled', true)
			$.post( '/v1/feeds', {url: url} ).done (json)=>
				json = JSON.parse(json)
				$.get( 'v1/feeds/' + json.id ).done (json)=>
					@set('isProcessing', false)
					@$('input').attr('disabled', false)
					json = JSON.parse(json)
					items = json.feed.items.map((i)->
						o = Ember.Object.create().setProperties(i)
						o.set('selected', false)
					)
					feed = Ember.Object.create {
						title: json.feed.title
						url: url
						created_at: new Date()
						items: items
						selected: false
					}
					view.get('controller.content').pushObject( feed )
					view.set('controller.urlPrompt', false)
					view.set('controller.newFeedUrl', null)

		# if e.keyCode == 13 && !!url
		# 	@get('controller').newFeed {"url": encodeURIComponent(url)}