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