Revision 3bd1773c
Von Sven Schöling vor mehr als 15 Jahren hinzugefügt
bin/mozilla/common.pl | ||
---|---|---|
276 | 276 |
sub calculate_qty { |
277 | 277 |
$lxdebug->enter_sub(); |
278 | 278 |
|
279 |
my @variable_sort = (); |
|
280 |
my %variable_list = (); |
|
281 |
my $unit_list = (); |
|
282 | 279 |
$form->{formel} =~ s/\r\n//g; |
283 | 280 |
|
284 | 281 |
my ($variable_string, $formel) = split /###/,$form->{formel}; |
285 | 282 |
|
286 |
|
|
287 |
split m/;/, $variable_string; |
|
288 |
foreach $item (@_) { |
|
289 |
my($name, $valueunit) = split /=/,$item; |
|
290 |
my($value, $unit) = split / /, $valueunit; |
|
291 |
|
|
292 |
push(@variable_sort, $value); |
|
293 |
$variable_list{$value} = $name; |
|
294 |
$unit_list{$value} = $unit; |
|
283 |
foreach $item (split m/;/, $variable_string) { |
|
284 |
next unless $item =~ m/^ \s* (\w+) \s* = \s* (\w+) \s* (\w+) \s* $/x; |
|
285 |
push @variable, { |
|
286 |
description => $1, |
|
287 |
name => $2, |
|
288 |
unit => $3, |
|
289 |
}; |
|
295 | 290 |
} |
296 | 291 |
|
297 | 292 |
my @header_sort = qw(variable value unit); |
298 |
my %header_title = ( "variable" => $locale->text("Variable"), |
|
299 |
"value" => $locale->text("Value"), |
|
300 |
"unit" => $locale->text("Unit"), |
|
301 |
); |
|
293 |
my %header_title = ( |
|
294 |
variable => $locale->text("Variable"), |
|
295 |
value => $locale->text("Value"), |
|
296 |
unit => $locale->text("Unit"), |
|
297 |
); |
|
298 |
my @header = map +{ |
|
299 |
column_title => $header_title{$_}, |
|
300 |
column => $_, |
|
301 |
}, @header_sort; |
|
302 | 302 |
|
303 |
my @variable = map(+{ "description" => $variable_list{$_}, |
|
304 |
"name" => $_, |
|
305 |
"unit" => $unit_list{$_} }, @variable_sort); |
|
306 |
|
|
307 |
my @header = |
|
308 |
map(+{ "column_title" => $header_title{$_}, |
|
309 |
"column" => $_, |
|
310 |
}, |
|
311 |
@header_sort); |
|
312 | 303 |
$form->{formel} = $formel; |
313 |
$form->{"title"} = $locale->text("Please enter values");
|
|
304 |
$form->{title} = $locale->text("Please enter values");
|
|
314 | 305 |
$form->header(); |
315 |
print($form->parse_html_template("generic/calculate_qty", { "HEADER" => \@header,
|
|
306 |
print $form->parse_html_template("generic/calculate_qty", { "HEADER" => \@header,
|
|
316 | 307 |
"VARIABLES" => \@variable, |
317 |
"onload" => $onload }));
|
|
308 |
"onload" => $onload }); |
|
318 | 309 |
|
319 | 310 |
$lxdebug->leave_sub(); |
320 | 311 |
} |
Auch abrufbar als: Unified diff
Verbesserung an der Formelmeachanik.
Fehlertoleranteres Parsing, und Dokumentation im Tooltip.
Ausserdem das sehr suspekte Konstrukt "split m/;/, $formel; for (@_) { ... }" entfernt.
Fix für Bug 461.