[Bio] / FigKernelPackages / HTML.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/HTML.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6, Sun Mar 21 02:20:55 2004 UTC revision 1.35, Sun Mar 13 00:55:21 2005 UTC
# Line 1  Line 1 
1  package HTML;  package HTML;
2    
3    use FIG;
4  use Carp;  use Carp;
5  use Data::Dumper;  use Data::Dumper;
6  use LWP::UserAgent;  use LWP::UserAgent;
7  use LWP::Simple;  use LWP::Simple;
8  use URI::URL;  use URI::URL;
9  use HTTP::Request::Common;  use HTTP::Request::Common;
10    use POSIX;
11    
12  sub show_page {  sub new
13      my($cgi,$html,$no_home) = @_;  {
14      my $i;      my($class) = @_;
15    
16      #      my $self = {};
17      # Find the HTML header  
18      #      return bless $self, $class;
19    }
20    
21    sub compute_html_header
22    {
23        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
24        my($additional_insert,$user) = @_;
25      my $html_hdr_file = "./Html/html.hdr";      my $html_hdr_file = "./Html/html.hdr";
26      if (! -f $html_hdr_file)      if (! -f $html_hdr_file)
27      {      {
28          $html_hdr_file = "$FIG_Config::fig/CGI/Html/html.hdr";          $html_hdr_file = "$FIG_Config::fig/CGI/Html/html.hdr";
29      }      }
30        my @html_hdr = &FIG::file_read($html_hdr_file);
31        push( @html_hdr, "<br><a href=\"index.cgi?user=$user\">FIG search</a>\n" );
32    
33        if (@html_hdr)
34        {
35            my $insert_stuff;
36            my @ver = &FIG::file_head("$FIG_Config::fig_disk/CURRENT_RELEASE", 1);
37            my $ver = $ver[0];
38            chomp $ver;
39            if ($ver =~ /^cvs\.(\d+)$/)
40            {
41                my $d = asctime(localtime($1));
42                chomp($d);
43                $ver .=  " ($d)";
44            }
45            my $host = &FIG::get_local_hostname();
46            $insert_stuff = "SEED version <b>$ver</b> on $host";
47            if ($additional_insert)
48            {
49                $insert_stuff .= "<br>" . $additional_insert;
50            }
51    
52            for $_ (@html_hdr)
53            {
54                s,(href|img\s+src)="/FIG/,\1="$FIG_Config::cgi_base,g;
55                if ($_ eq "<!-- HEADER_INSERT -->\n")
56                {
57                    $_ = $insert_stuff;
58                }
59            }
60        }
61    
62        return @html_hdr;
63    }
64    
65    sub show_page {
66        #warn "SHOWPAGE: cgi=", Dumper(@_);
67        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
68        my($cgi,$html,$no_home, $alt_header, $css) = @_;
69        my $i;
70    
71    
72        # ARGUMENTS:
73        #     $cgi is the CGI method
74        #     $html is an array with all the html in it. It is just joined by "\n" (and not <br> or <p>
75        #     $no_home eliminates ONLY the bottom FIG search link in a page
76        #     $alt_header is a reference to an array for an alternate header banner that you can replace the standard one with
77        #     $css is a reference to a hash. The key is the name of the CSS sheet and the value is the URL of that sheet. Note the usual rules about relative css urls
78        #               the sheet named "Default" is considered to be the default style sheet, and if this is not set it points at $FIG_Config::HTML/css/default.css
79        #               the sheet named "Sans Serif" is considered to the the first alternate, and if this is not set it points at $FIG_Config::HTML/css/sanserif.css
80    
81        #
82        # Find the HTML header
83        #
84    
85      my $html_tail_file = "./Html/html.tail";      my $html_tail_file = "./Html/html.tail";
86      if (! -f $html_tail_file)      if (! -f $html_tail_file)
# Line 27  Line 88 
88          $html_tail_file = "$FIG_Config::fig/CGI/Html/html.tail";          $html_tail_file = "$FIG_Config::fig/CGI/Html/html.tail";
89      }      }
90    
91        my $user = $cgi->param('user') || "";
92        my @html_hdr;
93        if ($alt_header)
94        {
95           @html_hdr = @$alt_header;
96        }
97        else
98        {
99            @html_hdr = compute_html_header(undef,$user);
100        }
101    
102    
103      print $cgi->header;      print $cgi->header;
104    
# Line 145  Line 217 
217      #      #
218      #  <BODY> goes after last head line      #  <BODY> goes after last head line
219      #      #
220        #  RAE:
221        #  Added the javascript for the buttons immediately after body.
222        #  Note if no buttons are added we still (at the moment) add the script,
223        #  but it only adds a little text (495 characters) to the html and noone will notice!
224    
225      if ( $body_line < 0 )      if ( $body_line < 0 )
226      {      {
227            my $js=&javascript;
228          $body_line = $last_head_line + 1;          $body_line = $last_head_line + 1;
229          splice( @$html, $body_line, 0, "<BODY>\n" );          splice( @$html, $body_line, 0, "<BODY>\n$js\n" );
230      }      }
231    
232      #      #
233      #  Seed page header (if it exists) goes after <BODY>      #  Seed page header (if it exists) goes after <BODY>
234      #      #
235    
236      if ( -f $html_hdr_file )      if (@html_hdr)
237      {      {
238          splice( @$html, $body_line + 1, 0, `cat $html_hdr_file` );          splice( @$html, $body_line + 1, 0, @html_hdr );
239      }      }
240    
241      #      #
# Line 171  Line 248 
248          splice( @$html, $body_line, 0, "</HEAD>\n" );          splice( @$html, $body_line, 0, "</HEAD>\n" );
249      }      }
250    
251        # RAE:
252        # Add css here
253        # Note that at the moment I define these two sheets here. I think this should be moved out, but I want to try it and see what happens
254        # css has the format
255        # <link rel='stylesheet' title='default' href='/css/default.css' type='text/css'>
256    
257        # convert the default key to the right case. and eliminate dups
258        foreach my $k (keys %$css) {if (lc($k) eq "default") {$css->{'Default'}=$css->{$k}}}
259    
260        if (!$css || !$css->{'Default'})
261        {
262           $css->{'Default'}="/FIG/Html/css/default.css";
263        }
264        if (!$css->{"Sans Serif"})
265        {
266           $css->{'Sans Serif'}="/FIG/Html/css/sanserif.css";
267        }
268        my $csstext = "<link rel='stylesheet' title='default' href='".$css->{'Default'}."' type='text/css'>\n";
269        $csstext   .= "<link rel='alternate stylesheet' title='Sans Serif' href='".$css->{'Sans Serif'}."' type='text/css'>\n";
270    
271        foreach my $k (keys %$css)
272        {
273           next if (lc($k) eq "default" || lc($k) eq "sans serif");
274           $csstext .= "<link rel='stylesheet' title='$k' href='".$css->{$k}."' type='text/css'>\n";
275        }
276        splice( @$html, $head_end_line, 1, "$csstext</HEAD>\n" );  # note here I am replacing the </head> line. Could be bad...? But it doesn't increment everything else.
277    
278      #      #
279      #  <BASE ...> goes before </HEAD>      #  <BASE ...> goes before </HEAD>
280      #      #
# Line 183  Line 287 
287          #  only, or every update?), I provide an alternative derivation          #  only, or every update?), I provide an alternative derivation
288          #  from $cgi_url. -- GJO          #  from $cgi_url. -- GJO
289          #          #
290            # BASE href needs to be absolute. RDO.
291          my $base_url = $FIG_Config::cgi_base;          #
292          if ( ! $base_url )                      # if cgi_base was not defined          #
293          {          $base_url = &FIG::cgi_url;
294              $base_url = $FIG_Config::cgi_url;   # get the full cgi url  #       my $base_url = $FIG_Config::cgi_base;
295              $base_url =~ s~^http://[^/]*~~;     # remove protocol and host  #       if ( ! $base_url )                      # if cgi_base was not defined
296              $base_url =~ m~/$~ || $base_url =~ s~$~/~; # check trailing slash  #       {
297          }  #           $base_url = $FIG_Config::cgi_url;   # get the full cgi url
298    #           $base_url =~ s~^http://[^/]*~~;     # remove protocol and host
299    #           $base_url =~ m~/$~ || $base_url =~ s~$~/~; # check trailing slash
300    #       }
301    
302          $base_line = $head_end_line;          $base_line = $head_end_line;
303          splice( @$html, $base_line, 0, "<BASE href=\"$base_url\">\n" );          splice( @$html, $base_line, 0, "<BASE href=\"$base_url/\">\n" );
304      }      }
305    
306      #      #
# Line 228  Line 335 
335      }      }
336    
337      #      #
338        # See if we have a site-specific tail (for disclaimers, etc).
339        #
340    
341        my $site_tail = "$FIG_Config::fig_disk/config/site_tail.html";
342        my $site_fh;
343        if (open($site_fh, "<$site_tail"))
344        {
345            push(@tail, <$site_fh>);
346            close($site_fh);
347        }
348    
349        #
350      #  Figure out where to insert The SEED tail.  Before </body>,      #  Figure out where to insert The SEED tail.  Before </body>,
351      #  or before </html>, or at end of page.      #  or before </html>, or at end of page.
352      #      #
# Line 255  Line 374 
374          splice( @$html, $i, 0, @tags );          splice( @$html, $i, 0, @tags );
375      }      }
376    
377      print @$html;      print join "\n", @$html;
378  }  }
379    
380  sub make_table {  sub make_table {
381      my($col_hdrs,$tab,$title,$instr) = @_;      my($col_hdrs,$tab,$title, %options ) = @_;
382      my(@tab);      my(@tab);
383    
384      push( @tab, "\n<table border>\n",      my $border = defined $options{border} ? "border=\"$options{border}\"" : "border";
385        push( @tab, "\n<table $border>\n",
386                  "\t<caption><b>$title</b></caption>\n",                  "\t<caption><b>$title</b></caption>\n",
387                  "\t<tr>\n\t\t<th>"                  "\t<tr>\n\t\t"
388                . join( "</th>\n\t\t<th>", @$col_hdrs )                . join( "\n", map { &expand($_, "th") } @$col_hdrs )
389                . "</th>\n\t</tr>\n"                . "\n\t</tr>\n"
390          );          );
391      my($i,$nowrap);      my($i);
   
     for ($i=0; ($i < @$instr) && ($instr->[$i] !~ /nowrap/); $i++) {}  
     $nowrap = ($i == @$instr) ? "" : " nowrap";  
392    
393      my $row;      my $row;
394      foreach $row (@$tab)      foreach $row (@$tab)
395      {      {
396          push( @tab, "\t<tr>\n"          push( @tab, "\t<tr>\n"
397                    . join( "\n", map { &expand($_,$nowrap) } @$row )                    . join( "\n", map { &expand($_) } @$row )
398                    . "\n\t</tr>\n"                    . "\n\t</tr>\n"
399              );              );
400      }      }
# Line 286  Line 403 
403  }  }
404    
405  sub expand {  sub expand {
406      my($x,$nowrap) = @_;      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
407        my($x, $tag) = @_;
408    
409        $tag = "td" unless $tag;
410        my $endtag=$tag;
411        # RAE modified this so that you can pass in a reference to an array where the first element is the data to
412        # display and the second element is optional things like colspan and align. Note that in this case you need to include the td
413        # use something like ["some data to appear", "td colspan=4 bgcolor=gray"]
414        if (ref($x) eq "ARRAY") {($x, $tag)=@$x; if ($tag =~ /td/) {$endtag = "td"}}
415    
416      if ($x =~ /^\@([^:]+)\:([^:]+)\:(.*)$/)      if ($x =~ /^\@([^:]+)\:(.*)$/)
417      {      {
418          return "\t\t<td$nowrap $1=\"$2\">$3</td>";          return "\t\t<$tag $1>$2</$endtag>";
419      }      }
420      else      else
421      {      {
422          return "\t\t<td$nowrap>$x</td>";          return "\t\t<$tag>$x</$endtag>";
423      }      }
424  }  }
425    
426    sub set_ec_links {
427        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
428        my($cgi,$x) = @_;
429        my($before,$match,$after);
430    
431        if ($x =~ /^(.*)(EC \d+\.\d+\.\d+\.\d+)(.*)/s)
432        {
433            $before = $1;
434            $match = $2;
435            $after = $3;
436            return &set_ec_links($cgi,$before) . &HTML::ec_link($match) . &set_ec_links($cgi,$after);
437        }
438        return $x;
439    }
440    
441  sub ec_link {  sub ec_link {
442        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
443      my($role) = @_;      my($role) = @_;
444    
445      if ($role =~ /(\d+\.\d+\.\d+\.\d+)/)      if ($role =~ /(\d+\.\d+\.\d+\.\d+)/)
# Line 312  Line 453 
453  }  }
454    
455  sub role_link {  sub role_link {
456        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
457      my($cgi,$role) = @_;      my($cgi,$role) = @_;
458    
459      my $roleR = ($role =~ /^(\d+\.\d+\.\d+\.\d+)\s+-\s+/) ? $1 : $role;      my $roleR = ($role =~ /^(\d+\.\d+\.\d+\.\d+)\s+-\s+/) ? $1 : $role;
# Line 322  Line 464 
464      return "<a href=$link>$role</a>";      return "<a href=$link>$role</a>";
465  }  }
466    
467    #
468    # Local means to eliminate the fig|org.peg from the
469    # text of the link.
470    #
471  sub fid_link {  sub fid_link {
472        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
473      my($cgi,$fid,$local,$just_url) = @_;      my($cgi,$fid,$local,$just_url) = @_;
474      my($n);      my($n);
475    
# Line 347  Line 494 
494          my $user = $cgi->param('user');          my $user = $cgi->param('user');
495          if (! $user) { $user = "" }          if (! $user) { $user = "" }
496          my $trans = $cgi->param('translate') ? "&translate=1" : "";          my $trans = $cgi->param('translate') ? "&translate=1" : "";
497          my $link = $cgi->url() . "?prot=$fid&user=$user$trans";          my $sprout = $cgi->param('SPROUT') ? "&SPROUT=1" : "";
498          $link =~ s/[a-z_A-Z]+\.cgi\?/protein.cgi?/;          my $link = &FIG::cgi_url . "/protein.cgi?prot=$fid&user=$user$trans$sprout";
499            $link =~ s/[a-z_A-Z0-9]+\.cgi\?/protein.cgi?/;
500            #
501            # Elimin the p2p part if we're in that subdir. Ugh.
502            #
503            $link =~ s,p2p/protein.cgi,protein.cgi,;
504    
505          if ($just_url)          if ($just_url)
506          {          {
507              return $link;              return $link;
# Line 362  Line 515 
515  }  }
516    
517  sub family_link {  sub family_link {
518        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
519      my($family,$user) = @_;      my($family,$user) = @_;
520    
521      return $family;      return $family;
# Line 370  Line 524 
524  use URI::Escape;  use URI::Escape;
525    
526  sub get_html {  sub get_html {
527        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
528      my( $url, $type, $kv_pairs) = @_;      my( $url, $type, $kv_pairs) = @_;
529      my( $encoded, $ua, $args, @args, $out, @output, $x );      my( $encoded, $ua, $args, @args, $out, @output, $x );
530    
531      $ua = new LWP::UserAgent;      $ua = new LWP::UserAgent;
532      $ua->timeout( 900 );      $ua->timeout( 900 );
   
533      if ($type =~/post/i)      if ($type =~/post/i)
534      {      {
535          $args = [];          $args = [];
# Line 435  Line 589 
589  }  }
590    
591  sub trim_output {  sub trim_output {
592        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
593      my($out) = @_;      my($out) = @_;
594      my $i;      my $i;
595    
# Line 472  Line 627 
627  }  }
628    
629  sub set_prot_links {  sub set_prot_links {
630        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
631      my($cgi,$x) = @_;      my($cgi,$x) = @_;
632      my($before,$match,$after);      my($before,$match,$after);
633    
634      if ($x =~ /^(.*)(fig\|\d+\.\d+\.peg\.\d+)(.*)$/)      if ($x =~ /^(.*)(fig\|\d+\.\d+\.peg\.\d+)(.*)/s)
635        {
636            $before = $1;
637            $match = $2;
638            $after = $3;
639            return &set_prot_links($cgi,$before) . &HTML::fid_link($cgi,$match) . &set_prot_links($cgi,$after);
640        }
641        elsif ($x =~ /^(.*)\b([NXYZA]P_[0-9\.]+)\b(.*)/s)
642        {
643            $before = $1;
644            $match = $2;
645            $after = $3;
646            return &set_prot_links($cgi,$before) . &HTML::refseq_link($cgi,$match) . &set_prot_links($cgi,$after);
647        }
648        elsif ($x =~ /^(.*)(gi\|\d+)(.*)/s)
649        {
650            $before = $1;
651            $match = $2;
652            $after = $3;
653            return &set_prot_links($cgi,$before) . &HTML::gi_link($cgi,$match) . &set_prot_links($cgi,$after);
654        }
655        elsif ($x =~  /^(.*)(uni\|[A-Z0-9]{6})(.*)/s)
656      {      {
657          $before = $1;          $before = $1;
658          $match = $2;          $match = $2;
659          $after = $3;          $after = $3;
660          return &set_prot_links($cgi,$before) . &HTML::fid_link($cgi,$match) . &set_prot_links($cgi,$after) . "\n";          return &set_prot_links($cgi,$before) . &HTML::uni_link($cgi,$match) . &set_prot_links($cgi,$after);
661      }      }
662      elsif ($x =~ /^(.*)(gi\|\d+)(.*)$/)      elsif ($x =~ /^(.*)(sp\|[A-Z0-9]{6})(.*)/s)
663      {      {
664          $before = $1;          $before = $1;
665          $match = $2;          $match = $2;
666          $after = $3;          $after = $3;
667          return &set_prot_links($cgi,$before) . &HTML::gi_link($cgi,$match) . &set_prot_links($cgi,$after) . "\n";          return &set_prot_links($cgi,$before) . &HTML::sp_link($cgi,$match) . &set_prot_links($cgi,$after);
668      }      }
669      elsif ($x =~ /^(.*)(sp\|[A-Z0-9]{6})(.*)$/)      elsif ($x =~ /^(.*)(pirnr\|NF\d+)(.*)/s)
670      {      {
671          $before = $1;          $before = $1;
672          $match = $2;          $match = $2;
673          $after = $3;          $after = $3;
674          return &set_prot_links($cgi,$before) . &HTML::sp_link($cgi,$match) . &set_prot_links($cgi,$after) . "\n";          return &set_prot_links($cgi,$before) . &HTML::pir_link($cgi,$match) . &set_prot_links($cgi,$after);
675      }      }
676      elsif ($x =~ /^(.*)(pirnr\|NF\d+)(.*)$/)      elsif ($x =~ /^(.*)(kegg\|[a-z]{2,4}:[a-zA-Z_0-9]+)(.*)/s)
677      {      {
678          $before = $1;          $before = $1;
679          $match = $2;          $match = $2;
680          $after = $3;          $after = $3;
681          return &set_prot_links($cgi,$before) . &HTML::pir_link($cgi,$match) . &set_prot_links($cgi,$after) . "\n";          return &set_prot_links($cgi,$before) . &HTML::kegg_link($cgi,$match) . &set_prot_links($cgi,$after);
682      }      }
683      return $x;      return $x;
684  }  }
685    
686    sub refseq_link {
687        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
688        my($cgi,$id) = @_;
689    
690        if ($id =~ /^[NXYZA]P_/)
691        {
692            return "<a href=http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=protein&cmd=search&term=$id>$id</a>";
693        }
694    }
695    
696  sub gi_link {  sub gi_link {
697        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
698      my($cgi,$gi) = @_;      my($cgi,$gi) = @_;
699    
700      if ($gi =~ /^gi\|(\d+)$/)      if ($gi =~ /^gi\|(\d+)$/)
# Line 516  Line 704 
704      return $gi;      return $gi;
705  }  }
706    
707    sub uni_link {
708        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
709        my($cgi,$uni) = @_;
710    
711        if ($uni =~ /^uni\|(\S+)$/)
712        {
713            return "<a href=http://www.pir.uniprot.org/cgi-bin/upEntry?id=$1>$uni</a>";
714        }
715        return $uni;
716    }
717    
718  sub sp_link {  sub sp_link {
719        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
720      my($cgi,$sp) = @_;      my($cgi,$sp) = @_;
721    
722      if ($sp =~ /^sp\|(\S+)$/)      if ($sp =~ /^sp\|(\S+)$/)
# Line 527  Line 727 
727  }  }
728    
729  sub pir_link {  sub pir_link {
730        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
731      my($cgi,$pir) = @_;      my($cgi,$pir) = @_;
732    
733      if ($pir =~ /^pirnr\|(NF\d+)$/)      if ($pir =~ /^pirnr\|(NF\d+)$/)
# Line 536  Line 737 
737      return $pir;      return $pir;
738  }  }
739    
740    sub kegg_link {
741        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
742        my($cgi,$kegg) = @_;
743    
744        if ($kegg =~ /^kegg\|([^:]+):(\S+)$/)
745        {
746            return "<a href=http://www.genome.ad.jp/dbget-bin/www_bget?$1+$2>$kegg</a>";
747        }
748        return $kegg;
749    }
750    
751    sub set_map_links {
752        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
753        my($cgi,$x) = @_;
754        my($before,$match,$after);
755    
756        my $org = ($cgi->param('org') || $cgi->param('genome') || "");
757    
758        if ($x =~ /^(.*)(MAP\d+)(.*)/s)
759        {
760            $before = $1;
761            $match = $2;
762            $after = $3;
763            return &set_map_links($cgi,$before) . &map_link($cgi,$match,$org) . &set_map_links($cgi,$after);
764        }
765        return $x;
766    }
767    
768    sub map_link {
769        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
770        my($cgi,$map,$org) = @_;
771    
772        $user = $cgi->param('user');
773        $user = $user ? $user : "";
774        $org = $org ? $org : "";
775        my $url = "$FIG_Config::cgi_url/show_kegg_map.cgi?user=$user&map=$map&org=$org";
776        my $link = "<a href=\"$url\">$map</a>";
777        return $link;
778    }
779    
780    sub javascript {
781        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
782            #### MODIFIED BY RAE TO ADD JAVA SUPPORT FOR CHECK ALL/UNCHECK ALL
783            # This routine takes three arguments, $html, $form, and $button
784            # $html is the ref to the array with the html in it
785            # $form is the name of the form. This must be added whenever start_form is called
786            # by including a -name entry. This is only used for the javascript
787            # $button is the name of the button that should be checked/unchecked.
788            #
789            # At the moment this add's four buttons:
790            # Check all, check's all
791            # Check first half will check the first 50% of the entries
792            # Check second half will check the second 50% of the entries
793            # Uncheck all will remove the checks.
794    
795            # Note that the other change is I added a -name=>'fig_checked' to the start_form
796            # field. The name is needed for the java script.
797            #
798    
799              $java_script=<<EOF;
800      <SCRIPT LANGUAGE="JavaScript">
801      <!-- Begin
802      function checkAll(field)
803      {
804       for (i = 0; i < field.length; i++)
805       field[i].checked = true ;
806      }
807    
808      function checkFirst(field)
809      {
810       for (i = 0; i < field.length/2; i++)
811       field[i].checked = true;
812      }
813    
814      function checkSecond(field)
815      {
816       for (i=Math.round(field.length/2); i < field.length; i++)
817       field[i].checked = true ;
818      }
819    
820      function uncheckAll(field)
821      {
822       for (i = 0; i < field.length; i++)
823       field[i].checked = false ;
824      }
825      //  End -->
826      </script>
827    EOF
828            return $java_script;
829    }
830    
831    sub java_buttons {
832        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
833      ## ADDED BY RAE
834      # Provides code to include check all/first half/second half/none for javascrspt
835      # this takes two variables - the form name provided in start_form with the
836      # -name => field and the checkbox name
837      my ($form, $button)=@_;
838    
839      $java_script="<input type=\"button\" name=\"CheckAll\" value=\"Check All\"\nonClick=\"checkAll(document.$form.$button)\">\n";
840      $java_script.="<input type=\"button\" name=\"CheckFirst\" value=\"Check First Half\"\nonClick=\"checkFirst(document.$form.$button)\">\n";
841      $java_script.="<input type=\"button\" name=\"CheckSecond\" value=\"Check Second Half\"\nonClick=\"checkSecond(document.$form.$button)\">\n";
842      $java_script.="<input type=\"button\" name=\"UnCheckAll\" value=\"Uncheck All\"\nonClick=\"uncheckAll(document.$form.$button)\">\n";
843    
844      return $java_script;
845    }
846    
847    sub sub_link {
848        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
849        my($cgi,$sub) = @_;
850        my($sub_link);
851    
852        my $user = $cgi->param('user');
853        if ($user)
854        {
855            $sub_link = "<a href=./subsys.cgi?ssa_name=$sub&request=show_ssa&user=$user>$sub</a>";
856        }
857        else
858        {
859            $sub_link = $sub;
860        }
861        return $sub_link;
862    }
863    
864  1  1

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.35

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3