From 610ee5df38b6dc76ef103cb02212df3fbf5b7a9a Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 22 Sep 2012 17:48:00 +0200 Subject: [PATCH] simpler rmClone --- 4chan_x.user.js | 8 +++++--- script.coffee | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a0b6d1bd1..23ef34fec 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -919,10 +919,12 @@ }; Post.prototype.rmClone = function(index) { - var i, _i, _ref; + var clone, _i, _len, _ref; this.clones.splice(index, 1); - for (i = _i = index, _ref = this.clones.length; index <= _ref ? _i < _ref : _i > _ref; i = index <= _ref ? ++_i : --_i) { - this.clones[i].nodes.root.setAttribute('data-clone', i); + _ref = this.clones.slice(index); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + clone = _ref[_i]; + clone.nodes.root.setAttribute('data-clone', index++); } }; diff --git a/script.coffee b/script.coffee index d76499a1b..dbfc0df97 100644 --- a/script.coffee +++ b/script.coffee @@ -718,8 +718,8 @@ class Post new Clone @, context rmClone: (index) -> @clones.splice index, 1 - for i in [index...@clones.length] - @clones[i].nodes.root.setAttribute 'data-clone', i + for clone in @clones[index..] + clone.nodes.root.setAttribute 'data-clone', index++ return class Clone extends Post