Created
February 5, 2011 03:40
-
-
Save miya2000/812179 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var GOOGLE_READER_PROXY_URL = 'http://www.google.com/reader/atom/feed/' | |
| function feedRequest(href, feedCallback) { | |
| httpRequest(href, callback); | |
| function callback(e) { | |
| if (e.status == '403') { | |
| postError('feed access denied. [' + e.status + '] ' + e.statusText); | |
| if (href.indexOf(GOOGLE_READER_PROXY_URL) != 0) { | |
| var url = GOOGLE_READER_PROXY_URL + encodeURIComponent(href); | |
| postError('retry to Google Reader [' + url + ']'); | |
| feedRequest(url, feedCallback); | |
| return; | |
| } | |
| } | |
| if (e.readyState < 4) { // timeout. | |
| var feedObj = { | |
| title : href, | |
| link : href, | |
| description: NDR.lang.ABORTED_CONNECTION, | |
| items : [], | |
| url : href, | |
| status : 'timeout' | |
| }; | |
| } | |
| else if (e.responseText == "") { | |
| var feedObj = { | |
| title : href, | |
| link : href, | |
| description: NDR.lang.MISSING_DATA, | |
| items : [], | |
| url : href, | |
| status : 'nodata' | |
| }; | |
| } | |
| else if (!/^\s*</.test(e.responseText)) { // deleted mylist. etc. | |
| var feedObj = { | |
| title : href, | |
| link : href, | |
| description: NDR.lang.INVALID_FEED + '\n(' + /\s*(.*)$/m.exec(e.responseText)[0].substring(0, 300) + ')', | |
| items : [], | |
| url : href, | |
| status : 'invalid' | |
| }; | |
| } | |
| else { | |
| var feedObj = parseFeedObjectFromString(e.responseText); | |
| feedObj.url = href; | |
| feedObj.status = 'ok'; | |
| if (!feedObj.link) { | |
| feedObj.link = href; | |
| } | |
| } | |
| feedCallback(feedObj); | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment