Subversion Repositories HomeAutomation

Rev

Rev 1625 | Rev 1646 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
1601 runge 1
 
1644 runge 2
function in_array(array, item)
1601 runge 3
{
1644 runge 4
    for (var n in array)
1604 runge 5
    {
1644 runge 6
        if (array[n] == item)
7
        {
8
            return true;
9
        }
1604 runge 10
    }
1603 runge 11
 
1644 runge 12
    return false;
1603 runge 13
}
14
 
1644 runge 15
function key_in_array(array, key)
1614 runge 16
{
1619 runge 17
    for (var n in array)
1614 runge 18
    {
1644 runge 19
        if (n == key)
1614 runge 20
        {
21
            return true;
22
        }
23
    }
24
 
25
    return false;
26
}
27
 
1603 runge 28
String.prototype.ltrim = function(charlist)
29
{
30
    charlist = !charlist ? ' \s\xA0' : charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1');
31
    var re = new RegExp('^[' + charlist + ']+', 'g');
32
    return this.replace(re, '');
33
}
34
 
35
String.prototype.rtrim = function(charlist)
36
{
37
    charlist = !charlist ? ' \s\xA0' : charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1');
38
    var re = new RegExp('[' + charlist + ']+$', 'g');
39
    return this.replace(re, '');
40
}
41
 
42
String.prototype.trim = function(charlist)
43
{
44
    var str = this.ltrim(charlist);
45
    return str.rtrim(charlist);
46
}