-
Notifications
You must be signed in to change notification settings - Fork 2
/
laravel_class.js
152 lines (123 loc) · 4.81 KB
/
laravel_class.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
var cl = jQuery('title').text().match(/^[^ ]+/);
var desc = "";
var inheritance = "";
var classextends = "";
var inh = {};
var is_trait = false;
var Facades = {
'Illuminate\\Foundation\\Application': 'App',
'Illuminate\\Contracts\\Console\\Kernel': 'Artisan',
'Illuminate\\Auth\\Guard': 'Auth',
'Illuminate\\View\\Compilers\\BladeCompiler': 'Blade',
'Illuminate\\Contracts\\Broadcasting\\Broadcaster': 'Broadcast',
'Illuminate\\Contracts\\Bus\\Dispatcher': 'Bus',
'Illuminate\\Cache\\Repository': 'Cache',
'Illuminate\\Config\\Repository': 'Config',
'Illuminate\\Cookie\\CookieJar': 'Cookie',
'Illuminate\\Encryption\\Encrypter': 'Crypt',
'Illuminate\\Database\\Connection': 'DB',
'Illuminate\\Events\\Dispatcher': 'Event',
'Illuminate\\Filesystem\\Filesystem': 'File',
'Illuminate\\Contracts\\Auth\\Access\\Gate': 'Gate',
'Illuminate\\Contracts\\Hashing\\Hasher': 'Hash',
'Illuminate\\Translation\\Translator': 'Lang',
'Illuminate\\Log\\Logger': 'Log',
'Illuminate\\Mail\\Mailer': 'Mail',
'Illuminate\\Notifications\\ChannelManager': 'Notification',
'Illuminate\\Auth\\Passwords\\PasswordBroker': 'Password',
'Illuminate\\Contracts\\Queue\\Queue': 'Queue',
'Illuminate\\Routing\\Redirector': 'Redirect',
'Illuminate\\Redis\\Connections\\Connection': 'Redis',
'Illuminate\\Http\\Request': 'Request',
'Illuminate\\Http\\Response': 'Response',
'Illuminate\\Routing\\Router': 'Route',
'Illuminate\\Database\\Schema\\Builder': 'Schema',
'Illuminate\\Session\\Store': 'Session',
'Illuminate\\Contracts\\Filesystem\\Filesystem': 'Storage',
'Illuminate\\Routing\\UrlGenerator': 'URL',
'Illuminate\\Validation\\Validator': 'Validator',
'Illuminate\\View\\View': 'View'
};
jQuery('h2:contains("Methods")').next('div').find('div.row div small a abbr').each(function(i) {
var parentclass = jQuery(this).text();
var funcname = jQuery(this).parent().parent().parent().parent().find('div.col-md-8.type a:first').text();
if (typeof inh[parentclass] == 'undefined') {
inh[parentclass] = parentclass + "::";
} else {
inh[parentclass] += ",";
}
inh[parentclass] += funcname + "()";
});
for (var key in inh) {
if (inheritance) {
inheritance += ";";
}
inheritance += inh[key];
}
jQuery('div.page-header').next('p').find('strong').each(function(i) {
var c = "";
try {
c = this.previousSibling.nodeValue.trim();
} catch(e) {}
if(c == 'trait') {
is_trait = true;
}
});
jQuery('div.page-header').next('p').find('a abbr').each(function(i) {
var c = "";
try {
c = this.parentNode.previousSibling.nodeValue.trim();
} catch(e) {}
if(c == 'extends') {
classextends = jQuery(this).attr('title');
}
});
jQuery('h2:contains("Traits")').next('div').find('div.row a abbr').each(function(i) {
var c = jQuery(this).attr('title');
classextends = classextends + "," + c;
});
if (!is_trait) {
WeBuilderAddClass(cl, desc, inheritance, classextends, false);
if (cl in Facades) {
WeBuilderAddClass(Facades[cl], desc, inheritance, classextends, true); //this class has a facade, add it
}
} else {
WeBuilderAddTrait(cl, desc, inheritance, classextends);
}
jQuery('h2:contains("Methods")').next('div').find('div.row').each(function(i) {
var isInherited = (jQuery(this).find('div small a abbr').length > 0);
if (!isInherited) {
var desc = jQuery(this).find('div.col-md-8.type p').text().normalize_spaces();
var funcname = jQuery(this).find('div.col-md-8.type a:first').first().text().trim();
var td = jQuery(this).find('div.col-md-8.type').clone();
td.find('p').remove();
var func = td.text().normalize_spaces();
var fnArgsRegex = /\(.*\)/;
var funcargs = func.match(fnArgsRegex);
var ret_td = jQuery(this).find('div.col-md-2.type').clone();
ret_td.find('a abbr').each(function(i) {
jQuery(this).html(jQuery(this).attr('title'));
});
var funcres = ret_td.text().trim();
var is_static = funcres.startsWith('static');
if (is_static) {
is_static = "1";
}
funcres = funcres.replace(/^static\b/, '').trim();
WeBuilderAddMethod(cl, funcname, funcargs[0], funcres, desc, is_static);
if (cl in Facades) {
WeBuilderAddMethod(Facades[cl], funcname, funcargs[0], funcres, desc, true);
}
}
});
jQuery('h2:contains("Properties")').next('table').find('tr').each(function(i) {
var desc = jQuery(this).find('td.last').text().normalize_spaces();
var fieldname = jQuery(this).find('td.last').prev().text().trim();
var fieldtype = jQuery(this).find('td.type').text().trim();
var is_static = fieldtype.startsWith('static ');
if (is_static) {
is_static = "1";
}
fieldtype = fieldtype.replace(/^static /, '');
WeBuilderAddProperty(cl, fieldname, fieldtype, desc, is_static);
});