Cheats.
Don't do this. Why am I doing it, then? Because indexOf is so slooooooooooooooooooooooooooooooooooooooooooooooooooooooooooow
This commit is contained in:
parent
7b4c794729
commit
b060a9c23e
@ -16,6 +16,7 @@ module.exports = (grunt) ->
|
||||
)
|
||||
coffee:
|
||||
src: [
|
||||
'src/General/Cheats.coffee'
|
||||
'src/General/Config.coffee'
|
||||
'src/General/Globals.coffee'
|
||||
'src/General/lib/*.coffee'
|
||||
|
||||
@ -352,18 +352,6 @@
|
||||
posts: {}
|
||||
};
|
||||
|
||||
Array.prototype.indexOf = function(val) {
|
||||
var i;
|
||||
|
||||
i = this.length;
|
||||
while (i--) {
|
||||
if (this[i] === val) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
};
|
||||
|
||||
$ = function(selector, root) {
|
||||
if (root == null) {
|
||||
root = d.body;
|
||||
@ -833,6 +821,20 @@
|
||||
return __slice.call(root.querySelectorAll(selector));
|
||||
};
|
||||
|
||||
Array.prototype.indexOf = function(val) {
|
||||
var i;
|
||||
|
||||
i = this.length;
|
||||
while (i--) {
|
||||
if (this[i] === val) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
};
|
||||
|
||||
__indexOf = [].indexOf;
|
||||
|
||||
Board = (function() {
|
||||
Board.prototype.toString = function() {
|
||||
return this.ID;
|
||||
|
||||
@ -330,18 +330,6 @@
|
||||
posts: {}
|
||||
};
|
||||
|
||||
Array.prototype.indexOf = function(val) {
|
||||
var i;
|
||||
|
||||
i = this.length;
|
||||
while (i--) {
|
||||
if (this[i] === val) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
};
|
||||
|
||||
$ = function(selector, root) {
|
||||
if (root == null) {
|
||||
root = d.body;
|
||||
@ -840,6 +828,20 @@
|
||||
return __slice.call(root.querySelectorAll(selector));
|
||||
};
|
||||
|
||||
Array.prototype.indexOf = function(val) {
|
||||
var i;
|
||||
|
||||
i = this.length;
|
||||
while (i--) {
|
||||
if (this[i] === val) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
};
|
||||
|
||||
__indexOf = [].indexOf;
|
||||
|
||||
Board = (function() {
|
||||
Board.prototype.toString = function() {
|
||||
return this.ID;
|
||||
|
||||
10
src/General/cheats.coffee
Normal file
10
src/General/cheats.coffee
Normal file
@ -0,0 +1,10 @@
|
||||
# I am bad at JavaScript and if you reuse this, so are you.
|
||||
Array::indexOf = (val) ->
|
||||
i = @length
|
||||
while i--
|
||||
return i if @[i] is val
|
||||
return i
|
||||
|
||||
# Update CoffeeScript's reference to [].indexOf
|
||||
# Reserved keywords are ignored in embedded javascript.
|
||||
`__indexOf = [].indexOf`
|
||||
@ -1,9 +1,3 @@
|
||||
Array::indexOf = (val) ->
|
||||
i = @length
|
||||
while i--
|
||||
return i if @[i] is val
|
||||
return i
|
||||
|
||||
# loosely follows the jquery api:
|
||||
# http://api.jquery.com/
|
||||
# not chainable
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user