# -*- perl -*- # # $Id: HTML.pm,v 1.7 2003/10/22 21:36:11 eserte Exp $ # Author: Slaven Rezic # # Copyright (C) 1999 Slaven Rezic. All rights reserved. # This package is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # # Mail: slaven@rezic.de # WWW: http://www.rezic.de/eserte/ # package BikePower::HTML; use BikePower; use strict; use vars qw($fontstr $VERSION); $fontstr = ""; $VERSION = "0.02"; # XXX englische Version sub cgi { require CGI; my $q = CGI->new; print $q->header; print code(); } sub code { head() . body(); } sub head { my $head = <<'EOF'; BikePower: persönliche Einstellungen EOF $head .= set_personal_settings_js_code(); $head .= get_personal_settings_js_code(); $head .= "\n"; $head; } sub body { my $body = <<'EOF'; EOF $body .= $fontstr . <<'EOF';

BikePower: persönliche Einstellungen

EOF # $body .= <
${fontstr}Fahrergewicht${fontstr} kg
${fontstr}Gewicht von Rad+Kleidung${fontstr} kg
${fontstr}Haltung des Fahrers${fontstr}
${fontstr}Rollwiderstand${fontstr}
${fontstr}Effizienz der Übertragung${fontstr}
Schließen
EOF $body; } sub set_personal_settings_js_code { <<'EOF' EOF } sub get_personal_settings_js_code { my $code = <<'EOF'; EOF $code; } sub new_from_cookie { my $q = shift; # CGI object my $raw_cookie = $q->raw_cookie; return if !defined $raw_cookie || $raw_cookie eq ''; my(@cookies) = split(/;\s*/, $raw_cookie); my %bikepower_def; TRY_COOKIE: { foreach (@cookies) { my($name, $cookie_def) = split(/=/, $_, 2); if ($name eq 'BikePower') { foreach (split(/:/, $cookie_def)) { my($key, $val) = split(/=/, $_); $bikepower_def{$key} = $val; } last TRY_COOKIE; } } return; } require BikePower; my $bp_obj = new BikePower '-no-ini' => 1; foreach (['frontalarea', 'A_c'], ['transeff', 'transmission_efficiency'], ['rollfriction', 'rolling_friction'], ['weightcyclist', 'weight_cyclist'], ['weightmachine', 'weight_machine'], ) { my($cgidef, $method) = ($_->[0], $_->[1]); if (exists $bikepower_def{$cgidef}) { my $eval = '$bp_obj->' . $method . '($bikepower_def{$cgidef})'; eval $eval; warn $@ if $@; # XXX } } $bp_obj; } 1; __END__