line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Waft::JS; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
140682
|
use 5.005; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
86
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
82
|
|
5
|
2
|
|
|
2
|
|
10
|
use vars qw( $VERSION ); |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
134
|
|
6
|
2
|
50
|
|
2
|
|
5
|
BEGIN { eval { require warnings } ? 'warnings'->import : ( $^W = 1 ) } |
|
2
|
|
|
|
|
97
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
9
|
use Waft 0.9910 (); |
|
2
|
|
|
|
|
48
|
|
|
2
|
|
|
|
|
1014
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$VERSION = '0.02'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$Waft::JS::Name = 'Waft.JS'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub convert_text_part { |
15
|
1
|
|
|
1
|
0
|
23
|
my ($self, $text_part, $break) = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my @text_parts |
18
|
1
|
|
|
|
|
26
|
= split /\b \Q$Waft::JS::Name\E \. /xms, $text_part; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
13
|
my $code = $self->next( shift(@text_parts), $break ); |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
196
|
while ( @text_parts ) { |
23
|
1
|
|
|
|
|
2
|
my $text_part = shift @text_parts; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
6
|
( my $method, $text_part ) = split / \b /xms, $text_part, 2; |
26
|
|
|
|
|
|
|
|
27
|
1
|
50
|
33
|
|
|
10
|
if ($method eq 'make_url' or $method eq 'url') { |
28
|
1
|
|
|
|
|
3
|
$code .= q{$__self->output_js_make_url_script;}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
5
|
$code .= $self->next($text_part, $break); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
64
|
return $code; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub output_js_make_url_script { |
38
|
1
|
|
|
1
|
0
|
5525
|
my ($self) = @_; |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
10
|
my $base_url = $self->jsstr_escape($self->get_base_url); |
41
|
1
|
|
|
|
|
62
|
my $page = $self->jsstr_escape($self->page); |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
73
|
my $v = q{}; |
44
|
1
|
|
|
|
|
5
|
my $value_hashref = $self->value_hashref; |
45
|
1
|
|
|
|
|
12
|
while ( my ($key, $values_arrayref) = each %$value_hashref ) { |
46
|
2
|
|
|
|
|
6
|
$key = $self->jsstr_escape($key); |
47
|
2
|
|
|
|
|
29
|
my @values = map { qq{'$_'} } $self->jsstr_escape(@$values_arrayref); |
|
3
|
|
|
|
|
49
|
|
48
|
2
|
|
|
|
|
17
|
$v .= q{v['} . $key . q{'] = [} . join(q{, }, @values) . q{];}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
8
|
my $javascript = qq{( function (page, keys, data) { |
52
|
|
|
|
|
|
|
var base_url = '$base_url'; |
53
|
|
|
|
|
|
|
var query_string = ''; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
if (page == undefined) page = 'default.html'; |
56
|
|
|
|
|
|
|
else if (page == 'CURRENT') page = '$page'; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
if (page != 'default.html') { |
59
|
|
|
|
|
|
|
query_string |
60
|
|
|
|
|
|
|
= '?p=' + encodeURIComponent(page).replace(/%20/g, '+'); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
var v = {}; $v |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
if (keys == undefined) |
66
|
|
|
|
|
|
|
return base_url + query_string; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
if (keys.constructor == Object) { |
69
|
|
|
|
|
|
|
data = keys; |
70
|
|
|
|
|
|
|
keys = []; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else if (keys == 'ALL_VALUES') { |
73
|
|
|
|
|
|
|
keys = []; |
74
|
|
|
|
|
|
|
for ( var key in v ) { |
75
|
|
|
|
|
|
|
keys.push(key); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
var keep = {}; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
for ( var i = 0; i < keys.length; i++ ) { |
82
|
|
|
|
|
|
|
if ( v[ keys[i] ] != undefined ) |
83
|
|
|
|
|
|
|
keep[ keys[i] ] = v[ keys[i] ]; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
if ( data ) { |
87
|
|
|
|
|
|
|
for ( var key in data ) { |
88
|
|
|
|
|
|
|
keep[key] = data[key]; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
var escape_space_percent_hyphen = function (val) { |
93
|
|
|
|
|
|
|
if ( typeof val != 'string' ) |
94
|
|
|
|
|
|
|
return val; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
val = val.replace(/%/g, '%25'); |
97
|
|
|
|
|
|
|
val = val.replace(/ /g, '%20'); |
98
|
|
|
|
|
|
|
val = val.replace(/-/g, '%2D'); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
return val; |
101
|
|
|
|
|
|
|
}; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
keys = []; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
for ( var key in keep ) { |
106
|
|
|
|
|
|
|
keys.push(key); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
if (keep[key].constructor == Array) { |
109
|
|
|
|
|
|
|
var val = ''; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
for ( var i = 0; i < keep[key].length; i++ ) { |
112
|
|
|
|
|
|
|
val += '-' + escape_space_percent_hyphen(keep[key][i]); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
keep[key] = val; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
else { |
118
|
|
|
|
|
|
|
keep[key] = '-' + escape_space_percent_hyphen(keep[key]); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
keys.sort(); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
var joined_values = ''; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
for ( var i = 0; i < keys.length; i++ ) { |
127
|
|
|
|
|
|
|
if (joined_values != '') joined_values += ' '; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
joined_values += escape_space_percent_hyphen(keys[i]) |
130
|
|
|
|
|
|
|
+ keep[ keys[i] ]; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
if (joined_values == '') |
134
|
|
|
|
|
|
|
return base_url + query_string; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
query_string += query_string == '' ? '?' : '&'; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
query_string |
139
|
|
|
|
|
|
|
+= 'v=' + encodeURIComponent(joined_values).replace(/%20/g, '+'); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
return base_url + query_string; |
142
|
|
|
|
|
|
|
} )}; |
143
|
|
|
|
|
|
|
|
144
|
1
|
|
|
|
|
265
|
$javascript =~ s/ (?: \x0D\x0A | [\x0A\x0D] ) \s* / /gxms; |
145
|
|
|
|
|
|
|
|
146
|
1
|
|
|
|
|
6
|
$self->output($javascript); |
147
|
|
|
|
|
|
|
|
148
|
1
|
|
|
|
|
7
|
return; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; |
152
|
|
|
|
|
|
|
__END__ |