~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to local/in/dhis-web-ga/javascript/ie5.js

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// +----------------------------------------------------------------+
 
2
// | Array functions that are missing in IE 5.0                     |
 
3
// | Author: Cezary Tomczak [www.gosu.pl]                           |
 
4
// | Free for any use as long as all copyright messages are intact. |
 
5
// +----------------------------------------------------------------+
 
6
 
 
7
// Removes the last element from an array and returns that element.
 
8
if (!Array.prototype.pop) {
 
9
    Array.prototype.pop = function() {
 
10
        var last;
 
11
        if (this.length) {
 
12
            last = this[this.length - 1];
 
13
            this.length -= 1;
 
14
        }
 
15
        return last;
 
16
    };
 
17
}
 
18
 
 
19
// Adds one or more elements to the end of an array and returns the new length of the array.
 
20
if (!Array.prototype.push) {
 
21
    Array.prototype.push = function() {
 
22
        for (var i = 0; i < arguments.length; ++i) {
 
23
            this[this.length] = arguments[i];
 
24
        }
 
25
        return this.length;
 
26
    };
 
27
}
 
28
 
 
29
// Removes the first element from an array and returns that element.
 
30
if (!Array.prototype.shift) {
 
31
    Array.prototype.shift = function() {
 
32
        var first;
 
33
        if (this.length) {
 
34
            first = this[0];
 
35
            for (var i = 0; i < this.length - 1; ++i) {
 
36
                this[i] = this[i + 1];
 
37
            }
 
38
            this.length -= 1;
 
39
        }
 
40
        return first;
 
41
    };
 
42
}
 
43
 
 
44
// Adds one or more elements to the front of an array and returns the new length of the array.
 
45
if (!Array.prototype.unshift) {
 
46
    Array.prototype.unshift = function() {
 
47
        if (arguments.length) {
 
48
            var i, len = arguments.length;
 
49
            for (i = this.length + len - 1; i >= len; --i) {
 
50
                this[i] = this[i - len];
 
51
            }
 
52
            for (i = 0; i < len; ++i) {
 
53
                this[i] = arguments[i];
 
54
            }
 
55
        }
 
56
        return this.length;
 
57
    };
 
58
}
 
59
 
 
60
// Adds and/or removes elements from an array.
 
61
if (!Array.prototype.splice) {
 
62
    Array.prototype.splice = function(index, howMany) {
 
63
        var elements = [], removed = [], i;
 
64
        for (i = 2; i < arguments.length; ++i) {
 
65
            elements.push(arguments[i]);
 
66
        }
 
67
        for (i = index; (i < index + howMany) && (i < this.length); ++i) {
 
68
            removed.push(this[i]);
 
69
        }
 
70
        for (i = index + howMany; i < this.length; ++i) {
 
71
            this[i - howMany] = this[i];
 
72
        }
 
73
        this.length -= removed.length;
 
74
        for (i = this.length + elements.length - 1; i >= index + elements.length; --i) {
 
75
            this[i] = this[i - elements.length];
 
76
        }
 
77
        for (i = 0; i < elements.length; ++i) {
 
78
            this[index + i] = elements[i];
 
79
        }
 
80
        return removed;
 
81
    };
 
82
}
 
 
b'\\ No newline at end of file'