--- loncom/interface/lonsearchcat.pm 2015/06/12 21:11:07 1.345 +++ loncom/interface/lonsearchcat.pm 2015/06/16 20:24:39 1.346 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.345 2015/06/12 21:11:07 damieng Exp $ +# $Id: lonsearchcat.pm,v 1.346 2015/06/16 20:24:39 damieng Exp $ # # Copyright Michigan State University Board of Trustees # @@ -144,7 +144,7 @@ sub handler { ## this once, so the pause indicator is deleted ## if (exists($env{'form.pause'})) { - Time::HiRes::sleep(0.1); + sleep(0.1); delete($env{'form.pause'}); } ## @@ -2051,19 +2051,7 @@ sub print_sort_form { &Apache::lonnet::logthis(&Apache::lonmysql::get_error()); return; } - # update results - my $newloc = '/adm/searchcat?phase=results&persistent_db_id='. - $env{'form.persistent_db_id'}; - my $js =< - var frame = parent.resultsframe; - var frameDoc = frame.document; - if (frameDoc.readyState == 'complete') - frame.location = "$newloc"; - -END - - my $start_page = &Apache::loncommon::start_page('Results',$js); + my $start_page = &Apache::loncommon::start_page('Results',undef); my $breadcrumbs= &Apache::lonhtmlcommon::breadcrumbs('Searching','Searching', $env{'form.catalogmode'} ne 'import'); @@ -2233,10 +2221,7 @@ sub reload_result_frame { $env{'form.persistent_db_id'}; $r->print(< - var frame = parent.resultsframe; - var frameDoc = frame.document; - if (frameDoc.readyState == 'complete') - frame.location = "$newloc"; + parent.update_results("$newloc"); SCRIPT @@ -2472,7 +2457,7 @@ END &update_status($r, &mt('waiting on [_1]',join(' ',keys(%Server_status)))); } - Time::HiRes::sleep(0.1); + sleep(0.1); } # # Loop through the servers we have contacted but do not @@ -3176,6 +3161,14 @@ SCRIPT SCRIPT + $js.=< + \$(document).ready(function() { + parent.done_loading_results(); + }); + +SCRIPT + my $start_page = &Apache::loncommon::start_page(undef,$js, {'only_body' =>1, 'add_wishlist' =>1, @@ -3206,10 +3199,28 @@ sub print_frames_interface { my $results_link = &results_link(); my $js = < -// + +var loading_results = true; +var need_reloading = false; +var new_location; +function update_results(newloc) { + if (loading_results) { + need_reloading = true; + new_location = newloc; + } else { + loading_results = true; + resultsframe.location = newloc; + } +} +function done_loading_results() { + loading_results = false; + if (need_reloading) { + need_reloading = false; + update_results(new_location); + } +} JS