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