URL = require './url'

checkFeedURL = (feedUrl) ->
	$.ajax "//widgetic.com/feeds/?v=1.0&q=#{encodeURIComponent(feedUrl)}", dataType: 'jsonp'

class RSS extends URL
	type: 'rss'
	className: 'control-rss'

	_checkURL: =>
		@req = checkFeedURL(@lastURL).done (data) =>
			(data.responseStatus is 200) and @def.resolve() or @def.reject()

		(@def = new $.Deferred).promise()

module.exports = RSS
