--- loncom/interface/lonnavmaps.pm 2003/03/13 19:57:10 1.158 +++ loncom/interface/lonnavmaps.pm 2003/03/13 20:46:36 1.159 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.158 2003/03/13 19:57:10 bowersj2 Exp $ +# $Id: lonnavmaps.pm,v 1.159 2003/03/13 20:46:36 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -550,7 +550,7 @@ Most of these parameters are only useful =item * B: A flag. If yes (default), if all parts of the problem have the same status and that status is Nothing Set, Correct, or Network Failure, then only one line will be displayed for that resource anyhow. If no, all parts will always be displayed. If showParts is 0, this is ignored. -=item * B: A string identifying the URL to place the anchor 'curloc' at. Default to no anchor at all. It is the responsibility of the renderer user to ensure that the #curloc is in the URL. By default, determined through the use of the ENV{} 'jump' and 'jumpType' information. +=item * B: A string identifying the URL to place the anchor 'curloc' at. Default to no anchor at all. It is the responsibility of the renderer user to ensure that the #curloc is in the URL. By default, determined through the use of the ENV{} 'jump' information, and should normally "just work" correctly. =item * B: A Symb identifying where to place the 'here' marker. Default empty, which means no marker. @@ -651,7 +651,7 @@ sub render_resource { $linkopen .= "&condition=" . $it->{CONDITION} . '&hereType=' . $params->{'hereType'} . '&here=' . &Apache::lonnet::escape($params->{'here'}) . - '&jumpType=' . SYMB() . '&jump=' . + '&jump=' . &Apache::lonnet::escape($resource->symb()) . "&folderManip=1'>"; } else { @@ -839,12 +839,8 @@ sub render { my $r = $args->{'r'}; my $queryString = $args->{'queryString'}; - my $jumpToURL = $args->{'jumpToURL'}; - my $jumpToSymb = $args->{'jumpToSymb'}; - my $jumpType; + my $jump = $args->{'jump'}; my $here = $args->{'here'}; - my $jump; - my $currentJumpIndex = setDefault($args->{'currentJumpIndex'}, 0); my $suppressNavmap = setDefault($args->{'suppressNavmap'}, 0); my $currentJumpDelta = 2; # change this to change how many resources are displayed # before the current resource when using #current @@ -879,10 +875,6 @@ sub render { # Step two: Locate what kind of here marker is necessary # Determine where the "here" marker is and where the screen jumps to. - # We're coming from the remote. We have either a url, a symb, or nothing, - # and we need to figure out what. - # Preference: Symb - if ($ENV{'form.symb'}) { $here = $jump = $ENV{'form.symb'}; } elsif ($ENV{'form.postdata'}) { @@ -899,7 +891,6 @@ sub render { my $depth = 1; $mapIterator->next(); # discard the first BEGIN_MAP my $curRes = $mapIterator->next(); - my $counter = 0; my $found = 0; # We only need to do this if we need to open the maps to show the @@ -925,34 +916,8 @@ sub render { $curRes = $mapIterator->next(); } - - # Since we changed the folders, (re-)locate the jump point, if any - $mapIterator = $navmap->getIterator(undef, undef, $filterHash, 0); - $depth = 1; - $mapIterator->next(); - $curRes = $mapIterator->next(); - my $foundJump = 0; - - while ($depth > 0 && !$foundJump) { - if ($curRes == $mapIterator->BEGIN_MAP()) { $depth++; } - if ($curRes == $mapIterator->END_MAP()) { $depth--; } - if (ref($curRes)) { $counter++; } - - if (ref($curRes) && - (($jumpType == SYMB() && $curRes->symb() eq $jump) || - ($jumpType == URL() && $curRes->src() eq $jump))) { - - # This is why we have to use the main iterator instead of the - # potentially faster DFS: The count has to be the same, so - # the order has to be the same, which DFS won't give us. - $currentJumpIndex = $counter; - $foundJump = 1; - } - - $curRes = $mapIterator->next(); - } - } + if ( !defined($args->{'iterator'}) && $ENV{'form.folderManip'} ) { # we came from a user's manipulation of the nav page # If this is a click on a folder or something, we want to preserve the "here" # from the querystring, and get the new "jump" marker @@ -987,6 +952,31 @@ sub render { } } + # (re-)Locate the jump point, if any + my $mapIterator = $navmap->getIterator(undef, undef, $filterHash, 0); + my $depth = 1; + $mapIterator->next(); + my $curRes = $mapIterator->next(); + my $foundJump = 0; + my $counter = 0; + + while ($depth > 0 && !$foundJump) { + if ($curRes == $mapIterator->BEGIN_MAP()) { $depth++; } + if ($curRes == $mapIterator->END_MAP()) { $depth--; } + if (ref($curRes)) { $counter++; } + + if (ref($curRes) && $jump eq $curRes->symb()) { + + # This is why we have to use the main iterator instead of the + # potentially faster DFS: The count has to be the same, so + # the order has to be the same, which DFS won't give us. + $args->{'currentJumpIndex'} = $counter; + $foundJump = 1; + } + + $curRes = $mapIterator->next(); + } + my $showParts = setDefault($args->{'showParts'}, 1); my $condenseParts = setDefault($args->{'condenseParts'}, 1); # keeps track of when the current resource is found, @@ -1059,9 +1049,9 @@ sub render { my $displayedJumpMarker = 0; # Set up iteration. - my $depth = 1; + $depth = 1; $it->next(); # discard initial BEGIN_MAP - my $curRes = $it->next(); + $curRes = $it->next(); my $now = time(); my $in24Hours = $now + 24 * 60 * 60; my $rownum = 0; @@ -1218,8 +1208,14 @@ sub render { } # Print out the part that jumps to #curloc if it exists + # delay needed because the browser is processing the jump before + # it finishes rendering, so it goes to the wrong place! + # onload might be better, but this routine has no access to that. + # On mozilla, the 0-millisecond timeout seems to prevent this; + # it's quite likely this might fix other browsers, too, and + # certainly won't hurt anything. if ($displayedJumpMarker) { - $result .= "\n"; + $result .= "\n"; } $result .= "";