| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
2
|
|
|
2
|
|
51572
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
121
|
|
|
2
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
111
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Plack::Middleware::Debug::Ajax; |
|
5
|
|
|
|
|
|
|
{ |
|
6
|
|
|
|
|
|
|
$Plack::Middleware::Debug::Ajax::VERSION = '0.02'; |
|
7
|
|
|
|
|
|
|
} |
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1799
|
use parent 'Plack::Middleware::Debug::Base'; |
|
|
2
|
|
|
|
|
673
|
|
|
|
2
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
85439
|
use Plack::Util::Accessor qw(log_limit); |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
25
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Plack::Middleware::Debug::Ajax - Show log of ajax requests/responses |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
version 0.02 |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
To activate this panel: |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
builder { |
|
26
|
|
|
|
|
|
|
enable 'Debug', panels => |
|
27
|
|
|
|
|
|
|
[ |
|
28
|
|
|
|
|
|
|
qw(Parameters Memory), |
|
29
|
|
|
|
|
|
|
[ 'Ajax', |
|
30
|
|
|
|
|
|
|
log_limit => 100, |
|
31
|
|
|
|
|
|
|
] |
|
32
|
|
|
|
|
|
|
]; |
|
33
|
|
|
|
|
|
|
$app; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
If you're using Dancer, you can enable the panel via your config.yml: |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
plack_middlewares: |
|
39
|
|
|
|
|
|
|
- |
|
40
|
|
|
|
|
|
|
- Debug |
|
41
|
|
|
|
|
|
|
- panels |
|
42
|
|
|
|
|
|
|
- |
|
43
|
|
|
|
|
|
|
- Parameters |
|
44
|
|
|
|
|
|
|
- Memory |
|
45
|
|
|
|
|
|
|
- Ajax |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Adds a debug panel that logs ajax requests and responses through jQuery, as |
|
51
|
|
|
|
|
|
|
they happen. Only ajax requests that go through jQuery are logged, because the |
|
52
|
|
|
|
|
|
|
logging relies on jQuery's global event handlers. If you make an ajax call with |
|
53
|
|
|
|
|
|
|
global set to false, the event won't be logged: |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$.ajax({ |
|
56
|
|
|
|
|
|
|
// ... |
|
57
|
|
|
|
|
|
|
global: false, |
|
58
|
|
|
|
|
|
|
}); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
You could use this feature to selectively log messages, if you don't make use |
|
61
|
|
|
|
|
|
|
of global ajax event handlers elsewhere. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Note that ajax events are logged as they happen, so responses won't necessarily |
|
64
|
|
|
|
|
|
|
appear directly above their respective requests. Events are shown newest first. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SETTINGS |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=over 4 |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item log_limit |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Limit the number of logged ajax requests and responses to the specified number. |
|
73
|
|
|
|
|
|
|
When the log exceeds this size, the oldest items are deleted to make room for |
|
74
|
|
|
|
|
|
|
new items. The default limit is 50, to avoid hogging memory with large |
|
75
|
|
|
|
|
|
|
responses. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=back |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 STANDALONE DEMO |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
There is a complete standalone demo of the Ajax panel in the source of this |
|
82
|
|
|
|
|
|
|
distribution. To run the demo, download the tarball for this distribution, |
|
83
|
|
|
|
|
|
|
extract it, cd into it, and run: |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$ plackup sample/app.psgi |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Then point your browser to: |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
http://0:5000/ |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
And play around with it. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 JQUERY VERSIONS |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Requires jQuery 1.4 or later for full functionality, and has been tested with |
|
96
|
|
|
|
|
|
|
the following versions: |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=over 4 |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item 1.9.1 |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item 1.8.3 |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item 1.6.4 |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item 1.5.1 |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item 1.4.1 |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=back |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
It mostly works with jQuery 1.1 and greater, and doesn't work at all with |
|
113
|
|
|
|
|
|
|
jQuery 1.0. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 BUGS |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Report any bugs via F. Pull requests welcome on github: |
|
118
|
|
|
|
|
|
|
F |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 AUTHOR |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Vincent Launchbury |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Copyright (C) 2013 Vincent Launchbury |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
|
129
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
L |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub run { |
|
138
|
0
|
|
|
0
|
1
|
|
my ($self, $env, $panel) = @_; |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
## |
|
141
|
|
|
|
|
|
|
## Settings |
|
142
|
|
|
|
|
|
|
## |
|
143
|
|
|
|
|
|
|
|
|
144
|
0
|
|
0
|
|
|
|
my $log_limit = $self->log_limit || 50; |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
## |
|
147
|
|
|
|
|
|
|
## Set titles |
|
148
|
|
|
|
|
|
|
## |
|
149
|
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
$panel->title("Ajax Log"); |
|
151
|
0
|
|
|
|
|
|
$panel->nav_title("Ajax Log"); |
|
152
|
0
|
|
|
|
|
|
$panel->nav_subtitle("Live jQuery logging"); |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
## |
|
156
|
|
|
|
|
|
|
## Table for our panel |
|
157
|
|
|
|
|
|
|
## |
|
158
|
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
|
my $status_table = $self->render_list_pairs( |
|
160
|
|
|
|
|
|
|
[ "Status" => "jQuery not present, or document not yet loaded" ], |
|
161
|
|
|
|
|
|
|
); |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
## |
|
165
|
|
|
|
|
|
|
## Javascript/CSS/HTML |
|
166
|
|
|
|
|
|
|
## |
|
167
|
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
my $id = $panel->dom_id; |
|
169
|
0
|
|
|
|
|
|
$panel->content(<<"EOF"); |
|
170
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
$status_table |
|
353
|
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
EOF |
|
365
|
|
|
|
|
|
|
} |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
1; |