diff --git a/4chan_x.user.js b/4chan_x.user.js index 1ca174296..ce72dc978 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -362,7 +362,7 @@ } } else { req = $.ajax(url, { - onload: (function() { + onload: function() { var cb, _i, _len, _ref, _results; _ref = this.callbacks; _results = []; @@ -371,7 +371,10 @@ _results.push(cb.call(this)); } return _results; - }) + }, + onabort: function() { + return delete $.cache.requests[url]; + } }); req.callbacks = [cb]; return $.cache.requests[url] = req; @@ -811,13 +814,13 @@ switch (a.textContent[0]) { case '+': if ((_ref = $('.op .container', thread)) != null) _ref.textContent = ''; - a.textContent = a.textContent.replace('+', 'X Loading...'); + a.textContent = a.textContent.replace('+', '\u00d7 Loading...'); return $.cache(pathname, (function() { return expandThread.parse(this, pathname, thread, a); })); - case 'X': - a.textContent = a.textContent.replace('X Loading...', '+'); - return $.cache[pathname].abort(); + case '\u00d7': + a.textContent = a.textContent.replace('\u00d7 Loading...', '+'); + return $.cache.requests[pathname].abort(); case '-': a.textContent = a.textContent.replace('-', '+'); num = (function() { @@ -855,7 +858,7 @@ $.off(a, 'click', expandThread.cb.toggle); return; } - a.textContent = a.textContent.replace('X Loading...', '-'); + a.textContent = a.textContent.replace('\u00d7 Loading...', '-'); body = $.el('body', { innerHTML: req.responseText }); diff --git a/script.coffee b/script.coffee index 041630193..711571768 100644 --- a/script.coffee +++ b/script.coffee @@ -297,7 +297,9 @@ $.extend $, else req.callbacks.push cb else - req = $.ajax url, onload: (-> cb.call @ for cb in @callbacks) + req = $.ajax url, + onload: -> cb.call @ for cb in @callbacks + onabort: -> delete $.cache.requests[url] req.callbacks = [cb] $.cache.requests[url] = req cb: @@ -681,16 +683,17 @@ expandThread = pathname = "/#{g.BOARD}/res/#{threadID}" a = $ '.omittedposts', thread + # \u00d7 is × + switch a.textContent[0] when '+' $('.op .container', thread)?.textContent = '' - a.textContent = a.textContent.replace '+', 'X Loading...' + a.textContent = a.textContent.replace '+', '\u00d7 Loading...' $.cache pathname, (-> expandThread.parse @, pathname, thread, a) - when 'X' - a.textContent = a.textContent.replace 'X Loading...', '+' - #FIXME this will kill all callbacks - $.cache[pathname].abort() + when '\u00d7' + a.textContent = a.textContent.replace '\u00d7 Loading...', '+' + $.cache.requests[pathname].abort() when '-' a.textContent = a.textContent.replace '-', '+' @@ -712,7 +715,7 @@ expandThread = $.off a, 'click', expandThread.cb.toggle return - a.textContent = a.textContent.replace 'X Loading...', '-' + a.textContent = a.textContent.replace '\u00d7 Loading...', '-' body = $.el 'body', innerHTML: req.responseText