[TemporaryStorage] add files required for SDK build
[samples/web/TemporaryStorage.git] / tizen-web-ui-fw / latest / js / src / util / range.js
1
2 /*
3  * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL licenses
4  * http://phpjs.org/functions/range
5  * original by: Waldo Malqui Silva
6  * version: 1107.2516
7  */
8 function range( low, high, step ) {
9     // Create an array containing the range of integers or characters
10     // from low to high (inclusive)  
11     // 
12     // version: 1107.2516
13     // discuss at: http://phpjs.org/functions/range
14     // +   original by: Waldo Malqui Silva
15     // *     example 1: range ( 0, 12 );
16     // *     returns 1: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
17     // *     example 2: range( 0, 100, 10 );
18     // *     returns 2: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
19     // *     example 3: range( 'a', 'i' );
20     // *     returns 3: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
21     // *     example 4: range( 'c', 'a' );
22     // *     returns 4: ['c', 'b', 'a']
23         var matrix = [],
24                 inival,
25                 endval,
26                 plus,
27                 walker = step || 1,
28                 chars = false;
29
30     if (!isNaN(low) && !isNaN(high)) {
31         inival = low;
32         endval = high;
33     } else if (isNaN(low) && isNaN(high)) {
34         chars = true;
35         inival = low.charCodeAt(0);
36         endval = high.charCodeAt(0);
37     } else {
38         inival = (isNaN(low) ? 0 : low);
39         endval = (isNaN(high) ? 0 : high);
40     }
41
42     plus = ((inival > endval) ? false : true);
43     if (plus) {
44         while (inival <= endval) {
45             matrix.push(((chars) ? String.fromCharCode(inival) : inival));
46             inival += walker;
47         }
48     } else {
49         while (inival >= endval) {
50             matrix.push(((chars) ? String.fromCharCode(inival) : inival));
51             inival -= walker;
52         }
53     }
54
55     return matrix;
56 }
57