2150 |
mathias |
1 |
if(!dojo._hasResource["dojox.dtl.filter.integers"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
|
|
2 |
dojo._hasResource["dojox.dtl.filter.integers"] = true;
|
|
|
3 |
dojo.provide("dojox.dtl.filter.integers");
|
|
|
4 |
|
|
|
5 |
dojo.mixin(dojox.dtl.filter.integers, {
|
|
|
6 |
add: function(value, arg){
|
|
|
7 |
value = parseInt(value);
|
|
|
8 |
arg = parseInt(arg);
|
|
|
9 |
return isNaN(arg) ? value : value + arg;
|
|
|
10 |
},
|
|
|
11 |
get_digit: function(value, arg){
|
|
|
12 |
// summary:
|
|
|
13 |
// Given a whole number, returns the 1-based requested digit of it
|
|
|
14 |
// desciprtion:
|
|
|
15 |
// 1 is the right-most digit, 2 is the second-right-most digit, etc. Returns the
|
|
|
16 |
// original value for invalid input (if input or argument is not an integer,
|
|
|
17 |
// or if argument is less than 1). Otherwise, output is always an integer.
|
|
|
18 |
value = parseInt(value);
|
|
|
19 |
arg = parseInt(arg) - 1;
|
|
|
20 |
if(arg >= 0){
|
|
|
21 |
value += "";
|
|
|
22 |
if(arg < value.length){
|
|
|
23 |
value = parseInt(value.charAt(arg));
|
|
|
24 |
}else{
|
|
|
25 |
value = 0;
|
|
|
26 |
}
|
|
|
27 |
}
|
|
|
28 |
return (isNaN(value) ? 0 : value);
|
|
|
29 |
}
|
|
|
30 |
});
|
|
|
31 |
|
|
|
32 |
}
|