source: extensions/grum_plugins_classes-2/genericjs.js @ 14520

Last change on this file since 14520 was 3395, checked in by grum, 15 years ago

Add plugin Grum Plugins Class-2

  • Property svn:executable set to *
File size: 1.4 KB
Line 
1/* -----------------------------------------------------------------------------
2  file: genricjs.js
3  file version: 1.0
4  date: 2008-01-02
5  ------------------------------------------------------------------------------
6  author: grum at grum.dnsalias.com
7  << May the Little SpaceFrog be with you >>
8  ------------------------------------------------------------------------------
9
10  this classes provides base functions to make easiest a compliant code with
11  FF2.0 & IE7.0
12 
13
14  ------------------------------------------------------------------------------
15  HISTORY VERSION
16             
17   -------------------------------------------------------------------------- */
18
19
20
21/*
22  this is an implementation of the function <indexOf> to the Array class, as
23  defined in the ECMA-262 standard
24  for more information, see at http://developer.mozilla.org/fr/docs/R%C3%A9f%C3%A9rence_de_JavaScript_1.5_Core:Objets_globaux:Array:indexOf
25
26  not implemented in IE 7.0
27*/
28if (!Array.prototype.indexOf)
29{
30  Array.prototype.indexOf = function(elt /*, from*/)
31  {
32    var len = this.length;
33
34    var from = Number(arguments[1]) || 0;
35    from = (from < 0)
36         ? Math.ceil(from)
37         : Math.floor(from);
38    if (from < 0)
39      from += len;
40
41    for (; from < len; from++)
42    {
43      if (from in this &&
44          this[from] === elt)
45        return from;
46    }
47    return -1;
48  };
49}
Note: See TracBrowser for help on using the repository browser.