[LON-CAPA-cvs] cvs: loncom /interface lonsearchcat.pm /lonnet/perl lonnet.pm

damieng damieng at source.lon-capa.org
Tue Jun 16 16:25:00 EDT 2015


damieng		Tue Jun 16 20:25:00 2015 EDT

  Modified files:              
    /loncom/interface	lonsearchcat.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  further bug fixes, optimizations and cleanup for searches
  
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.345 loncom/interface/lonsearchcat.pm:1.346
--- loncom/interface/lonsearchcat.pm:1.345	Fri Jun 12 21:11:07 2015
+++ loncom/interface/lonsearchcat.pm	Tue Jun 16 20:24:39 2015
@@ -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 @@
     ##     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 @@
         &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 =<<END;
-<script type="text/javascript">
-    var frame = parent.resultsframe;
-    var frameDoc = frame.document;
-    if (frameDoc.readyState  == 'complete')
-        frame.location = "$newloc";
-</script>
-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 @@
         $env{'form.persistent_db_id'};
     $r->print(<<SCRIPT);
 <script type="text/javascript">
-    var frame = parent.resultsframe;
-    var frameDoc = frame.document;
-    if (frameDoc.readyState  == 'complete')
-        frame.location = "$newloc";
+    parent.update_results("$newloc");
 </script>
 SCRIPT
 
@@ -2472,7 +2457,7 @@
                 &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.=<<SCRIPT;
+<script type="text/javascript">
+    \$(document).ready(function() {
+        parent.done_loading_results();
+    });
+</script>
+SCRIPT
+
     my $start_page  = &Apache::loncommon::start_page(undef,$js,
 						     {'only_body' =>1,
                                                       'add_wishlist' =>1,
@@ -3206,10 +3199,28 @@
     my $results_link = &results_link();
     my $js = <<JS;
 <script type="text/javascript">
-// <![CDATA[
 var targetwin = opener;
 var queue = '';
-// ]]>
+
+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);
+    }
+}
 </script>
 JS
 
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1288 loncom/lonnet/perl/lonnet.pm:1.1289
--- loncom/lonnet/perl/lonnet.pm:1.1288	Fri Jun 12 21:11:20 2015
+++ loncom/lonnet/perl/lonnet.pm	Tue Jun 16 20:24:59 2015
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1288 2015/06/12 21:11:20 damieng Exp $
+# $Id: lonnet.pm,v 1.1289 2015/06/16 20:24:59 damieng Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -92,7 +92,7 @@
 use HTML::LCParser;
 use Fcntl qw(:flock);
 use Storable qw(thaw nfreeze);
-use Time::HiRes qw( gettimeofday tv_interval );
+use Time::HiRes qw( sleep gettimeofday tv_interval );
 use Cache::Memcached;
 use Digest::MD5;
 use Math::Random;
@@ -101,7 +101,6 @@
 use LONCAPA::Configuration;
 use LONCAPA::lonmetadata;
 use LONCAPA::Lond;
-use Time::HiRes qw(sleep);
 
 use File::Copy;
 
@@ -376,7 +375,7 @@
 
     my $lockfile=$peerfile.".lock";
     while (-e $lockfile) {	# Need to wait for the lockfile to disappear.
-	Time::HiRes::sleep(0.1);
+	sleep(0.1);
     }
     # At this point, either a loncnew parent is listening or an old lonc
     # or loncnew child is listening so we can connect or everything's dead.
@@ -394,7 +393,7 @@
 	} else {
 	    &create_connection(&hostname($server),$server);
 	}
-        Time::HiRes::sleep(0.1);	# Try again later if failed connection.
+        sleep(0.1);	# Try again later if failed connection.
     }
     my $answer;
     if ($client) {
@@ -7679,7 +7678,7 @@
     my $replyfile=LONCAPA::tempdir().$queryid;
     my $reply='';
     for (1..100) {
-	Time::HiRes::sleep(0.2);
+	sleep(0.2);
         if (-e $replyfile.'.end') {
 	    if (open(my $fh,$replyfile)) {
 		$reply = join('',<$fh>);
@@ -9524,7 +9523,7 @@
    
     while (($gotlock ne 'ok') && $tries < 10) {
         $tries ++;
-        Time::HiRes::sleep(0.1);
+        sleep(0.1);
         $gotlock = &newput('file_permissions',$lockhash,$domain,$user);
     }
     if ($gotlock eq 'ok') {




More information about the LON-CAPA-cvs mailing list