Syntax highlighting correction
[tpope-extra.git] / perl / sctweb
index 2380f31074598f540a57a3845aa1899b2d902ebb..6c47ff946e0290280c5649f8962b45f23bca0dc8 100755 (executable)
@@ -91,7 +91,7 @@ $response = $ua->post("$url&tserve_trans_config=astulog.cfg", { tserve_tip_write
 
 $response = $ua->get("$url&tserve_tip_write=||WID|SID|PIN|Term&tserve_trans_config=" . ("regterm.cfg"||"rgrdterm.cfg")); # Valid terms
 die $response->status_line unless $response->is_success;
-my @terms = grep {s/^<option value="([^"]*)">.*/$1/} (split( /\r\n/, $response->content));
+my @terms = grep {s/^<option value="([^"]*)">.*/$1/} (split( /\r\n/, $response->content)); # "
 if(@terms) {
     $opts{school} = 'accd';
 } else {
@@ -344,7 +344,7 @@ sub get_faculty_email {
        open INS, $ENV{'HOME'} . "/public_html/faculty.csv";
        while($_ = <INS>) {
            chomp;
-           m/"([^"]*)",([^,]*),([^,]*)/;
+           m/"([^"]*)",([^,]*),([^,]*)/; # "
            ($name, $email, $school) = ($1, $2, $3);
            $name =~ s/^([^,]*), ([^,]*)(.*)$/$2 $1$3/;
            $name =~ s/ [A-Z]\.//g;
@@ -529,16 +529,20 @@ sub do_vcalendar_schedule {
 
 sub do_html_schedule {
     my @showheaders = ("Section ID/Title", "Instructor", "Days", "Time", "Duration", "Location");
+    my $shade = "dark";
     my @schedule = get_schedule(@_);
-    print '<table cellpadding="3" cellspacing="0">'."\n<tr><th>";
+    print '<table id="schedule" cellpadding="3" cellspacing="0">'."\n<tr><th>";
     print join("</th><th>",@showheaders);
     print "</th></tr>\n";
        foreach my $row (@schedule) {
            map { s/\n/<br \/>/g; $_} %$row;
            $row->{'time'} =~ s/-/-<wbr \/>/;
            $row->{'duration'} =~ s/\d\d(\d\d)(\d\d)(\d\d)/$2-$3-$1/g;
-           print '<tr>';
-           print "<td>" . $row->{'id'} . "<br />" . $row->{'title'} . "</td>";
+           print '<tr class="'.$shade.'">';
+           $shade = ($shade eq "dark"?"light":"dark");
+           print '<td class="idtitle">';
+           print '<span class="sectionid">' .$row->{'id'}. '</span><br />';
+           print '<span class="coursetitle">' .$row->{'title'}. '</span></td>';
            my $instructor = $row->{'instructor'};
            $instructor =~ s/^([^,]*), ([^,]*)(.*)/$2 $1$3/;
            my $email = get_faculty_email($instructor);
@@ -562,6 +566,7 @@ sub do_html_grades {
     @readheaders = ("Section", "Course Title", "FinalGrade", "Earned Hours", "Quality Hours", "Quality Points", "GPA") if($opts{'school'} eq 'tamuk');
     my @showheaders = ("Section ID", "Course Title", "Grade", "Earned<br />Hours", "Quality<br />Hours", "Quality<br />Points");
     my ($row, $lastrow);
+    my $shade = "dark";
     my $te = new HTML::TableExtract( headers => [ @readheaders ] );
     my $response = $ua->get("$url&tserve_tip_write=||WID|SID|PIN|Term&tserve_trans_config=rgrdterm.cfg"); # Valid grading terms
     die $response->status_line unless $response->is_success;
@@ -574,31 +579,37 @@ sub do_html_grades {
        die $response->status_line unless $response->is_success;
        $te->parse($response->content);
     }
-    print '<table cellpadding="3" cellspacing="0">'."\n<tr><th>";
-    print $showheaders[0], '</th><th>';
-    print join('</th><th>',@showheaders[1 .. 5]);
+    print '<table id="grades" cellpadding="3" cellspacing="0">'."\n<tr>";
+    print '<th align="left" class="sectionid">', $showheaders[0];
+    print '</th><th align="left" class="coursetitle">', $showheaders[1];
+    print '</th><th align="center" class="grade">';
+    print join('</th><th align="center" class="right-number">',@showheaders[2 .. 5]);
     print "</th></tr>\n";
     foreach my $ts ($te->table_states) {
        foreach my $row ($ts->rows) {
            map { s/^\s+//; s/\xa0|\r//g; s/\n/<br \/>/g; $_} @$row;
            $row->[1] = capitalize($row->[1]);
            $row->[1] =~ s/&/&amp;/g;
+           $row->[0] =~ s/Cumulative through/Cumulative: through/;
+           $row->[0] =~ s/Cumulative:(.*) (\d{4}) (.*)/Cumulative:$1 $3 $2/;
            $lastrow=$row;
-           next if $row->[0] =~ /:|Current Term|Cumulative/;
-           print '<tr><td>';
-           print $$row[0], '</td><td>', $$row[1], '</td>';
-           print '<td align="center">';
+           next if $row->[0] =~ /:|Current Term/;
+           print '<tr class="'.$shade.'">';
+           $shade = ($shade eq "dark"?"light":"dark");
+           print '<td align="left" class="sectionid">', $$row[0], '</td>';
+           print '<td align="left" class="coursetitle">', $$row[1], '</td>';
+           print '<td align="center" class="grade">';
            #print join('</td><td>', @$row[0 .. 1]);
-           print join('</td><td>', @$row[2 .. 5]);
+           print join('</td><td align="right" class="right-number">', @$row[2 .. 5]);
            print "</td></tr>\n";
        }
     }
-    print '<tr><td colspan="2">', capitalize($lastrow->[0]);
+    print '<tr class="cumulative '.$shade.'"><td id="cumulative" colspan="2">', capitalize($lastrow->[0]);
     #shift @$lastrow; shift @$lastrow;
-    print '</td><td align="center">';
+    print '</td><td align="center" id="gpa" class="grade">';
     print $$lastrow[6];
-    print '</td><td>';
-    print join('</td><td>', @$lastrow[3 .. 5]);
+    print '</td><td align="right" class="right-number">';
+    print join('</td><td align="right" class="right-number">', @$lastrow[3 .. 5]);
     print "</td></tr>\n";
     print "</table>\n";
 }