We don't need an entire method for a set of code we only use once
This commit is contained in:
parent
56397d7ba2
commit
9e6e9686e6
2
LICENSE
2
LICENSE
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.3.2 - 2014-01-14
|
* 4chan X - Version 1.3.2 - 2014-01-15
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.3.2 - 2014-01-14
|
* 4chan X - Version 1.3.2 - 2014-01-15
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||||
@ -805,16 +805,6 @@
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
$.remove = function(arr, value) {
|
|
||||||
var i;
|
|
||||||
i = arr.indexOf(value);
|
|
||||||
if (i === -1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
arr.splice(i, 1);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
$$ = function(selector, root) {
|
$$ = function(selector, root) {
|
||||||
if (root == null) {
|
if (root == null) {
|
||||||
root = d.body;
|
root = d.body;
|
||||||
@ -1624,9 +1614,13 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
SimpleDict.prototype.rm = function(key) {
|
SimpleDict.prototype.rm = function(key) {
|
||||||
|
var i;
|
||||||
key = "" + key;
|
key = "" + key;
|
||||||
if ($.remove(this.keys, key)) {
|
if ((i = this.keys.indexOf(key)) !== -1) {
|
||||||
return delete this[key];
|
this.keys.splice(i, 1);
|
||||||
|
if ($.remove(this.keys, key)) {
|
||||||
|
return delete this[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript
|
// Generated by CoffeeScript
|
||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.3.2 - 2014-01-14
|
* 4chan X - Version 1.3.2 - 2014-01-15
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||||
@ -810,16 +810,6 @@
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
$.remove = function(arr, value) {
|
|
||||||
var i;
|
|
||||||
i = arr.indexOf(value);
|
|
||||||
if (i === -1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
arr.splice(i, 1);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
$$ = function(selector, root) {
|
$$ = function(selector, root) {
|
||||||
if (root == null) {
|
if (root == null) {
|
||||||
root = d.body;
|
root = d.body;
|
||||||
@ -1630,9 +1620,13 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
SimpleDict.prototype.rm = function(key) {
|
SimpleDict.prototype.rm = function(key) {
|
||||||
|
var i;
|
||||||
key = "" + key;
|
key = "" + key;
|
||||||
if ($.remove(this.keys, key)) {
|
if ((i = this.keys.indexOf(key)) !== -1) {
|
||||||
return delete this[key];
|
this.keys.splice(i, 1);
|
||||||
|
if ($.remove(this.keys, key)) {
|
||||||
|
return delete this[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -404,11 +404,5 @@ $.set = do ->
|
|||||||
return
|
return
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
$.remove = (arr, value) ->
|
|
||||||
i = arr.indexOf value
|
|
||||||
return false if i is -1
|
|
||||||
arr.splice i, 1
|
|
||||||
true
|
|
||||||
|
|
||||||
$$ = (selector, root=d.body) ->
|
$$ = (selector, root=d.body) ->
|
||||||
[root.querySelectorAll(selector)...]
|
[root.querySelectorAll(selector)...]
|
||||||
|
|||||||
@ -9,6 +9,8 @@ class SimpleDict
|
|||||||
|
|
||||||
rm: (key) ->
|
rm: (key) ->
|
||||||
key = "#{key}"
|
key = "#{key}"
|
||||||
delete @[key] if $.remove @keys, key
|
if (i = @keys.indexOf key) isnt -1
|
||||||
|
@keys.splice i, 1
|
||||||
|
delete @[key] if $.remove @keys, key
|
||||||
|
|
||||||
forEach: (fn) -> fn @[key] for key in [@keys...]
|
forEach: (fn) -> fn @[key] for key in [@keys...]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user