--- loncom/interface/lonmenu.pm 2002/12/06 17:49:49 1.29 +++ loncom/interface/lonmenu.pm 2003/02/13 15:52:53 1.33 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.29 2002/12/06 17:49:49 matthew Exp $ +# $Id: lonmenu.pm,v 1.33 2003/02/13 15:52:53 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,13 +36,74 @@ package Apache::lonmenu; use strict; use Apache::lonnet; +use Apache::Constants qw(:common); +use Apache::loncommon; use Apache::File; use vars qw(@desklines $readdesk); - + +# ============================================================= Start up remote + +sub startupremote { + my ($lowerurl)=@_; + my $configmenu=&rawconfig(); + return(< + +// ---------------------------------------------------------- The wait function +var canceltim; +function wait() { + if ((menuloaded==1) || (tim==1)) { + if (tim==0) { + clearTimeout(canceltim); + $configmenu + window.location='$lowerurl'; + } else { + alert("Remote Control Timed Out."); + } + } else { + setTimeout('wait();',100); + } +} + +function main() { + canceltim=setTimeout('tim=1;',80000); + wait(); +} + + +ENDREMOTESTARTUP +} + +sub setflags() { + return(< + menuloaded=0; + tim=0; + +ENDSETFLAGS +} + +sub maincall() { + return(< + main(); + +ENDMAINCALL +} +# ================================================================= Reopen menu + +sub reopenmenu { + my $nothing=''; + my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; + if ($ENV{'browser.type'} eq 'explorer') { $nothing='javascript:void(0);'; } + return('window.open("'.$nothing.'","'.$menuname.'","",false);'); +} + # =============================================================== Open the menu sub open { my $returnval=''; + my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; unless (shift eq 'unix') { # resizing does not work on linux because of virtual desktop sizes $returnval.=(<'.$returnval.''; @@ -104,15 +165,15 @@ sub secondlevel { } sub openmenu { + my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; if ($ENV{'browser.type'} eq 'explorer') { - return "window.open('javascript:void(0);','LONCAPAmenu');"; + return "window.open('javascript:void(0);','".$menuname."');"; } else { - return "window.open('','LONCAPAmenu');"; + return "window.open('','".$menuname."');"; } } sub rawconfig { - my $r = shift; my $output="var swmenu=".&openmenu(); my $uname=$ENV{'user.name'}; my $udom=$ENV{'user.domain'}; @@ -172,7 +233,7 @@ sub rawconfig { } $act =~ s/\$caname/$caname/g; my $home = &Apache::lonnet::homeserver($caname,$cadom); - if ($home eq $r->dir_config('lonHostID')) { + if ($home eq $Apache::lonnet::perlvar{'lonHostID'}) { $output.=switch($caname,$cadom, $row,$col,$img,$top,$bot,$act,$desc); } @@ -187,10 +248,12 @@ sub rawconfig { # ======================================================================= Close sub close { + my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; return(< -menu=window.open("/adm/rat/empty.html","LONCAPAmenu", +menu=window.open("/adm/rat/empty.html","$menuname", "height=350,width=150,scrollbars=no,menubar=no"); +menu.autologout=0; menu.close(); ENDCLOSE @@ -202,6 +265,23 @@ sub footer { } +# ================================================ Handler when called directly + + +sub handler { + my $r = shift; + $r->content_type('text/html'); + $r->send_http_header; + return OK if $r->header_only; + +# ------------------------------------------------------------ Print the screen + $r->print('LON-CAPA Main Menu'); + $r->print(''); + $r->print('

LON-CAPA Main Menu

'); + $r->print(''); + return OK; +} + # ================================================================ Main Program BEGIN { @@ -221,6 +301,7 @@ BEGIN { $readdesk='done'; } } + 1; __END__