File Coverage

blib/lib/BikePower/HTML.pm
Criterion Covered Total %
statement 66 71 92.9
branch 8 12 66.6
condition 1 3 33.3
subroutine 9 10 90.0
pod 0 7 0.0
total 84 103 81.5


line stmt bran cond sub pod time code
1             # -*- perl -*-
2              
3             #
4             # $Id: HTML.pm,v 1.4 1999/02/14 22:20:50 eserte Exp $
5             # Author: Slaven Rezic
6             #
7             # Copyright (C) 1999 Slaven Rezic. All rights reserved.
8             # This package is free software; you can redistribute it and/or
9             # modify it under the same terms as Perl itself.
10             #
11             # Mail: eserte@cs.tu-berlin.de
12             # WWW: http://user.cs.tu-berlin.de/~eserte/
13             #
14              
15             package BikePower::HTML;
16 1     1   824 use BikePower;
  1         2  
  1         22  
17 1     1   5 use strict;
  1         2  
  1         35  
18 1     1   5 use vars qw($fontstr $VERSION);
  1         2  
  1         905  
19              
20             $fontstr = "";
21             $VERSION = "0.02";
22              
23             # XXX englische Version
24              
25             sub cgi {
26 0     0 0 0 require CGI;
27 0         0 my $q = CGI->new;
28 0         0 print $q->header;
29 0         0 print code();
30             }
31              
32             sub code {
33 1     1 0 618 head() . body();
34             }
35              
36             sub head {
37 1     1 0 2 my $head = <<'EOF';
38            
39            
40             BikePower: persönliche Einstellungen
41            
42             EOF
43 1         41 $head .= set_personal_settings_js_code();
44 1         4 $head .= get_personal_settings_js_code();
45 1         2 $head .= "\n";
46 1         21 $head;
47             }
48              
49             sub body {
50 1     1 0 2 my $body = <<'EOF';
51            
52             EOF
53 1         3 $body .= $fontstr . <<'EOF';
54            

BikePower: persönliche Einstellungen

55            
56            
57             EOF
58             #
64 1         5 $body .= <
65            
${fontstr}Fahrergewicht${fontstr} kg
66            
${fontstr}Gewicht von Rad+Kleidung${fontstr}
67             value="12" size=3> kg
68            
${fontstr}Haltung des Fahrers${fontstr}
69             EOF
70 1         3 foreach my $res_key (@BikePower::air_resistance_order) {
71 7         12 my $res = $BikePower::air_resistance{$res_key};
72 7         33 $body .= "
73             . $res->{'text_de'} . "\n";
74             }
75 1         4 $body .= <
76            
77            
${fontstr}Rollwiderstand${fontstr}
78             EOF
79 1         2 foreach my $r (@BikePower::rolling_friction) {
80 6         25 $body .= "
81             . $r->{'text_de'} . "\n";
82             }
83 1         19 $body .= <
84            
85            
${fontstr}Effizienz der Übertragung${fontstr}
86            
87             Schließen
88            
89            
90             EOF
91 1         13 $body;
92             }
93              
94             sub set_personal_settings_js_code {
95             <<'EOF'
96            
110             EOF
111 1     1 0 5 }
112              
113             sub get_personal_settings_js_code {
114 1     1 0 2 my $code = <<'EOF';
115            
239             EOF
240 1         9 $code;
241             }
242              
243             sub new_from_cookie {
244 1     1 0 3995 my $q = shift; # CGI object
245              
246 1         8 my $raw_cookie = $q->raw_cookie;
247 1 50 33     3551 return if !defined $raw_cookie || $raw_cookie eq '';
248 1         6 my(@cookies) = split(/;\s*/, $raw_cookie);
249 1         3 my %bikepower_def;
250             TRY_COOKIE: {
251 1         3 foreach (@cookies) {
  1         3  
252 1         6 my($name, $cookie_def) = split(/=/, $_, 2);
253 1 50       6 if ($name eq 'BikePower') {
254 1         5 foreach (split(/:/, $cookie_def)) {
255 5         10 my($key, $val) = split(/=/, $_);
256 5         13 $bikepower_def{$key} = $val;
257             }
258 1         4 last TRY_COOKIE;
259             }
260             }
261 0         0 return;
262             }
263              
264 1         8 require BikePower;
265 1         10 my $bp_obj = new BikePower '-no-ini' => 1;
266 1         6 foreach (['frontalarea', 'A_c'],
267             ['transeff', 'transmission_efficiency'],
268             ['rollfriction', 'rolling_friction'],
269             ['weightcyclist', 'weight_cyclist'],
270             ['weightmachine', 'weight_machine'],
271             ) {
272 5         9 my($cgidef, $method) = ($_->[0], $_->[1]);
273 5 50       11 if (exists $bikepower_def{$cgidef}) {
274 5         9 my $eval = '$bp_obj->' . $method . '($bikepower_def{$cgidef})';
275 5         219 eval $eval;
276 5 50       23 warn $@ if $@; # XXX
277             }
278             }
279              
280 1         6 $bp_obj;
281             }
282              
283             1;
284              
285             __END__