-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjplus.js
executable file
·65 lines (53 loc) · 1.67 KB
/
jplus.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<%= include '../HEADER' %>
var JPlus = {
Version: '<%= JPLUS_VERSION %>',
emptyFunction: function() { },
K: function(x) {return x}
}
function $defined(obj){
return (obj != undefined);
};
function $splat(obj){
var type = $type(obj);
return (type) ? ((type != 'array' && type != 'arguments') ? [obj] : obj) : [];
};
function $type(obj){
if (obj == undefined) return false;
if (obj.nodeName){
switch (obj.nodeType){
case 1: return 'element';
case 3: return (/\S/).test(obj.nodeValue) ? 'textnode' : 'whitespace';
}
} else if (typeof obj.length == 'number'){
if (obj.callee) return 'arguments';
else if (obj.item) return 'collection';
}
if (Object.isArray(obj)) return 'array';
if (Object.isString(obj)) return 'string';
if (Object.isFunction(obj)) return 'function';
if (Object.isNumber(obj)) return 'number';
if (Object.isHash(obj)) return 'hash';
if (Object.isDate(obj)) return 'date';
if (Object.isRegExp(obj)) return 'regexp';
return typeof obj;
};
function $pick(){
for (var i = 0, l = arguments.length; i < l; i++){
if ($defined(arguments[i])) return arguments[i];
}
return null;
};
function $try(fn, bind, args){
try {
return fn.apply(bind, $splat(args));
} catch(e){
return false;
}
};
function $random(min, max){
return Math.floor(Math.random() * (max - min + 1) + min);
};
<%= include 'browser.js', 'object.js', 'function.js' %>
<%= include '../class/class.js' %>
<%= include '../native/string.js', '../native/enumerable.js', '../native/array.js', '../native/number.js', '../native/hash.js', '../native/date.js', '../native/range.js' %>
<%= include '../dom/element.js', '../event/event.js', '../dom/element.event.js', '../request/request.js' %>