From f7f80e4488f07db0fd481aeaaad5b1264962c60e Mon Sep 17 00:00:00 2001 From: tyru Date: Tue, 3 May 2011 15:33:35 +0900 Subject: handle a exception thrown from this.transport.onreadystatechange --- _libly.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/_libly.js b/_libly.js index 4f96654..b62e34a 100644 --- a/_libly.js +++ b/_libly.js @@ -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(); -- cgit v1.2.3 From 1b4d7961dff6d7abca01ded1f395f948917940d8 Mon Sep 17 00:00:00 2001 From: tyru Date: Tue, 3 May 2011 16:52:57 +0900 Subject: show clear message when a user needs to authenticate. --- subscldr.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subscldr.js b/subscldr.js index 2c2805c..83a039c 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, -- cgit v1.2.3 From 6974c188200faec5160d63d3fa3684b3116892de Mon Sep 17 00:00:00 2001 From: tyru Date: Tue, 3 May 2011 16:53:24 +0900 Subject: fix english --- subscldr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subscldr.js b/subscldr.js index 83a039c..7d8bfad 100644 --- a/subscldr.js +++ b/subscldr.js @@ -226,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(); -- cgit v1.2.3