Filename | /var/www/foswiki11/lib/Foswiki/Plugins/JQueryPlugin/Plugin.pm |
Statements | Executed 66 statements in 1.18ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
2 | 2 | 2 | 67µs | 688µs | init (recurses: max depth 1, inclusive time 86µs) | Foswiki::Plugins::JQueryPlugin::Plugin::
2 | 2 | 2 | 53µs | 53µs | new | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 18µs | 86µs | BEGIN@9 | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 14µs | 29µs | BEGIN@7 | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 12µs | 12µs | BEGIN@4 | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 11µs | 18µs | BEGIN@8 | Foswiki::Plugins::JQueryPlugin::Plugin::
2 | 1 | 1 | 11µs | 11µs | renderJS | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 4µs | 4µs | BEGIN@5 | Foswiki::Plugins::JQueryPlugin::Plugin::
0 | 0 | 0 | 0s | 0s | getSummary | Foswiki::Plugins::JQueryPlugin::Plugin::
0 | 0 | 0 | 0s | 0s | renderCSS | 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 | 31µs | 1 | 12µs | # spent 12µs within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@4 which was called:
# once (12µs+0s) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::BEGIN@7 at line 4 # spent 12µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@4 |
5 | 2 | 35µs | 1 | 4µs | # spent 4µs within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@5 which was called:
# once (4µs+0s) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::BEGIN@7 at line 5 # spent 4µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@5 |
6 | |||||
7 | 2 | 31µs | 2 | 45µs | # spent 29µs (14+16) within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@7 which was called:
# once (14µs+16µs) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::BEGIN@7 at line 7 # spent 29µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@7
# spent 16µs making 1 call to strict::import |
8 | 2 | 32µs | 2 | 24µs | # spent 18µs (11+6) within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@8 which was called:
# once (11µs+6µs) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::BEGIN@7 at line 8 # spent 18µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@8
# spent 6µs making 1 call to warnings::import |
9 | 2 | 907µs | 2 | 153µs | # spent 86µs (18+67) within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@9 which was called:
# once (18µs+67µs) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::BEGIN@7 at line 9 # spent 86µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@9
# spent 67µ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 | * =name => 'pluginName'= (default unknown) | ||||
26 | * =author => 'pluginAuthor'= (default unknown) | ||||
27 | * =version => 'pluginVersion'= (default unknown) | ||||
28 | * =summary => 'pluginSummary'= (default undefined) | ||||
29 | * =documentation => 'pluginDocumentation'= (default JQuery<Name>) | ||||
30 | * =homepage => 'pluginHomepage'= (default unknown) | ||||
31 | * =debug => 0 or 1= (default =$Foswiki::cfg{JQueryPlugin}{Debug}=) | ||||
32 | |||||
33 | =cut | ||||
34 | |||||
35 | # spent 53µs within Foswiki::Plugins::JQueryPlugin::Plugin::new which was called 2 times, avg 26µs/call:
# once (29µs+0s) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::new at line 29 of /var/www/foswiki11/lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm
# once (24µs+0s) by Foswiki::Plugins::JQueryPlugin::LIVEQUERY::new at line 28 of /var/www/foswiki11/lib/Foswiki/Plugins/JQueryPlugin/LIVEQUERY.pm | ||||
36 | 2 | 1µs | my $class = shift; | ||
37 | |||||
38 | # backwards compatibility: the session param is deprecated now | ||||
39 | 2 | 1µs | if ( ref( $_[0] ) =~ /^Foswiki/ ) { | ||
40 | my ( $package, $file, $line ) = caller; | ||||
41 | |||||
42 | # emit a deprecation warning | ||||
43 | print STDERR | ||||
44 | "$package constructor called with deprecated session object in $file:$line\n" | ||||
45 | if DEBUG; | ||||
46 | shift; # ... it off the args | ||||
47 | } | ||||
48 | |||||
49 | 2 | 35µs | my $this = bless( | ||
50 | { | ||||
51 | debug => $Foswiki::cfg{JQueryPlugin}{Debug} || 0, | ||||
52 | name => $class, | ||||
53 | author => 'unknown', | ||||
54 | version => 'unknown', | ||||
55 | summary => undef, | ||||
56 | documentation => undef, | ||||
57 | homepage => 'unknown', | ||||
58 | puburl => '', | ||||
59 | css => [], | ||||
60 | javascript => [], | ||||
61 | dependencies => [], | ||||
62 | tags => '', | ||||
63 | @_ | ||||
64 | }, | ||||
65 | $class | ||||
66 | ); | ||||
67 | |||||
68 | 2 | 5µs | $this->{documentation} = | ||
69 | $Foswiki::cfg{SystemWebName} . '.JQuery' . ucfirst( $this->{name} ) | ||||
70 | unless defined $this->{documentation}; | ||||
71 | |||||
72 | 2 | 2µs | $this->{documentation} =~ s/:://g; | ||
73 | |||||
74 | 2 | 3µs | unless ( $this->{puburl} ) { | ||
75 | $this->{puburl} = '%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/plugins/' | ||||
76 | . lc( $this->{name} ); | ||||
77 | } | ||||
78 | |||||
79 | 2 | 13µs | return $this; | ||
80 | } | ||||
81 | |||||
82 | =begin TML | ||||
83 | |||||
84 | ---++ ClassMethod init( ) | ||||
85 | |||||
86 | add jQuery plugin to web and make sure all its dependencies | ||||
87 | are fulfilled. | ||||
88 | |||||
89 | =cut | ||||
90 | |||||
91 | # spent 688µs (67+621) within Foswiki::Plugins::JQueryPlugin::Plugin::init which was called 2 times, avg 344µs/call:
# once (38µs+650µs) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::init at line 57 of /var/www/foswiki11/lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm
# once (30µs+-30µs) by Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin at line 115 of /var/www/foswiki11/lib/Foswiki/Plugins/JQueryPlugin/Plugins.pm | ||||
92 | 2 | 700ns | my $this = shift; | ||
93 | |||||
94 | 2 | 1µs | return 0 if $this->{isInit}; | ||
95 | 2 | 1µs | $this->{isInit} = 1; | ||
96 | |||||
97 | 2 | 800ns | my $header = ''; | ||
98 | 2 | 500ns | my $footer = ''; | ||
99 | |||||
100 | # load all css | ||||
101 | 2 | 3µs | foreach my $css ( @{ $this->{css} } ) { | ||
102 | $header .= $this->renderCSS($css); | ||||
103 | } | ||||
104 | |||||
105 | # load all javascript | ||||
106 | 2 | 1µs | foreach my $js ( @{ $this->{javascript} } ) { | ||
107 | 2 | 10µs | 2 | 11µs | $footer .= $this->renderJS($js); # spent 11µs making 2 calls to Foswiki::Plugins::JQueryPlugin::Plugin::renderJS, avg 6µs/call |
108 | } | ||||
109 | |||||
110 | # gather dependencies | ||||
111 | 2 | 2µs | my @dependencies = | ||
112 | ('JQUERYPLUGIN::FOSWIKI'); # jquery.foswiki is in there by default | ||||
113 | 2 | 2µs | foreach my $dep ( @{ $this->{dependencies} } ) { | ||
114 | 3 | 7µs | if ( $dep =~ /^(JQUERYPLUGIN|JavascriptFiles)/ ) | ||
115 | { # SMELL: there are some jquery modules that depend on non-jquery code | ||||
116 | push @dependencies, $dep; | ||||
117 | } | ||||
118 | else { | ||||
119 | 1 | 4µs | 1 | 0s | Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin($dep); # spent 577µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin, recursion: max depth 1, sum of overlapping time 577µs |
120 | 1 | 2µs | push @dependencies, 'JQUERYPLUGIN::' . uc($dep); | ||
121 | } | ||||
122 | } | ||||
123 | |||||
124 | Foswiki::Func::addToZone( | ||||
125 | 2 | 7µs | 2 | 67µs | 'head', "JQUERYPLUGIN::" . uc( $this->{name} ), # spent 67µs making 2 calls to Foswiki::Func::addToZone, avg 33µs/call |
126 | $header, join( ', ', @dependencies ) | ||||
127 | ); | ||||
128 | 2 | 6µs | 2 | 52µs | Foswiki::Func::addToZone( # spent 52µs making 2 calls to Foswiki::Func::addToZone, avg 26µs/call |
129 | 'script', "JQUERYPLUGIN::" . uc( $this->{name} ), | ||||
130 | $footer, join( ', ', @dependencies ) | ||||
131 | ); | ||||
132 | |||||
133 | 2 | 10µs | return 1; | ||
134 | } | ||||
135 | |||||
136 | sub renderCSS { | ||||
137 | my ( $this, $text ) = @_; | ||||
138 | |||||
139 | $text =~ s/\.css$/.uncompressed.css/ | ||||
140 | if $this->{debug} && $text !~ /(\.uncompressed|_src)\./; | ||||
141 | $text .= '?version=' . $this->{version}; | ||||
142 | $text = | ||||
143 | "<link rel='stylesheet' href='$this->{puburl}/$text' type='text/css' media='all' />\n"; | ||||
144 | |||||
145 | return $text; | ||||
146 | } | ||||
147 | |||||
148 | # spent 11µs within Foswiki::Plugins::JQueryPlugin::Plugin::renderJS which was called 2 times, avg 6µs/call:
# 2 times (11µs+0s) by Foswiki::Plugins::JQueryPlugin::Plugin::init at line 107, avg 6µs/call | ||||
149 | 2 | 2µs | my ( $this, $text ) = @_; | ||
150 | |||||
151 | 2 | 800ns | $text =~ s/\.js$/.uncompressed.js/ | ||
152 | if $this->{debug} && $text !~ /(\.uncompressed|_src)\./; | ||||
153 | 2 | 2µs | $text .= '?version=' . $this->{version}; | ||
154 | 2 | 3µs | $text = | ||
155 | "<script type='text/javascript' src='$this->{puburl}/$text'></script>\n"; | ||||
156 | |||||
157 | 2 | 9µs | return $text; | ||
158 | } | ||||
159 | |||||
160 | =begin TML | ||||
161 | |||||
162 | ---++ ClassMethod getSummary() | ||||
163 | |||||
164 | returns the summary text for this plugin. this is either the =summary= property of the class or the | ||||
165 | =summary= section of the plugin's documentation topic. | ||||
166 | |||||
167 | =cut | ||||
168 | |||||
169 | sub getSummary { | ||||
170 | my $this = shift; | ||||
171 | |||||
172 | my $summary = $this->{summary}; | ||||
173 | |||||
174 | unless ( defined $summary ) { | ||||
175 | $summary = 'n/a'; | ||||
176 | if ( $this->{'documentation'} ) { | ||||
177 | $summary = | ||||
178 | Foswiki::Func::expandCommonVariables( '%INCLUDE{"' | ||||
179 | . $this->{documentation} | ||||
180 | . '" section="summary" warn="off"}%' ); | ||||
181 | } | ||||
182 | |||||
183 | $this->{summary} = $summary; | ||||
184 | } | ||||
185 | |||||
186 | return $summary; | ||||
187 | } | ||||
188 | |||||
189 | 1 | 3µs | 1; | ||
190 | __END__ |