-
Notifications
You must be signed in to change notification settings - Fork 0
/
pQuery.js
78 lines (75 loc) · 1.52 KB
/
pQuery.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
66
67
68
69
70
71
72
73
74
75
76
77
var pQuery = {
run: function (string)
{
for (x in string)
{
var object = string[x];
this.parse_object(object, $(object.selector));
}
},
parse_object: function (object, that)
{
if(typeof(object.method) !== 'undefined')
{
for(y in object.method)
{
var methodName = object.method[y];
var selector = $(object.selector);
if(that !== undefined)
{
selector = that;
}
if(object.arguments[y].length > 0)
{
var arguments = [];
for(z in object.arguments[y])
{
var child_object = object.arguments[y][z];
if(child_object.arguments !== undefined && child_object.arguments.length > 0)
{
if(child_object.selector !== undefined)
{
arguments.push(this.parse_object(child_object));
}
else
{
arguments.push(this.parse_object(child_object, selector));
}
}
else if(child_object.selector !== undefined)
{
arguments.push(this.parse_object(child_object, selector));
}
else
{
arguments.push(child_object);
}
}
if(y == (object.method.length - 1))
{
return selector[methodName].apply(selector, arguments);
}
else
{
selector[methodName].apply(selector, arguments);
}
}
else
{
if(y == (object.method.length - 1))
{
return selector[methodName]();
}
else
{
selector[methodName]();
}
}
}
}
else if(typeof(object.selector) !== 'undefined')
{
return $(object.selector);
}
}
}