[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.37, Tue Mar 15 22:29:27 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        # RAE the chomp will return any new lines at the ends of elements in the array, and then we can join  with a "\n"
378        # this is because somethings put newlines in, and others don't. This should make nicer looking html
379        #chomp(@$html);
380        #print join "\n", @$html;
381    
382        # Apparently the above still breaks things. This is the correct code:
383      print @$html;      print @$html;
384  }  }
385    
386  sub make_table {  sub make_table {
387      my($col_hdrs,$tab,$title,$instr) = @_;      my($col_hdrs,$tab,$title, %options ) = @_;
388      my(@tab);      my(@tab);
389    
390      push( @tab, "\n<table border>\n",      my $border = defined $options{border} ? "border=\"$options{border}\"" : "border";
391        push( @tab, "\n<table $border>\n",
392                  "\t<caption><b>$title</b></caption>\n",                  "\t<caption><b>$title</b></caption>\n",
393                  "\t<tr>\n\t\t<th>"                  "\t<tr>\n\t\t"
394                . join( "</th>\n\t\t<th>", @$col_hdrs )                . join( "\n", map { &expand($_, "th") } @$col_hdrs )
395                . "</th>\n\t</tr>\n"                . "\n\t</tr>\n"
396          );          );
397      my($i,$nowrap);      my($i);
   
     for ($i=0; ($i < @$instr) && ($instr->[$i] !~ /nowrap/); $i++) {}  
     $nowrap = ($i == @$instr) ? "" : " nowrap";  
398    
399      my $row;      my $row;
400      foreach $row (@$tab)      foreach $row (@$tab)
401      {      {
402          push( @tab, "\t<tr>\n"          push( @tab, "\t<tr>\n"
403                    . join( "\n", map { &expand($_,$nowrap) } @$row )                    . join( "\n", map { &expand($_) } @$row )
404                    . "\n\t</tr>\n"                    . "\n\t</tr>\n"
405              );              );
406      }      }
# Line 286  Line 409 
409  }  }
410    
411  sub expand {  sub expand {
412      my($x,$nowrap) = @_;      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
413        my($x, $tag) = @_;
414    
415        $tag = "td" unless $tag;
416        my $endtag=$tag;
417        # RAE modified this so that you can pass in a reference to an array where the first element is the data to
418        # display and the second element is optional things like colspan and align. Note that in this case you need to include the td
419        # use something like ["some data to appear", "td colspan=4 bgcolor=gray"]
420        if (ref($x) eq "ARRAY") {($x, $tag)=@$x; if ($tag =~ /td/) {$endtag = "td"}}
421    
422      if ($x =~ /^\@([^:]+)\:([^:]+)\:(.*)$/)      if ($x =~ /^\@([^:]+)\:(.*)$/)
423      {      {
424          return "\t\t<td$nowrap $1=\"$2\">$3</td>";          return "\t\t<$tag $1>$2</$endtag>";
425      }      }
426      else      else
427      {      {
428          return "\t\t<td$nowrap>$x</td>";          return "\t\t<$tag>$x</$endtag>";
429      }      }
430  }  }
431    
432    sub set_ec_links {
433        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
434        my($cgi,$x) = @_;
435        my($before,$match,$after);
436    
437        if ($x =~ /^(.*)(EC \d+\.\d+\.\d+\.\d+)(.*)/s)
438        {
439            $before = $1;
440            $match = $2;
441            $after = $3;
442            return &set_ec_links($cgi,$before) . &HTML::ec_link($match) . &set_ec_links($cgi,$after);
443        }
444        return $x;
445    }
446    
447  sub ec_link {  sub ec_link {
448        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
449      my($role) = @_;      my($role) = @_;
450    
451      if ($role =~ /(\d+\.\d+\.\d+\.\d+)/)      if ($role =~ /(\d+\.\d+\.\d+\.\d+)/)
# Line 312  Line 459 
459  }  }
460    
461  sub role_link {  sub role_link {
462        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
463      my($cgi,$role) = @_;      my($cgi,$role) = @_;
464    
465      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 470 
470      return "<a href=$link>$role</a>";      return "<a href=$link>$role</a>";
471  }  }
472    
473    #
474    # Local means to eliminate the fig|org.peg from the
475    # text of the link.
476    #
477  sub fid_link {  sub fid_link {
478        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
479      my($cgi,$fid,$local,$just_url) = @_;      my($cgi,$fid,$local,$just_url) = @_;
480      my($n);      my($n);
481    
# Line 347  Line 500 
500          my $user = $cgi->param('user');          my $user = $cgi->param('user');
501          if (! $user) { $user = "" }          if (! $user) { $user = "" }
502          my $trans = $cgi->param('translate') ? "&translate=1" : "";          my $trans = $cgi->param('translate') ? "&translate=1" : "";
503          my $link = $cgi->url() . "?prot=$fid&user=$user$trans";          my $sprout = $cgi->param('SPROUT') ? "&SPROUT=1" : "";
504          $link =~ s/[a-z_A-Z]+\.cgi\?/protein.cgi?/;          my $link = &FIG::cgi_url . "/protein.cgi?prot=$fid&user=$user$trans$sprout";
505            $link =~ s/[a-z_A-Z0-9]+\.cgi\?/protein.cgi?/;
506            #
507            # Elimin the p2p part if we're in that subdir. Ugh.
508            #
509            $link =~ s,p2p/protein.cgi,protein.cgi,;
510    
511          if ($just_url)          if ($just_url)
512          {          {
513              return $link;              return $link;
# Line 362  Line 521 
521  }  }
522    
523  sub family_link {  sub family_link {
524        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
525      my($family,$user) = @_;      my($family,$user) = @_;
526    
527      return $family;      return $family;
# Line 370  Line 530 
530  use URI::Escape;  use URI::Escape;
531    
532  sub get_html {  sub get_html {
533        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
534      my( $url, $type, $kv_pairs) = @_;      my( $url, $type, $kv_pairs) = @_;
535      my( $encoded, $ua, $args, @args, $out, @output, $x );      my( $encoded, $ua, $args, @args, $out, @output, $x );
536    
537      $ua = new LWP::UserAgent;      $ua = new LWP::UserAgent;
538      $ua->timeout( 900 );      $ua->timeout( 900 );
   
539      if ($type =~/post/i)      if ($type =~/post/i)
540      {      {
541          $args = [];          $args = [];
# Line 435  Line 595 
595  }  }
596    
597  sub trim_output {  sub trim_output {
598        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
599      my($out) = @_;      my($out) = @_;
600      my $i;      my $i;
601    
# Line 472  Line 633 
633  }  }
634    
635  sub set_prot_links {  sub set_prot_links {
636        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
637      my($cgi,$x) = @_;      my($cgi,$x) = @_;
638      my($before,$match,$after);      my($before,$match,$after);
639    
640      if ($x =~ /^(.*)(fig\|\d+\.\d+\.peg\.\d+)(.*)$/)      if ($x =~ /^(.*)(fig\|\d+\.\d+\.peg\.\d+)(.*)/s)
641        {
642            $before = $1;
643            $match = $2;
644            $after = $3;
645            return &set_prot_links($cgi,$before) . &HTML::fid_link($cgi,$match) . &set_prot_links($cgi,$after);
646        }
647        elsif ($x =~ /^(.*)\b([NXYZA]P_[0-9\.]+)\b(.*)/s)
648        {
649            $before = $1;
650            $match = $2;
651            $after = $3;
652            return &set_prot_links($cgi,$before) . &HTML::refseq_link($cgi,$match) . &set_prot_links($cgi,$after);
653        }
654        elsif ($x =~ /^(.*)(gi\|\d+)(.*)/s)
655        {
656            $before = $1;
657            $match = $2;
658            $after = $3;
659            return &set_prot_links($cgi,$before) . &HTML::gi_link($cgi,$match) . &set_prot_links($cgi,$after);
660        }
661        elsif ($x =~  /^(.*)(uni\|[A-Z0-9]{6})(.*)/s)
662      {      {
663          $before = $1;          $before = $1;
664          $match = $2;          $match = $2;
665          $after = $3;          $after = $3;
666          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);
667      }      }
668      elsif ($x =~ /^(.*)(gi\|\d+)(.*)$/)      elsif ($x =~ /^(.*)(sp\|[A-Z0-9]{6})(.*)/s)
669      {      {
670          $before = $1;          $before = $1;
671          $match = $2;          $match = $2;
672          $after = $3;          $after = $3;
673          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);
674      }      }
675      elsif ($x =~ /^(.*)(sp\|[A-Z0-9]{6})(.*)$/)      elsif ($x =~ /^(.*)(pirnr\|NF\d+)(.*)/s)
676      {      {
677          $before = $1;          $before = $1;
678          $match = $2;          $match = $2;
679          $after = $3;          $after = $3;
680          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);
681      }      }
682      elsif ($x =~ /^(.*)(pirnr\|NF\d+)(.*)$/)      elsif ($x =~ /^(.*)(kegg\|[a-z]{2,4}:[a-zA-Z_0-9]+)(.*)/s)
683      {      {
684          $before = $1;          $before = $1;
685          $match = $2;          $match = $2;
686          $after = $3;          $after = $3;
687          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);
688      }      }
689      return $x;      return $x;
690  }  }
691    
692    sub refseq_link {
693        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
694        my($cgi,$id) = @_;
695    
696        if ($id =~ /^[NXYZA]P_/)
697        {
698            return "<a href=http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=protein&cmd=search&term=$id>$id</a>";
699        }
700    }
701    
702  sub gi_link {  sub gi_link {
703        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
704      my($cgi,$gi) = @_;      my($cgi,$gi) = @_;
705    
706      if ($gi =~ /^gi\|(\d+)$/)      if ($gi =~ /^gi\|(\d+)$/)
# Line 516  Line 710 
710      return $gi;      return $gi;
711  }  }
712    
713    sub uni_link {
714        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
715        my($cgi,$uni) = @_;
716    
717        if ($uni =~ /^uni\|(\S+)$/)
718        {
719            return "<a href=http://www.pir.uniprot.org/cgi-bin/upEntry?id=$1>$uni</a>";
720        }
721        return $uni;
722    }
723    
724  sub sp_link {  sub sp_link {
725        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
726      my($cgi,$sp) = @_;      my($cgi,$sp) = @_;
727    
728      if ($sp =~ /^sp\|(\S+)$/)      if ($sp =~ /^sp\|(\S+)$/)
# Line 527  Line 733 
733  }  }
734    
735  sub pir_link {  sub pir_link {
736        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
737      my($cgi,$pir) = @_;      my($cgi,$pir) = @_;
738    
739      if ($pir =~ /^pirnr\|(NF\d+)$/)      if ($pir =~ /^pirnr\|(NF\d+)$/)
# Line 536  Line 743 
743      return $pir;      return $pir;
744  }  }
745    
746    sub kegg_link {
747        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
748        my($cgi,$kegg) = @_;
749    
750        if ($kegg =~ /^kegg\|([^:]+):(\S+)$/)
751        {
752            return "<a href=http://www.genome.ad.jp/dbget-bin/www_bget?$1+$2>$kegg</a>";
753        }
754        return $kegg;
755    }
756    
757    sub set_map_links {
758        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
759        my($cgi,$x) = @_;
760        my($before,$match,$after);
761    
762        my $org = ($cgi->param('org') || $cgi->param('genome') || "");
763    
764        if ($x =~ /^(.*)(MAP\d+)(.*)/s)
765        {
766            $before = $1;
767            $match = $2;
768            $after = $3;
769            return &set_map_links($cgi,$before) . &map_link($cgi,$match,$org) . &set_map_links($cgi,$after);
770        }
771        return $x;
772    }
773    
774    sub map_link {
775        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
776        my($cgi,$map,$org) = @_;
777    
778        $user = $cgi->param('user');
779        $user = $user ? $user : "";
780        $org = $org ? $org : "";
781        my $url = "$FIG_Config::cgi_url/show_kegg_map.cgi?user=$user&map=$map&org=$org";
782        my $link = "<a href=\"$url\">$map</a>";
783        return $link;
784    }
785    
786    sub javascript {
787        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
788            #### MODIFIED BY RAE TO ADD JAVA SUPPORT FOR CHECK ALL/UNCHECK ALL
789            # This routine takes three arguments, $html, $form, and $button
790            # $html is the ref to the array with the html in it
791            # $form is the name of the form. This must be added whenever start_form is called
792            # by including a -name entry. This is only used for the javascript
793            # $button is the name of the button that should be checked/unchecked.
794            #
795            # At the moment this add's four buttons:
796            # Check all, check's all
797            # Check first half will check the first 50% of the entries
798            # Check second half will check the second 50% of the entries
799            # Uncheck all will remove the checks.
800    
801            # Note that the other change is I added a -name=>'fig_checked' to the start_form
802            # field. The name is needed for the java script.
803            #
804    
805              $java_script=<<EOF;
806      <SCRIPT LANGUAGE="JavaScript">
807      <!-- Begin
808      function checkAll(field)
809      {
810       for (i = 0; i < field.length; i++)
811       field[i].checked = true ;
812      }
813    
814      function checkFirst(field)
815      {
816       for (i = 0; i < field.length/2; i++)
817       field[i].checked = true;
818      }
819    
820      function checkSecond(field)
821      {
822       for (i=Math.round(field.length/2); i < field.length; i++)
823       field[i].checked = true ;
824      }
825    
826      function uncheckAll(field)
827      {
828       for (i = 0; i < field.length; i++)
829       field[i].checked = false ;
830      }
831      //  End -->
832      </script>
833    EOF
834            return $java_script;
835    }
836    
837    sub java_buttons {
838        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
839      ## ADDED BY RAE
840      # Provides code to include check all/first half/second half/none for javascrspt
841      # this takes two variables - the form name provided in start_form with the
842      # -name => field and the checkbox name
843      my ($form, $button)=@_;
844    
845      $java_script="<input type=\"button\" name=\"CheckAll\" value=\"Check All\"\nonClick=\"checkAll(document.$form.$button)\">\n";
846      $java_script.="<input type=\"button\" name=\"CheckFirst\" value=\"Check First Half\"\nonClick=\"checkFirst(document.$form.$button)\">\n";
847      $java_script.="<input type=\"button\" name=\"CheckSecond\" value=\"Check Second Half\"\nonClick=\"checkSecond(document.$form.$button)\">\n";
848      $java_script.="<input type=\"button\" name=\"UnCheckAll\" value=\"Uncheck All\"\nonClick=\"uncheckAll(document.$form.$button)\">\n";
849    
850      return $java_script;
851    }
852    
853    sub sub_link {
854        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
855        my($cgi,$sub) = @_;
856        my($sub_link);
857    
858        my $user = $cgi->param('user');
859        if ($user)
860        {
861            $sub_link = "<a href=./subsys.cgi?ssa_name=$sub&request=show_ssa&user=$user>$sub</a>";
862        }
863        else
864        {
865            $sub_link = $sub;
866        }
867        return $sub_link;
868    }
869    
870  1  1

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3