Added tests for Objective-J mode.
[ohcount] / test / expected_dir / perl.cgi
1 perl    comment #!/usr/bin/perl -w
2 perl    blank   
3 perl    comment # ajaxCheckbox.pl - a script to test Ajax functionality
4 perl    blank   
5 perl    code    use strict;
6 perl    code    use CGI qw/:standard/;     
7 perl    code    use CGI::Ajax;
8 perl    code    use DBI;
9 perl    blank   
10 perl    comment # --- database authenication
11 perl    code    my $dbh = do 'db.inc';
12 perl    blank   
13 perl    code    my $query = q{ SELECT project.project_id, project.name, project.phase, prio.prio, 
14 perl    code                   HEX((255 - prio.prio)) AS hex, begun, tags
15 perl    code                       FROM project JOIN prio 
16 perl    code                       ON (project.project_id = prio.project_id)
17 perl    code                       WHERE completed < 1
18 perl    code                       ORDER BY prio.prio DESC LIMIT 3};
19 perl    blank   
20 perl    code    my $sth = $dbh->prepare($query);
21 perl    code    $sth->execute();
22 perl    code    my $result = $dbh->selectall_arrayref($sth);
23 perl    blank   
24 perl    code    my $cgi = new CGI;
25 perl    code    my $pjx = new CGI::Ajax( 'toStruck' => \&perl_func );
26 perl    code    print $pjx->build_html( $cgi, \&Show_HTML);
27 perl    blank   
28 perl    code    sub Show_HTML {
29 perl    blank   
30 perl    code        use CGI qw/:standard/; 
31 perl    blank   
32 perl    code        my $html = <<HEAD;
33 perl    code        <!DOCTYPE html
34 perl    code            PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
35 perl    code            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
36 perl    code            <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
37 perl    code            <head>
38 perl    code            <title>This is the lastest source version</title>
39 perl    code            <link rel="stylesheet" type="text/css" href="/css/carrot.css" />
40 perl    code            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
41 perl    code            </head><body>
42 perl    code            <h2>Carrot Queue</h2><a href="/cgi-bin/source_carrot/index.cgi">Priority List</a><b>&nbsp; | &nbsp;</b>
43 perl    code            <a href="/cgi-bin/source_carrot/add.cgi">Add a listing</a><b>&nbsp; | &nbsp;</b><div class="content" /><h4>Project listing</h4>
44 perl    code    HEAD
45 perl    blank   
46 perl    code    foreach my $row (@$result) {
47 perl    code        $html .= "<input type=\"checkbox\" name=name" . @$row[0] . " id=val" . @$row[0] . " value=\"ON\" onClick=\"toStruck( ['val@$row[0]'], ['div@$row[0]'] );\">";
48 perl    code        $html .= "<div id=\"div@$row[0]\" style=\"display: inline;\"><!-- This gets entirely replaced -->" . @$row[1] . "</span></div><br>";
49 perl    code    }
50 perl    blank   
51 perl    comment # you can append stuff to the HTML this way 
52 perl    code    $html .= "</body></html>";
53 perl    blank   
54 perl    code    return $html;
55 perl    code    }
56 perl    blank   
57 perl    code    sub perl_func {
58 perl    code        my  $input=shift;
59 perl    blank   
60 perl    comment     # if onClick the change the style
61 perl    code        if ($input eq "ON") {
62 perl    code            $input="<span style=\"text-decoration: line-through; display: inline;\">";
63 perl    code        } else {
64 perl    code            $input ="<span style=\"text-decoration: none; display: inline;\">";
65 perl    code        } 
66 perl    code    }