comparison parsedata.pl @ 145:c028506aa9cc

Separate the concepts of "every other week" classes and split group classes.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 10 Sep 2014 12:44:10 +0300
parents 4faf9956741b
children 1a5994671dcf
comparison
equal deleted inserted replaced
144:f64a46fa7961 145:c028506aa9cc
285 sub parseHourData($$) 285 sub parseHourData($$)
286 { 286 {
287 my ($l, $rowspan) = @_; 287 my ($l, $rowspan) = @_;
288 my $chours = $rowspan / 2; # The table is actually in half cells 288 my $chours = $rowspan / 2; # The table is actually in half cells
289 my $cdata = []; 289 my $cdata = [];
290 my $cturns = 0;
290 my $cgrouped = 0; 291 my $cgrouped = 0;
291 292
292 # Pull in data for the class/hour cell 293 # Pull in data for the class/hour cell
293 foreach my $h (@{$l}) { 294 foreach my $h (@{$l}) {
294 if (defined($$h{"nodes"})) { 295 if (defined($$h{"nodes"})) {
295 foreach my $b (@{$$h{"nodes"}}) { 296 foreach my $b (@{$$h{"nodes"}}) {
296 if (defined($$b{"nodes"})) { 297 if (defined($$b{"nodes"})) {
297 my $text = $$b{"nodes"}[0]{"text"}; 298 my $text = $$b{"nodes"}[0]{"text"};
298 $text =~ s/\.$//; 299 $text =~ s/\.$//;
299 300
300 $cgrouped = 1 if ($text =~ /vuorov/); 301 if ($text =~ /vuorov/i)
301 302 {
302 push(@$cdata, $text); 303 $cturns = 1;
304 }
305 else
306 {
307 push(@$cdata, $text);
308 }
303 } 309 }
304 } 310 }
305 } 311 }
306 } 312 }
307 313
339 for (my $i = 0; $i < length($cdata); $i += 2) 345 for (my $i = 0; $i < length($cdata); $i += 2)
340 { 346 {
341 push(@$cdata1, $$cdata[$i]) if defined($$cdata[$i]); 347 push(@$cdata1, $$cdata[$i]) if defined($$cdata[$i]);
342 push(@$cdata2, $$cdata[$i+1]) if defined($$cdata[$i+1]); 348 push(@$cdata2, $$cdata[$i+1]) if defined($$cdata[$i+1]);
343 } 349 }
344 $$hourDefs{$cid} = { "grouped" => $cgrouped, "start" => $lastHour, "hours" => $chours, "data" => [ $cdata1, $cdata2 ] }; 350 $$hourDefs{$cid} = { "turns" => $cturns, "split" => $cgrouped, "start" => $lastHour, "hours" => $chours, "data" => [ $cdata1, $cdata2 ] };
345 } 351 }
346 else 352 else
347 { 353 {
348 $$hourDefs{$cid} = { "grouped" => $cgrouped, "start" => $lastHour, "hours" => $chours, "data" => [ $cdata ] }; 354 $$hourDefs{$cid} = { "turns" => $cturns, "split" => $cgrouped, "start" => $lastHour, "hours" => $chours, "data" => [ $cdata ] };
349 } 355 }
350 356
351 push(@{$$hourTable{$cday}}, $tid); 357 push(@{$$hourTable{$cday}}, $tid);
352 $totalHours += $chours; 358 $totalHours += $chours;
353 } 359 }