-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommon.js
More file actions
46 lines (42 loc) · 935 Bytes
/
common.js
File metadata and controls
46 lines (42 loc) · 935 Bytes
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
/**
* @description Common utils functions for Walnut.
* WALNUT NodeJS MVC framework
*
* Copy right 2011, xukai.ken@gmail.com (XU Kai)
* Date 2011.11.22
*/
global.jCTRender = function (html, data) {
var temp = new jCT(html).Build();
return temp.GetView(data);
}
global.OExtend = function(target, options) {
for (var i in options) {
var copy = options[i];
if (copy instanceof Array) {
target[i] = this.OExtend(target[i], copy);
} else if (copy instanceof Object) {
target[i] = this.OExtend(target[i], copy);
} else {
target[i] = copy;
}
}
return target;
}
global.deleteArrValue = function(arr, value) {
if (arr instanceof Array) {
for(var i=0; i<arr.length; i++) {
var current = arr[i];
if (current == value)
arr.splice(i, 1);
}
}
return arr;
}
global.inArray = function(arr, val) {
var flag = false;
for (var i in arr) {
if (arr[i] == val)
flag = true;
}
return flag;
}