[LON-CAPA-cvs] cvs: loncom /interface lonhtmlcommon.pm /xml scripttag.pm

www lon-capa-cvs@mail.lon-capa.org
Wed, 29 Sep 2004 14:50:43 -0000


www		Wed Sep 29 10:50:43 2004 EDT

  Modified files:              
    /loncom/interface	lonhtmlcommon.pm 
    /loncom/xml	scripttag.pm 
  Log:
  Work-around for Safari bug regarding 'document.open', Bug #3449
  
  
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.89 loncom/interface/lonhtmlcommon.pm:1.90
--- loncom/interface/lonhtmlcommon.pm:1.89	Fri Sep 10 13:58:01 2004
+++ loncom/interface/lonhtmlcommon.pm	Wed Sep 29 10:50:43 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.89 2004/09/10 17:58:01 banghart Exp $
+# $Id: lonhtmlcommon.pm,v 1.90 2004/09/29 14:50:43 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -525,6 +525,27 @@
     return $nothing;
 }
 
+##############################################
+##############################################
+sub javascript_docopen {
+    # safari does not understand document.open() and loads "text/html"
+    my $nothing = "''";
+    my $user_browser;
+    my $user_os;
+    $user_browser = $ENV{'browser.type'} if (exists($ENV{'browser.type'}));
+    $user_os      = $ENV{'browser.os'}   if (exists($ENV{'browser.os'}));
+    if (! defined($user_browser) || ! defined($user_os)) {
+        (undef,$user_browser,undef,undef,undef,$user_os) = 
+                           &Apache::loncommon::decode_user_agent();
+    }
+    if ($user_browser eq 'safari' && $user_os =~ 'mac') {
+        $nothing = "document.clear()";
+    } else {
+	$nothing = "document.open('text/html','replace')";
+    }
+    return $nothing;
+}
+
 
 ##############################################
 ##############################################
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.117 loncom/xml/scripttag.pm:1.118
--- loncom/xml/scripttag.pm:1.117	Tue Sep 28 16:40:05 2004
+++ loncom/xml/scripttag.pm	Wed Sep 29 10:50:43 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # <script> definiton
 #
-# $Id: scripttag.pm,v 1.117 2004/09/28 20:40:05 www Exp $
+# $Id: scripttag.pm,v 1.118 2004/09/29 14:50:43 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -117,7 +117,8 @@
 	    ($Apache::lonhomework::viewgrades == 'F')) {
 	    $Apache::lonxml::evaluate--;
 	    my (undef,undef,$udom,$uname)=&Apache::lonxml::whichuser();
-	    $result.="<script type=\"text/javascript\"> function LONCAPA_scriptvars_".$uname."_".$udom."_"."$Apache::lonxml::curdepth() {newWindow=open('','new_W','width=500,height=500,scrollbars=1,resizable=yes');newWindow.document.open('text/html','replace');newWindow.document.writeln('<html><head><title>Script Vars</title></head><body bgcolor=\"#FFFFFF\"><pre>";
+	    my $windowopen=&Apache::lonhtmlcommon::javascript_docopen();
+	    $result.="<script type=\"text/javascript\"> function LONCAPA_scriptvars_".$uname."_".$udom."_"."$Apache::lonxml::curdepth() {newWindow=open('','new_W','width=500,height=500,scrollbars=1,resizable=yes');newWindow.$windowopen;newWindow.document.writeln('<html><head><title>Script Vars</title></head><body bgcolor=\"#FFFFFF\"><pre>";
 	    my $listing=&Apache::run::dump($target,$safeeval);
 	    $listing=~s/\'/\\\'/g;
 	    $listing=~s/\n/\\n/g;