subscribeToFeed: add ajax exception handler
This commit is contained in:
parent
6e63a7c306
commit
55a5137307
98
functions.js
98
functions.js
|
@ -1302,54 +1302,60 @@ function subscribeToFeed() {
|
||||||
onComplete: function(transport) {
|
onComplete: function(transport) {
|
||||||
//dlg_frefresh_callback(transport);
|
//dlg_frefresh_callback(transport);
|
||||||
|
|
||||||
notify('');
|
try {
|
||||||
|
|
||||||
var result = transport.responseXML.getElementsByTagName('result')[0];
|
var result = transport.responseXML.getElementsByTagName('result')[0];
|
||||||
var rc = parseInt(result.getAttribute('code'));
|
var rc = parseInt(result.getAttribute('code'));
|
||||||
|
|
||||||
Form.enable("feed_add_form");
|
Form.enable("feed_add_form");
|
||||||
|
|
||||||
switch (rc) {
|
notify('');
|
||||||
case 1:
|
|
||||||
closeInfoBox();
|
switch (rc) {
|
||||||
notify_info(__("Subscribed to %s").replace("%s", feed_url));
|
case 1:
|
||||||
|
closeInfoBox();
|
||||||
if (inPreferences()) {
|
notify_info(__("Subscribed to %s").replace("%s", feed_url));
|
||||||
updateFeedList();
|
|
||||||
} else {
|
if (inPreferences()) {
|
||||||
setTimeout('updateFeedList(false, false)', 50);
|
updateFeedList();
|
||||||
}
|
} else {
|
||||||
break;
|
setTimeout('updateFeedList(false, false)', 50);
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
alert(__("Can't subscribe to the specified URL."));
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
new Ajax.Request("backend.php", {
|
|
||||||
parameters: 'op=rpc&subop=extractfeedurls&url=' + encodeURIComponent(feed_url),
|
|
||||||
onComplete: function(transport) {
|
|
||||||
var result = transport.responseXML.getElementsByTagName('urls')[0];
|
|
||||||
var feeds = JSON.parse(result.firstChild.nodeValue);
|
|
||||||
var select = document.getElementById("faad_feeds_container_select");
|
|
||||||
|
|
||||||
while (select.hasChildNodes()) {
|
|
||||||
select.removeChild(elem.firstChild);
|
|
||||||
}
|
|
||||||
var count = 0;
|
|
||||||
for (var feedUrl in feeds) {
|
|
||||||
select.insert(new Option(feeds[feedUrl], feedUrl, false));
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
if (count > 5) count = 5;
|
|
||||||
select.size = count;
|
|
||||||
|
|
||||||
Effect.Appear('fadd_feeds_container', {duration : 0.5});
|
|
||||||
}
|
}
|
||||||
});
|
break;
|
||||||
break;
|
case 2:
|
||||||
case 0:
|
case 3:
|
||||||
alert(__("You are already subscribed to this feed."));
|
alert(__("Can't subscribe to the specified URL."));
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
new Ajax.Request("backend.php", {
|
||||||
|
parameters: 'op=rpc&subop=extractfeedurls&url=' + encodeURIComponent(feed_url),
|
||||||
|
onComplete: function(transport) {
|
||||||
|
var result = transport.responseXML.getElementsByTagName('urls')[0];
|
||||||
|
var feeds = JSON.parse(result.firstChild.nodeValue);
|
||||||
|
var select = document.getElementById("faad_feeds_container_select");
|
||||||
|
|
||||||
|
while (select.hasChildNodes()) {
|
||||||
|
select.removeChild(elem.firstChild);
|
||||||
|
}
|
||||||
|
var count = 0;
|
||||||
|
for (var feedUrl in feeds) {
|
||||||
|
select.insert(new Option(feeds[feedUrl], feedUrl, false));
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if (count > 5) count = 5;
|
||||||
|
select.size = count;
|
||||||
|
|
||||||
|
Effect.Appear('fadd_feeds_container', {duration : 0.5});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
alert(__("You are already subscribed to this feed."));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("subscribeToFeed", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
} });
|
} });
|
||||||
|
|
Loading…
Reference in New Issue