line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Javascript::Select::Chain::Nested; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
30504
|
use 5.006001; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
46
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use Carp qw/confess/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
68
|
|
8
|
1
|
|
|
1
|
|
1264
|
use Data::Dumper; |
|
1
|
|
|
|
|
10771
|
|
|
1
|
|
|
|
|
69
|
|
9
|
1
|
|
|
1
|
|
720
|
use FileHandle; |
|
1
|
|
|
|
|
12764
|
|
|
1
|
|
|
|
|
8
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require Exporter; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
16
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
17
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# This allows declaration use Javascript::Select::Chain ':all'; |
20
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
21
|
|
|
|
|
|
|
# will save memory. |
22
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
) ], |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } , |
28
|
|
|
|
|
|
|
'selectchain' |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our @EXPORT = qw( |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Preloaded methods go here. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub header { |
42
|
0
|
|
|
0
|
0
|
0
|
my $fh = shift; |
43
|
0
|
|
|
|
|
0
|
print $fh "var hide_empty_list=true;\n\n"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub validate { |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
1
|
0
|
2
|
my $model = shift; |
49
|
|
|
|
|
|
|
|
50
|
1
|
50
|
|
|
|
8
|
exists $model->{listgroupname} or |
51
|
|
|
|
|
|
|
confess "listgroupname must be supplied in model"; |
52
|
|
|
|
|
|
|
|
53
|
1
|
50
|
|
|
|
5
|
exists $model->{data} or |
54
|
|
|
|
|
|
|
confess "data must be supplied in model"; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub add_list_group { |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
1
|
0
|
3
|
my ($fh, $model) = @_; |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
2
|
my $first_list_item = (keys %{$model->{data}[0][0]})[0]; |
|
1
|
|
|
|
|
5
|
|
64
|
1
|
50
|
|
|
|
5
|
$first_list_item = "" unless defined($first_list_item); |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
11
|
print $fh sprintf 'addListGroup("%s", "%s");', |
67
|
|
|
|
|
|
|
$model->{listgroupname}, |
68
|
|
|
|
|
|
|
$first_list_item; |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
3
|
print $fh "\n\n"; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub quoteary { |
74
|
102
|
|
|
102
|
0
|
439
|
my $ary = shift; |
75
|
102
|
|
|
|
|
460
|
my $size = shift; |
76
|
|
|
|
|
|
|
|
77
|
102
|
|
|
|
|
323
|
for my $elt (0..$size-2) { |
78
|
331
|
50
|
|
|
|
1024
|
$ary->[$elt] = "" unless defined($ary->[$elt]); |
79
|
331
|
|
|
|
|
1846
|
$ary->[$elt] = sprintf '"%s"', $ary->[$elt]; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my %quoteary = (addList => 5, addOption => 4); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub addonelist { |
87
|
|
|
|
|
|
|
|
88
|
102
|
|
|
102
|
0
|
1380
|
my ($fh, $ary, $func) = @_; |
89
|
|
|
|
|
|
|
|
90
|
102
|
|
|
|
|
510
|
quoteary($ary, $quoteary{$func}); |
91
|
|
|
|
|
|
|
|
92
|
102
|
|
|
|
|
949
|
print $fh sprintf "$func(%s);\n", join ', ', @$ary; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub addlistary { |
96
|
3
|
|
|
3
|
0
|
7
|
my ($fh, $data, $func) = @_; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
3
|
|
|
|
|
4
|
for my $record (@$data) { |
100
|
21
|
|
|
|
|
208
|
my ($list_name, $list_data) = each %$record; |
101
|
|
|
|
|
|
|
|
102
|
21
|
|
|
|
|
157
|
for my $list_item (@{$list_data}) { |
|
21
|
|
|
|
|
33
|
|
103
|
102
|
|
|
|
|
615
|
addonelist($fh, [ $list_name, @$list_item ], $func); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub addlist { |
110
|
1
|
|
|
1
|
0
|
2
|
my ($fh,$data) = @_; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
4
|
for my $d (0 .. $#$data-1) { |
114
|
2
|
|
|
|
|
7
|
addlistary($fh, $data->[$d], 'addList'); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub addoption { |
120
|
1
|
|
|
1
|
0
|
2
|
my ($fh,$data) = @_; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# warn Dumper($data->[$#$data]); |
124
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
4
|
addlistary($fh, $data->[$#$data], 'addOption'); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub selectchain { |
134
|
1
|
|
|
1
|
1
|
2
|
my ($model, $config) = @_; |
135
|
|
|
|
|
|
|
|
136
|
1
|
|
|
|
|
6
|
validate $model ; |
137
|
|
|
|
|
|
|
|
138
|
1
|
|
50
|
|
|
125
|
my $js = $config->{js} || "_out.js"; |
139
|
1
|
|
|
|
|
12
|
my $jsf = new FileHandle; |
140
|
1
|
50
|
|
|
|
51
|
$jsf->open("> $js") or die $!; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# header($jsf); |
143
|
1
|
|
|
|
|
255
|
add_list_group($jsf, $model); |
144
|
|
|
|
|
|
|
|
145
|
1
|
|
|
|
|
5
|
addlist($jsf, $model->{data}); |
146
|
1
|
|
|
|
|
6
|
addoption($jsf, $model->{data}); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
1; |
151
|
|
|
|
|
|
|
__END__ |