diff options
author | anekos | 2011-05-03 07:04:16 -0700 |
---|---|---|
committer | anekos | 2011-05-03 07:04:16 -0700 |
commit | 41951ab91a0c1072724347e6c1594f669888a7e4 (patch) | |
tree | 6646a62f972a7559367e23583ed36244a7bf0740 | |
parent | ac243eead73c4aa993493e4d254389e9a494c0da (diff) | |
parent | 6974c188200faec5160d63d3fa3684b3116892de (diff) | |
download | vimperator-plugins-41951ab91a0c1072724347e6c1594f669888a7e4.tar.bz2 |
Merge pull request #9 from tyru/detect-ldr-auth.
subscldr.jsでLDRにログインしてなかったらそれとわかるメッセージを出すように
-rw-r--r-- | _libly.js | 11 | ||||
-rw-r--r-- | subscldr.js | 8 |
2 files changed, 17 insertions, 2 deletions
@@ -544,7 +544,14 @@ libly.Request.prototype = { this.transport = new XMLHttpRequest(); this.transport.open(method, this.url, this.options.asynchronous, this.options.username, this.options.password); - this.transport.onreadystatechange = libly.$U.bind(this, this._onStateChange); + var stateChangeException; + this.transport.onreadystatechange = libly.$U.bind(this, function () { + try { + this._onStateChange(); + } catch (e) { + stateChangeException = e; + } + }); this.setRequestHeaders(); this.transport.overrideMimeType('text/html; charset=' + this.options.encoding); @@ -552,6 +559,8 @@ libly.Request.prototype = { this.transport.send(this.body); + if (!this.options.asynchronous && stateChangeException) throw stateChangeException; + // Force Firefox to handle ready state 4 for synchronous requests if (!this.options.asynchronous && this.transport.overrideMimeType) this._onStateChange(); diff --git a/subscldr.js b/subscldr.js index 2c2805c..7d8bfad 100644 --- a/subscldr.js +++ b/subscldr.js @@ -131,6 +131,7 @@ liberator.plugins.subscldr = (function() { req.addEventListener("onSuccess", function(res) { liberator.log(res.responseText); res.getHTMLDocument(); + if (isLoginForm(res.doc)) throw "Please login to LDR to subscribe the feed."; subscribeInfo = getSubscribeInfo(res.doc); liberator.log(subscribeInfo.toSource()); }); @@ -191,6 +192,11 @@ liberator.plugins.subscldr = (function() { } + function isLoginForm(htmldoc) { + return htmldoc.getElementById('livedoor_id') && + htmldoc.getElementById('password'); + } + function getSubscribeInfo(htmldoc) { var subscribeInfo = { target_url: null, @@ -220,7 +226,7 @@ liberator.plugins.subscldr = (function() { function selectFeed(links, next) { liberator.log(links.toSource()); - liberator.echo("Following feeds were found on this site. Which are you subscribe?"); + liberator.echo("Following feeds were found on this site. Which do you subscribe?"); commandline.input("Select or input feed URL ", function(selected) { liberator.echo("You select " + selected + "."); commandline.close(); |