Filename | /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/Plugin.pm |
Statements | Executed 365 statements in 1.48ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
14 | 3 | 3 | 352µs | 2.55ms | init (recurses: max depth 2, inclusive time 1.17ms) | Foswiki::Plugins::JQueryPlugin::Plugin::
11 | 11 | 11 | 251µs | 251µs | new | Foswiki::Plugins::JQueryPlugin::Plugin::
12 | 1 | 1 | 46µs | 46µs | renderJS | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 13µs | 46µs | BEGIN@9 | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 11µs | 11µs | BEGIN@4 | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 9µs | 14µs | BEGIN@8 | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 8µs | 21µs | BEGIN@7 | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 7µs | 7µs | renderCSS | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 3µs | 3µs | BEGIN@5 | Foswiki::Plugins::JQueryPlugin::Plugin::
0 | 0 | 0 | 0s | 0s | getSummary | Foswiki::Plugins::JQueryPlugin::Plugin::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki::Plugins::JQueryPlugin::Plugin; | ||||
3 | |||||
4 | 2 | 25µs | 1 | 11µs | # spent 11µs within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@4 which was called:
# once (11µs+0s) by Foswiki::Contrib::JEditableContrib::JEDITABLE::BEGIN@10 at line 4 # spent 11µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@4 |
5 | 2 | 26µs | 1 | 3µs | # spent 3µs within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@5 which was called:
# once (3µs+0s) by Foswiki::Contrib::JEditableContrib::JEDITABLE::BEGIN@10 at line 5 # spent 3µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@5 |
6 | |||||
7 | 2 | 25µs | 2 | 34µs | # spent 21µs (8+13) within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@7 which was called:
# once (8µs+13µs) by Foswiki::Contrib::JEditableContrib::JEDITABLE::BEGIN@10 at line 7 # spent 21µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@7
# spent 13µs making 1 call to strict::import |
8 | 2 | 26µs | 2 | 18µs | # spent 14µs (9+4) within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@8 which was called:
# once (9µs+4µs) by Foswiki::Contrib::JEditableContrib::JEDITABLE::BEGIN@10 at line 8 # spent 14µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@8
# spent 4µs making 1 call to warnings::import |
9 | 2 | 705µs | 2 | 80µs | # spent 46µs (13+33) within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@9 which was called:
# once (13µs+33µs) by Foswiki::Contrib::JEditableContrib::JEDITABLE::BEGIN@10 at line 9 # spent 46µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@9
# spent 33µs making 1 call to constant::import |
10 | |||||
11 | =begin TML | ||||
12 | |||||
13 | ---+ package Foswiki::Plugins::JQueryPlugin::Plugin | ||||
14 | |||||
15 | abstract class for a jQuery plugin | ||||
16 | |||||
17 | =cut | ||||
18 | |||||
19 | =begin TML | ||||
20 | |||||
21 | ---++ ClassMethod new( $class, ... ) | ||||
22 | |||||
23 | * =$class=: Plugin class | ||||
24 | * =...=: additional properties to be added to the object. i.e. | ||||
25 | * =author => 'pluginAuthor'= (default unknown) | ||||
26 | * =debug => 0 or 1= (default =$Foswiki::cfg{JQueryPlugin}{Debug}=) | ||||
27 | * =dependencies => []= | ||||
28 | * =documentation => 'pluginDocumentation'= (default JQuery<Name>) | ||||
29 | * =homepage => 'pluginHomepage'= (default unknown) | ||||
30 | * =javascript => [] | ||||
31 | * =name => 'pluginName'= (default unknown) | ||||
32 | * =puburl= => 'pubUrl'= (default =%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/plugins/pluginname=) | ||||
33 | * =summary => 'pluginSummary'= (default undefined) | ||||
34 | * =tags= => [] | ||||
35 | * =version => 'pluginVersion'= (default unknown) | ||||
36 | |||||
37 | =cut | ||||
38 | |||||
39 | # spent 251µs within Foswiki::Plugins::JQueryPlugin::Plugin::new which was called 11 times, avg 23µs/call:
# once (35µs+0s) by Foswiki::Plugins::SubscribePlugin::JQuery::new at line 14 of /var/www/foswikidev/core/lib/Foswiki/Plugins/SubscribePlugin/JQuery.pm
# once (31µs+0s) by Foswiki::Plugins::CommentPlugin::JQuery::new at line 15 of /var/www/foswikidev/core/lib/Foswiki/Plugins/CommentPlugin/JQuery.pm
# once (26µs+0s) by Foswiki::Contrib::JEditableContrib::JEDITABLE::new at line 18 of /var/www/foswikidev/core/lib/Foswiki/Contrib/JEditableContrib/JEDITABLE.pm
# once (25µs+0s) by Foswiki::Plugins::JQueryPlugin::RENDER::new at line 14 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/RENDER.pm
# once (22µs+0s) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::new at line 29 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm
# once (20µs+0s) by Foswiki::Plugins::JQueryPlugin::COOKIE::new at line 28 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/COOKIE.pm
# once (20µs+0s) by Foswiki::Plugins::JQueryPlugin::LIVEQUERY::new at line 28 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/LIVEQUERY.pm
# once (19µs+0s) by Foswiki::Plugins::JQueryPlugin::UI::new at line 29 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/UI.pm
# once (18µs+0s) by Foswiki::Plugins::JQueryPlugin::METADATA::new at line 28 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/METADATA.pm
# once (18µs+0s) by Foswiki::Plugins::JQueryPlugin::EASING::new at line 28 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/EASING.pm
# once (17µs+0s) by Foswiki::Plugins::JQueryPlugin::MIGRATE::new at line 28 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/MIGRATE.pm | ||||
40 | 11 | 5µs | my $class = shift; | ||
41 | |||||
42 | # backwards compatibility: the session param is deprecated now | ||||
43 | 11 | 15µs | if ( ref( $_[0] ) =~ /^Foswiki/ ) { | ||
44 | 4 | 19µs | my ( $package, $file, $line ) = caller; | ||
45 | |||||
46 | # emit a deprecation warning | ||||
47 | print STDERR | ||||
48 | "$package constructor called with deprecated session object in $file:$line\n" | ||||
49 | if TRACE; | ||||
50 | 4 | 3µs | shift; # ... it off the args | ||
51 | } | ||||
52 | |||||
53 | 11 | 154µs | my $this = bless( | ||
54 | { | ||||
55 | author => 'unknown', | ||||
56 | css => [], | ||||
57 | debug => $Foswiki::cfg{JQueryPlugin}{Debug} || 0, | ||||
58 | dependencies => [], | ||||
59 | documentation => undef, | ||||
60 | homepage => 'unknown', | ||||
61 | javascript => [], | ||||
62 | name => $class, | ||||
63 | puburl => '', | ||||
64 | summary => undef, | ||||
65 | tags => [], | ||||
66 | version => 'unknown', | ||||
67 | idPrefix => 'JQUERYPLUGIN', | ||||
68 | @_ | ||||
69 | }, | ||||
70 | $class | ||||
71 | ); | ||||
72 | |||||
73 | 11 | 18µs | $this->{documentation} = | ||
74 | $Foswiki::cfg{SystemWebName} . '.JQuery' . ucfirst( $this->{name} ) | ||||
75 | unless defined $this->{documentation}; | ||||
76 | |||||
77 | 11 | 9µs | $this->{documentation} =~ s/:://g; | ||
78 | |||||
79 | 11 | 9µs | unless ( $this->{puburl} ) { | ||
80 | $this->{puburl} = '%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/plugins/' | ||||
81 | . lc( $this->{name} ); | ||||
82 | } | ||||
83 | |||||
84 | 11 | 56µs | return $this; | ||
85 | } | ||||
86 | |||||
87 | =begin TML | ||||
88 | |||||
89 | ---++ ClassMethod init( ) | ||||
90 | |||||
91 | add jQuery plugin to web and make sure all its dependencies | ||||
92 | are fulfilled. | ||||
93 | |||||
94 | =cut | ||||
95 | |||||
96 | # spent 2.55ms (352µs+2.20) within Foswiki::Plugins::JQueryPlugin::Plugin::init which was called 14 times, avg 182µs/call:
# 11 times (255µs+1.75ms) by Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin at line 151 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/Plugins.pm, avg 182µs/call
# 2 times (59µs+492µs) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::init at line 57 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm, avg 276µs/call
# once (38µs+-38µs) by Foswiki::Plugins::JQueryPlugin::UI::init at line 56 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/UI.pm | ||||
97 | 14 | 4µs | my $this = shift; | ||
98 | |||||
99 | 14 | 18µs | return 0 if $this->{isInit}; | ||
100 | 11 | 6µs | $this->{isInit} = 1; | ||
101 | |||||
102 | 11 | 3µs | my $header = ''; | ||
103 | 11 | 2µs | my $footer = ''; | ||
104 | |||||
105 | # load all css | ||||
106 | 11 | 13µs | foreach my $css ( @{ $this->{css} } ) { | ||
107 | 1 | 5µs | 1 | 7µs | $header .= $this->renderCSS($css); # spent 7µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::renderCSS |
108 | } | ||||
109 | |||||
110 | # load all javascript | ||||
111 | 11 | 8µs | foreach my $js ( @{ $this->{javascript} } ) { | ||
112 | 12 | 47µs | 12 | 46µs | $footer .= $this->renderJS($js); # spent 46µs making 12 calls to Foswiki::Plugins::JQueryPlugin::Plugin::renderJS, avg 4µs/call |
113 | } | ||||
114 | |||||
115 | # gather dependencies | ||||
116 | 11 | 10µs | my @dependencies = | ||
117 | ('JQUERYPLUGIN::FOSWIKI'); # jquery.foswiki is in there by default | ||||
118 | 11 | 9µs | foreach my $dep ( @{ $this->{dependencies} } ) { | ||
119 | 8 | 38µs | if ( $dep =~ /^($this->{idPrefix}|JQUERYPLUGIN|JavascriptFiles)/ ) | ||
120 | { # SMELL: there are some jquery modules that depend on non-jquery code | ||||
121 | push @dependencies, $dep; | ||||
122 | } | ||||
123 | else { | ||||
124 | 6 | 10µs | 6 | 0s | my $plugin = # spent 2.85ms making 6 calls to Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin, avg 475µs/call, recursion: max depth 2, sum of overlapping time 2.85ms |
125 | Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin($dep); | ||||
126 | 6 | 11µs | if ($plugin) { | ||
127 | push @dependencies, | ||||
128 | $plugin->{idPrefix} . '::' . uc( $plugin->{name} ); | ||||
129 | } | ||||
130 | else { | ||||
131 | my $trace = ''; | ||||
132 | |||||
133 | # require Devel::StackTrace; | ||||
134 | # $trace = Devel::StackTrace->new()->as_string()."\n"; | ||||
135 | |||||
136 | print STDERR "ERROR: can't load plugin for $dep\n" . $trace; | ||||
137 | } | ||||
138 | } | ||||
139 | } | ||||
140 | |||||
141 | 11 | 28µs | 11 | 204µs | Foswiki::Func::addToZone( 'head', # spent 204µs making 11 calls to Foswiki::Func::addToZone, avg 19µs/call |
142 | $this->{idPrefix} . '::' . uc( $this->{name} ), | ||||
143 | $header, join( ', ', @dependencies ) ); | ||||
144 | 11 | 25µs | 11 | 252µs | Foswiki::Func::addToZone( 'script', # spent 252µs making 11 calls to Foswiki::Func::addToZone, avg 23µs/call |
145 | $this->{idPrefix} . '::' . uc( $this->{name} ), | ||||
146 | $footer, join( ', ', @dependencies ) ); | ||||
147 | |||||
148 | 11 | 8µs | my $contextID = $this->{name} . 'Enabled'; | ||
149 | 11 | 6µs | $contextID =~ s/\W//g; | ||
150 | 11 | 24µs | 11 | 15µs | Foswiki::Func::getContext()->{$contextID} = 1; # spent 15µs making 11 calls to Foswiki::Func::getContext, avg 1µs/call |
151 | |||||
152 | 11 | 33µs | return 1; | ||
153 | } | ||||
154 | |||||
155 | # spent 7µs within Foswiki::Plugins::JQueryPlugin::Plugin::renderCSS which was called:
# once (7µs+0s) by Foswiki::Plugins::JQueryPlugin::Plugin::init at line 107 | ||||
156 | 1 | 1µs | my ( $this, $text ) = @_; | ||
157 | |||||
158 | 1 | 900ns | $text =~ s/\.css$/.uncompressed.css/ | ||
159 | if $this->{debug} && $text !~ /(\.uncompressed|_src)\./; | ||||
160 | 1 | 1µs | $text .= '?version=' . $this->{version}; | ||
161 | 1 | 2µs | $text = | ||
162 | "<link rel='stylesheet' href='$this->{puburl}/$text' type='text/css' media='all' />\n"; | ||||
163 | |||||
164 | 1 | 4µs | return $text; | ||
165 | } | ||||
166 | |||||
167 | # spent 46µs within Foswiki::Plugins::JQueryPlugin::Plugin::renderJS which was called 12 times, avg 4µs/call:
# 12 times (46µs+0s) by Foswiki::Plugins::JQueryPlugin::Plugin::init at line 112, avg 4µs/call | ||||
168 | 12 | 8µs | my ( $this, $text ) = @_; | ||
169 | |||||
170 | 12 | 4µs | $text =~ s/\.js$/.uncompressed.js/ | ||
171 | if $this->{debug} && $text !~ /(\.uncompressed|_src)\./; | ||||
172 | 12 | 7µs | $text .= '?version=' . $this->{version}; | ||
173 | 12 | 11µs | $text = | ||
174 | "<script type='text/javascript' src='$this->{puburl}/$text'></script>\n"; | ||||
175 | |||||
176 | 12 | 33µs | return $text; | ||
177 | } | ||||
178 | |||||
179 | =begin TML | ||||
180 | |||||
181 | ---++ ClassMethod getSummary() | ||||
182 | |||||
183 | returns the summary text for this plugin. this is either the =summary= property of the class or the | ||||
184 | =summary= section of the plugin's documentation topic. | ||||
185 | |||||
186 | =cut | ||||
187 | |||||
188 | sub getSummary { | ||||
189 | my $this = shift; | ||||
190 | |||||
191 | my $summary = $this->{summary}; | ||||
192 | |||||
193 | unless ( defined $summary ) { | ||||
194 | $summary = 'n/a'; | ||||
195 | if ( $this->{'documentation'} ) { | ||||
196 | $summary = | ||||
197 | Foswiki::Func::expandCommonVariables( '%INCLUDE{"' | ||||
198 | . $this->{documentation} | ||||
199 | . '" section="summary" warn="off"}%' ); | ||||
200 | } | ||||
201 | |||||
202 | $this->{summary} = $summary; | ||||
203 | } | ||||
204 | |||||
205 | return $summary; | ||||
206 | } | ||||
207 | |||||
208 | 1 | 2µs | 1; | ||
209 | __END__ |