[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonmenu.pm

raeburn raeburn at source.lon-capa.org
Sun Sep 21 21:33:17 EDT 2014


raeburn		Mon Sep 22 01:33:17 2014 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonmenu.pm 
  Log:
  - For 2.11
    - Backport 1.429
  
  
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.369.2.52 loncom/interface/lonmenu.pm:1.369.2.53
--- loncom/interface/lonmenu.pm:1.369.2.52	Sun Jun 22 19:48:05 2014
+++ loncom/interface/lonmenu.pm	Mon Sep 22 01:33:17 2014
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.369.2.52 2014/06/22 19:48:05 raeburn Exp $
+# $Id: lonmenu.pm,v 1.369.2.53 2014/09/22 01:33:17 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2017,8 +2017,26 @@
 
     my $countdown = &countdown_toggle_js();
 
+    my $hostvar = '
+function setLCHost() {
+    var lcHostname="";
+';
+    if ($httphost =~ m{^https?\://}) {
+        $hostvar .= '    var lcServer="'.$httphost.'";'."\n".
+                    '    var hostReg = /^https?:\/\/([^\/]+)$/i;'."\n".
+                    '    var match = hostReg.exec(lcServer);'."\n".
+                    '    if (match.length) {'."\n".
+                    '        if (match[1] == location.hostname) {'."\n".
+                    '            lcHostname=lcServer;'."\n".
+                    '        }'."\n".
+                    '    }'."\n";
+    }
+
+    $hostvar .= '    return lcHostname;'."\n".
+'}'."\n";
+
 return (<<ENDUTILITY)
-    var host="$httphost";
+    $hostvar
     var currentURL=unescape("$esc_url");
     var reloadURL=unescape("$esc_url");
     var currentSymb=unescape("$esc_symb");
@@ -2029,7 +2047,8 @@
    if (url!='' && url!= null) {
        currentURL = null;
        currentSymb= null;
-       window.location.href=host+url;
+       var lcHostname = setLCHost();
+       window.location.href=lcHostname+url;
    }
 }
 
@@ -2037,7 +2056,8 @@
 
 function gopost(url,postdata) {
    if (url!='') {
-      this.document.server.action=host+url;
+      var lcHostname = setLCHost();
+      this.document.server.action=lcHostname+url;
       this.document.server.postdata.value=postdata;
       this.document.server.command.value='';
       this.document.server.url.value='';
@@ -2048,7 +2068,8 @@
 
 function gocmd(url,cmd) {
    if (url!='') {
-      this.document.server.action=host+url;
+      var lcHostname = setLCHost();
+      this.document.server.action=lcHostname+url;
       this.document.server.postdata.value='';
       this.document.server.command.value=cmd;
       this.document.server.url.value=currentURL;
@@ -2100,7 +2121,8 @@
    if (url!='' && url!= null) {
        currentURL = null;
        currentSymb= null;
-       top.location.href=host+url;
+       var lcHostname = setLCHost();
+       top.location.href=lcHostname+url;
    }
 }
 
@@ -2115,11 +2137,13 @@
 }
 
 function chat_win() {
-   lonchat=window.open(host+'/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
+   var lcHostname = setLCHost();
+   lonchat=window.open(lcHostname+'/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
 }
 
 function group_chat(group) {
-   var url = host+'/adm/groupchat?group='+group;
+   var lcHostname = setLCHost();
+   var url = lcHostname+'/adm/groupchat?group='+group;
    var winName = 'LONchat_'+group;
    grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
 }
@@ -2139,12 +2163,13 @@
 
 function open_StoredLinks_Import(rat) {
    var newWin;
+   var lcHostname = setLCHost();
    if (rat) {
-       newWin = window.open(host+'/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
+       newWin = window.open(lcHostname+'/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
                             'wishlistImport','scrollbars=1,resizable=1,menubar=0');
    }
    else {
-       newWin = window.open(host+'/adm/wishlist?inhibitmenu=yes&mode=import',
+       newWin = window.open(lcHostname+'/adm/wishlist?inhibitmenu=yes&mode=import',
                             'wishlistImport','scrollbars=1,resizable=1,menubar=0');
    }
    newWin.focus();




More information about the LON-CAPA-cvs mailing list