line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::CallJS; |
2
|
3
|
|
|
3
|
|
45783
|
use 5.008005; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
105
|
|
3
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
100
|
|
4
|
3
|
|
|
3
|
|
51
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
160
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
2426
|
use parent qw(Exporter); |
|
3
|
|
|
|
|
885
|
|
|
3
|
|
|
|
|
15
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
3295
|
use JSON::XS; |
|
3
|
|
|
|
|
25955
|
|
|
3
|
|
|
|
|
671
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT = qw(call_js); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $JSON = JSON::XS->new()->ascii(1)->allow_nonref(); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my %_ESCAPE = ( |
17
|
|
|
|
|
|
|
'+' => '\\u002b', # do not eval as UTF-7 |
18
|
|
|
|
|
|
|
'&' => '\\u0026', |
19
|
|
|
|
|
|
|
'<' => '\\u003c', # do not eval as HTML |
20
|
|
|
|
|
|
|
'>' => '\\u003e', # ditto. |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub call_js { |
24
|
3
|
|
|
3
|
0
|
26
|
my ($func, $data) = @_; |
25
|
|
|
|
|
|
|
|
26
|
3
|
|
|
|
|
53
|
my $json = $JSON->encode($data); |
27
|
3
|
|
|
|
|
22
|
$json =~ s!([&+<>])!$_ESCAPE{$1}!g; |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
26
|
join('', |
30
|
|
|
|
|
|
|
q{} |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
__END__ |