Display a link in case of duplicate image error. Should display a message in case of connection error.

This commit is contained in:
Nicolas Stepien 2012-01-24 16:23:06 +01:00
parent df14650cc6
commit c9b7c0f15c
2 changed files with 27 additions and 12 deletions

View File

@ -1243,8 +1243,11 @@
return d.activeElement.blur();
}
},
error: function(err) {
$('.error', qr.el).textContent = err;
error: function(err, node) {
var el;
el = $('.error', qr.el);
el.textContent = err;
if (node) $.replace(el.firstChild, node);
qr.open();
if (d.hidden || d.oHidden || d.mozHidden || d.webkitHidden) {
return alert(err);
@ -1611,15 +1614,20 @@
return qr.message.send(post);
},
response: function(html) {
var b, persona, reply, sage;
var b, err, node, persona, reply, sage;
qr.status();
b = $('td b', $.el('a', {
if (!(b = $('td b', $.el('a', {
innerHTML: html
}));
if (b.childElementCount) {
qr.error(b.firstChild.data);
})))) {
err = 'Connection error with sys.4chan.org.';
} else if (b.childElementCount) {
if (b.firstChild.tagName) node = b.firstChild;
err = b.firstChild.textContent;
log(b);
console.dir(b);
}
if (err) {
qr.error(err, node);
return;
}
reply = qr.replies[0];

View File

@ -900,8 +900,10 @@ qr =
$.removeClass qr.el, 'autohide'
d.activeElement.blur()
error: (err) ->
$('.error', qr.el).textContent = err
error: (err, node) ->
el = $('.error', qr.el)
el.textContent = err
$.replace el.firstChild, node if node
qr.open()
alert err if d.hidden or d.oHidden or d.mozHidden or d.webkitHidden
cleanError: ->
@ -1228,12 +1230,17 @@ qr =
response: (html) ->
qr.status()
b = $ 'td b', $.el('a', innerHTML: html)
if b.childElementCount # error!
qr.error b.firstChild.data
unless b = $ 'td b', $.el('a', innerHTML: html)
err = 'Connection error with sys.4chan.org.'
else if b.childElementCount # error!
node = b.firstChild if b.firstChild.tagName # duplicate image link
err = b.firstChild.textContent
log b
console.dir b
# error handling
if err
qr.error err, node
return
reply = qr.replies[0]