From 090ef475ed227746073c587dd1687c949fcb156c Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 11 Oct 2011 13:50:39 -0700 Subject: [PATCH] forEach again --- 4chan_x.user.js | 27 ++++++++++----------------- script.coffee | 7 +++---- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 42165a93a..919f54ff2 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2957,7 +2957,7 @@ }; Main = { init: function() { - var callback, cutoff, hiddenThreads, id, lastChecked, nodes, now, timestamp, tzOffset, _i, _len, _ref, _ref2; + var cutoff, hiddenThreads, id, lastChecked, nodes, now, timestamp, tzOffset, _ref; $.unbind(document, 'DOMContentLoaded', Main.init); if (location.hostname === 'sys.4chan.org') { QR.sys(); @@ -3087,16 +3087,13 @@ } } nodes = $$('.op, a + table'); - _ref2 = g.callbacks; - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - callback = _ref2[_i]; + g.callbacks.forEach(function(callback) { try { - nodes.forEach(callback); + return nodes.forEach(callback); } catch (err) { - alert(err); - continue; + return alert(err); } - } + }); $.bind($('form[name=delform]'), 'DOMNodeInserted', Main.node); options.init(); if (!$.get('firstrun')) { @@ -3111,22 +3108,18 @@ } }, node: function(e) { - var callback, target, _i, _len, _ref, _results; + var target; target = e.target; if (target.nodeName !== 'TABLE') { return; } - _ref = g.callbacks; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - callback = _ref[_i]; + return g.callbacks.forEach(function(callback) { try { - nodes.forEach(callback); + return nodes.forEach(callback); } catch (err) { - continue; + } - } - return _results; + }); }, css: '\ /* dialog styling */\ diff --git a/script.coffee b/script.coffee index 75af835ef..ec9615d5b 100644 --- a/script.coffee +++ b/script.coffee @@ -2357,12 +2357,11 @@ Main = expandComment.init() nodes = $$ '.op, a + table' - for callback in g.callbacks + g.callbacks.forEach (callback) -> try nodes.forEach callback catch err alert err - continue $.bind $('form[name=delform]'), 'DOMNodeInserted', Main.node options.init() @@ -2377,11 +2376,11 @@ Main = node: (e) -> {target} = e return unless target.nodeName is 'TABLE' - for callback in g.callbacks + g.callbacks.forEach (callback) -> try nodes.forEach callback catch err - continue + #nothing css: ' /* dialog styling */