File:  [LON-CAPA] / loncom / html / res / adm / pages / menu.html
Revision 1.97: download - view: text, annotated - select for diffs
Fri May 23 13:56:39 2003 UTC (21 years, 7 months ago) by www
Branches: MAIN
CVS tags: HEAD
Attempt to fix quadruplicate bug 1178: when using browser URL field of
main content window to go to an external site, JavaScript security model
disconnects all access the Remote could have to it, including the one to
even find out if it has access.

Implemented flag "noclient" in the Remote which gets set in an unLoad event of
the main window (ignoring the fact that unLoad is kaputt in some browser
versions).

This all seems to work great on Mozilla, but I am sure there will be stupid
side effects in some odd scenarios.

<html>
<!--
The LearningOnline Network with CAPA
Remote Control

//
// $Id: menu.html,v 1.97 2003/05/23 13:56:39 www Exp $
//
// Copyright Michigan State University Board of Trustees
//
// This file is part of the LearningOnline Network with CAPA (LON-CAPA).
//
// LON-CAPA is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// LON-CAPA is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with LON-CAPA; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// /home/httpd/html/adm/gpl.txt
//
// http://www.lon-capa.org/
//

-->
<head>
<title>LON-CAPA Remote</title>
</head>

<body bgcolor="#BBBBBB" 
      background="remotebg.gif"
      onUnload="collapse();"
      onLoad="activate();"
      >
<LONCAPA_INTERNAL_LONHTTPD_PORT />
<script type="text/javascript">
<!--
var statustop = '';
var statusbot = '';
var active = 0;
var dislocked = 1;
var statuslocked = 0;

if (lonhttpdport == null) {
    var lonhttpdport='8080';
}
var imgpath=':'+lonhttpdport+'/res/adm/pages/';
var fontpath=':'+lonhttpdport+'/adm/lonLCDfont/';
var currentURL='';
var reloadURL='';
var currentSymb='';
var reloadSymb='';
var currentStale=1;
var menucltim;
var noclient=1;

var clockdelta=0;

var w_extdisp_flag=-1;
var extdisp=null;

var autologout=1;

// not used (yet)
// var w_Annotator;
// var w_bmquery;
// var w_BookmarkPal;
// var w_LONcatInfo;

//////////////////////////////////////
var w_Annotator_flag=-1;
var w_bmquery_flag=-1;
var w_BookmarkPal_flag=-1;
var w_LONcatInfo_flag=-1;
var w_LONchat_flag=-1;
 // 1 means currently open
 // 0 means closed (but has been open)
 // -1 means never yet opened/defined
///////////////////////////////////////

var hr = new Array;
var db = new Array;
var dt = new Array;
var ds = new Array;

for (var i=1;i<=3;i++) {
   for (var j=1;j<=10;j++) {
      var index = 10*j+i;
      hr[index]='';
      db[index]='';
      dt[index]='';
      ds[index]='';
   }
}

var clienthost=window.location.host;
var clientwindow=opener;

function syncclock(servertime) {
    var clientclock=new Date;
    clockdelta=servertime-clientclock.getTime();
}

function advanceclock() {
    var clock=new Date();
    clock.setTime(clock.getTime()+clockdelta);
    if (!statuslocked) {
       var days=""+clock.getDate();
       if (days.length<2) { days="0"+days; }
       var mons=""+(clock.getMonth()+1);
       if (mons.length<2) { mons="0"+mons; }
       var years=""+clock.getYear();

       if (years>1000) {
          years=years.substring(2,4);
       } else {
          years=years.substring(1,3);
       }
       statustop=mons+'/'+days+'/'+years;

       var secs=""+clock.getSeconds();
       if (secs.length<2) { secs="0"+secs; }
       var mins=""+clock.getMinutes();
       if (mins.length<2) { mins="0"+mins; }
       var hours=""+clock.getHours();
       if (hours.length<2) { hours=" "+hours; }
       statusbot=hours+':'+mins+':'+secs;

       if (!dislocked) { showdisplay(); }
    }
    setTimeout('advanceclock();',1000);
}

function windowcheck() {
   if (noclient || (clientwindow==null || clientwindow.closed)) {
      clientwindow=window.open("http://"+clienthost+"/",'',
      "height=400,width=440,"+
      "scrollbars=1,toolbar=1,status=1,resizable=1,location=1,"+
      "left=190,top=15,screenX=190,screenY=15"); 
   }
   clientwindow.name='loncapaclient';
   clientwindow.menuwindow=self;
   noclient=0;
   extenddispclose();
}

function collapse() {
   if (autologout) {
       go('/adm/remote?action=collapse');
   }
}
 
function logout () {
   windowcheck();

      if (w_Annotator_flag!=-1 && annotator && !annotator.closed) {
          annotator.close();
      }
      if (w_bmquery_flag!=-1 && bmquery && !bmquery.closed) {
          bmquery.close();
      }
      if (w_BookmarkPal_flag!=-1 && bookmarkpal && !bookmarkpal.closed) {
          bookmarkpal.close();
      }
      if (w_LONcatInfo_flag!=-1 && loncatinfo && !loncatinfo.closed) {
          loncatinfo.close();
      }
      if (w_LONchat_flag!=-1 && lonchat && !lonchat.closed) {
          lonchat.close();
      }
      if (autologout) {
         clientwindow.window.location.href="http://"+clienthost+"/adm/logout";
      }
}

function activate () {
   setTimeout('opener.menuloaded=1;',1000);
   setTimeout('active=1;',500);
   advanceclock();
}

function deactivate () {
   active=0;
}

function display(utext,ltext) {
    this.window.focus();
    showdisplay(utext,ltext);
}

function showdisplay(utext,ltext) {
  var i; var ch;
  dislocked=1;
  if (utext == null) { utext = '';}
  if (ltext == null) { ltext = '';}
  if (typeof(utext)!="string") { utext=''; }
  if (typeof(ltext)!="string") { ltext=''; }
  if ((utext=='') && (ltext=='')) {
     utext=statustop;
     ltext=statusbot;
     dislocked=0;
  }
  if (active) { 
   for (i=0;i<=7;i++) {
      if (i<utext.length) {
         ch=utext.charAt(i);
         if (ch==' ') { ch='space'; }
         if (ch=='-') { ch='hyphen'; }
         if (ch==':') { ch='colon'; }
         if (ch=='/') { ch='slash'; }
      } else { ch='space'; }
      this.document['i'+i].src="http://"+clienthost+fontpath+ch+'.gif';
   }
   for (i=0;i<=7;i++) {
      if (i<ltext.length) {
         ch=ltext.charAt(i);
         if (ch==' ') { ch='space'; }
         if (ch=='-') { ch='hyphen'; }
         if (ch==':') { ch='colon'; }
         if (ch=='/') { ch='slash'; }
      } else { ch='space'; }
      this.document['j'+i].src="http://"+clienthost+fontpath+ch+'.gif';
   }
  }
}

function defdis() {
   this.window.focus();
   display();
}

function switchbutton(row,col,imgsrc,texttop,textbot,action,desc) {
   var idx=10*row+col;
   this.document['b'+idx].src="http://"+clienthost+imgpath+imgsrc;
   hr[idx]=action;
   dt[idx]=texttop;
   db[idx]=textbot;
   ds[idx]=desc;
   for (var k=0;k<document.links.length;k++) {
       if (document.links[k].name=='link'+idx) {
          document.links[k].title=desc;
       }
   }
} 

function clearbut(row,col) {
   var idx=10*row+col;
   this.document['b'+idx].src="http://"+clienthost+imgpath+'empty.gif';
   hr[idx]='javascript:defdis();';
   dt[idx]='';
   db[idx]='';
   ds[idx]='';
   for (var k=0;k<document.links.length;k++) {
       if (document.links[k].name=='link'+idx) {
          document.links[k].title='';
       }
   }
}

function setstatus(tp,bt) {
   this.document['led'].src="http://"+clienthost+imgpath+"ledblink.gif";
   statustop=tp;
   statusbot=bt;
   statuslocked=1;
   defdis();
}

function go(url) {
   windowcheck();
   statuslocked=0;
   this.document['led'].src="http://"+clienthost+imgpath+"ledsend.gif";
   if (url!='' && url!= null) {
       currentURL = null;
       currentSymb= null;
       clientwindow.window.location.href="http://"+clienthost+url;
   }
}

function gopost(url,postdata) {
   windowcheck();
   statuslocked=0;
   this.document['led'].src="http://"+clienthost+imgpath+"ledsend.gif";
   if (url!='') {
      this.document.server.action="http://"+clienthost+url;
      this.document.server.postdata.value=postdata;
      this.document.server.command.value='';
      this.document.server.url.value='';
      this.document.server.postsymb.value='';
      this.document.server.submit();
   }
}

function gocmd(url,cmd) {
   windowcheck();
   statuslocked=0;
   this.document['led'].src="http://"+clienthost+imgpath+"ledsend.gif";
   if (url!='') {
      this.document.server.action="http://"+clienthost+url;
      this.document.server.postdata.value='';
      this.document.server.command.value=cmd;
      this.document.server.url.value=currentURL;
      this.document.server.postsymb.value=currentSymb;
      this.document.server.submit();
   }
}

function annotate() {
   w_Annotator_flag=1;
   annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
   annotator.document.write(
   "<html><body onload='Javascript:document.goannotate.submit();'>"
  +"<form name='goannotate' target='Annotator' method='post' "
  +"action='/adm/annotations'>"
  +"<input type='hidden' name='urlnew' value='"+currentURL+"'>"
  +"</form></body></html>");
   annotator.document.close();
}

function set_bookmark() {
   go('');
   if (currentStale) {
      clienttitle="Enter Title";
      clienthref=currentURL;
   } else {
      clienttitle=clientwindow.document.title;
      clienthref=clientwindow.location.pathname;
   }
   w_bmquery_flag=1;
   bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0');
   bmquery.document.write(
   "<html><body bgcolor='bbbbbb'><center><form method='post'"
   +" name='newlink' action='/adm/bookmarks' target='bmquery' "
   +">\n <table width=340 height=150 "
   +"bgcolor='ffffff' align=center><tr><td>Link Name:<br><input "
   +"type='text' name='title' size=45 value='"+clienttitle+"'>"
   +"<br>Address:<br><input type='text' name='address' size='45' "
   +"value='"+clienthref+"'><br><center><input type='submit' "
   +"value='Save'> <input type='button' value='Close (no save)' "
   +"onclick='javascript:window.close();'></center></td>"
   +"</tr></table></form></center></body></html>");
   bmquery.document.close();
}

function extenddispclose() {
   if (w_extdisp_flag>0) {
      if (extdisp!=null && !extdisp.closed) {
         extdisp.close();
      }
      w_extdisp_flag=-1;
   }
}

function extenddisp() {
   go('');
   w_extdisp_flag=1;
   extdisp=window.open("http://"+clienthost+"/adm/rat/loading.html",
               "ExtDisp", "scrollbars=1,width=400,height=450");
}

function drawwindow() {
   extdisp.document.clear();
   extdisp.document.writeln(
  '<html><body bgcolor="#666666" text="#DDDDDD" link="#EEEEEE" '+
         'onUnload="opener.w_extdisp_flag=-1;">'+
  '<h2>LON-CAPA Extended Display Remote Control</h2>'+
  '<script type="text/javascript">var currentURL="'+currentURL+'";self.focus();</s'+'cript>'+
  '<table border="2"><tr><th>Select Functionality from Below</th>'+
  '<th>Description</th></tr>');
   for (var i=0; i<=ds.length; i++) {
       if (typeof(ds[i])!='undefined') {
          if (ds[i]!='') {
             extdisp.document.writeln(
                '<tr><td align="center"><a href="javascript:opener.'+
               hr[i]+';">&gt;&gt;&gt;<img align="absmiddle" border="0" src="'+
             this.document['b'+i].src+'" />&lt;&lt;&lt;</a><br />&nbsp;<br />'+
  '<table hspace="0" border="0" cellspacing="1" cellpadding="0"><tr>');
             for (var j=0;j<=7;j++) {
                if (j<dt[i].length) {
                   ch=dt[i].charAt(j);
                   if (ch==' ') { ch='space'; }
                   if (ch=='-') { ch='hyphen'; }
                   if (ch==':') { ch='colon'; }
                   if (ch=='/') { ch='slash'; }
                } else { ch='space'; }
                extdisp.document.writeln('<td><img border="0" src="http://'
                                    +clienthost+fontpath+ch+'.gif" /></td>');
             }
             extdisp.document.writeln('</tr><tr>');
             for (var j=0;j<=7;j++) {
                if (j<db[i].length) {
                   ch=db[i].charAt(j);
                   if (ch==' ') { ch='space'; }
                   if (ch=='-') { ch='hyphen'; }
                   if (ch==':') { ch='colon'; }
                   if (ch=='/') { ch='slash'; }
                } else { ch='space'; }
                extdisp.document.writeln('<td><img border="0" src="http://'
                                    +clienthost+fontpath+ch+'.gif" /></td>');
            }
            extdisp.document.writeln(
  '</tr></table></td><td>'+ds[i]+'</td></tr>');
          }
       }
   }
   extdisp.document.writeln('</table></body></html>');
   extdisp.document.close();
}

function edit_bookmarks() {
   go('');
   w_BookmarkPal_flag=1;
   bookmarkpal=window.open("http://"+clienthost+"/adm/bookmarks",
               "BookmarkPal", "width=400,height=505,scrollbars=0");
}

function catalog_info() {
   go('');
   w_LONcatInfo_flag=1;
   loncatinfo=window.open(clientwindow.window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizeable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
}

function chat_win() {
   go('');
   w_LONchat_flag=1;
   lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=280,resizeable=yes,location=no,menubar=no,toolbar=no');
}
// -->
</script>
<center>
<table hspace="0" border="0" cellspacing="0" cellpadding="0">
<tr><td>
<a href="javascript:defdis();"
   onmouseover="defdis();"
><img border="0" width="80" height="50" src="title.gif" /></a>
</td><td>
<img border="0" width="50" height="50" name="led" src="ledoff.gif" />
</td></tr>
</table>
</center>

<center>
<a href="javascript:extenddisp();"
   onmouseover="defdis();"
><img width="104" height="10" border="0" src="spacer.gif" /></a>
</center>

<center>
<table hspace="1" border="0" cellspacing="0" cellpadding="1">
<tr><td bgcolor="#666666">
<table hspace="0" border="0" cellspacing="1" cellpadding="0"> 
<tr>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0"  name="i0" width="15" height="19" src="/adm/lonLCDfont/l.gif" /></a></td>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0"  name="i1" width="15" height="19" src="/adm/lonLCDfont/o.gif" /></a></td>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0"  name="i2" width="15" height="19" src="/adm/lonLCDfont/n.gif" /></a></td>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0"  name="i3" width="15" height="19" src="/adm/lonLCDfont/hyphen.gif" /></a></td>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0"  name="i4" width="15" height="19" src="/adm/lonLCDfont/c.gif" /></a></td>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0"  name="i5" width="15" height="19" src="/adm/lonLCDfont/a.gif" /></a></td>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0"  name="i6" width="15" height="19" src="/adm/lonLCDfont/p.gif" /></a></td>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0"  name="i7" width="15" height="19" src="/adm/lonLCDfont/a.gif" /></a></td>
</tr>
<tr>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0" name="j0" width="15" height="19" src="/adm/lonLCDfont/space.gif" /></a></td>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0" name="j1" width="15" height="19" src="/adm/lonLCDfont/space.gif" /></a></td>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0" name="j2" width="15" height="19" src="/adm/lonLCDfont/space.gif" /></a></td>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0" name="j3" width="15" height="19" src="/adm/lonLCDfont/space.gif" /></a></td>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0" name="j4" width="15" height="19" src="/adm/lonLCDfont/space.gif" /></a></td>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0" name="j5" width="15" height="19" src="/adm/lonLCDfont/space.gif" /></a></td>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0" name="j6" width="15" height="19" src="/adm/lonLCDfont/space.gif" /></a></td>
<td><a href="javascript:defdis();" onmouseover="defdis();"><img border="0" name="j7" width="15" height="19" src="/adm/lonLCDfont/space.gif" /></a></td>
</tr>
</table>
</td></tr>
</table>
</center>

<center>
<table hspace="0" border="0" cellspacing="0" cellpadding="0">

<tr>
<td colspan="2"><a name="link11" href="javascript:eval(hr[11]);" onmouseover="display(dt[11],db[11]);"><img width="86" height="20" border="0" name="b11" src="dempty.gif" /></a></td>
<td><a name="link12" href="javascript:eval(hr[12]);" onmouseover="display(dt[12],db[12]);"><img width="43" height="20" border="0" name="b12" src="empty.gif" /></a></td>
</tr>

<tr>
<td rowspan="2"><a name="link21" href="javascript:eval(hr[21]);" onmouseover="display(dt[21],db[21]);"><img width="43" height="40" border="0" name="b21" src="qempty.gif" /></a></td>
<td><a name="link22" href="javascript:eval(hr[22]);" onmouseover="display(dt[22],db[22]);"><img width="43" height="20" border="0" name="b22" src="empty.gif" /></a></td>
<td rowspan="2"><a name="link23" href="javascript:eval(hr[23]);" onmouseover="display(dt[23],db[23]);"><img width="43" height="40" border="0" name="b23" src="qempty.gif" /></a></td>
</tr>

<tr>
<td><a name="link31" href="javascript:eval(hr[31]);" onmouseover="display(dt[31],db[31]);"><img width="43" height="20" border="0" name="b31" src="empty.gif" /></a></td>
</tr>

<tr>
<td><a name="link41" href="javascript:eval(hr[41]);" onmouseover="display(dt[41],db[41]);"><img width="43" height="20" border="0" name="b41" src="empty.gif" /></a></td>
<td><a name="link42" href="javascript:eval(hr[42]);" onmouseover="display(dt[42],db[42]);"><img width="43" height="20" border="0" name="b42" src="empty.gif" /></a></td>
<td><a name="link43" href="javascript:eval(hr[43]);" onmouseover="display(dt[43],db[43]);"><img width="43" height="20" border="0" name="b43" src="empty.gif" /></a></td>
</tr>

<tr>
<td><a name="link51" href="javascript:eval(hr[51]);" onmouseover="display(dt[51],db[51]);"><img width="43" height="20" border="0" name="b51" src="empty.gif" /></a></td>
<td><a name="link52" href="javascript:eval(hr[52]);" onmouseover="display(dt[52],db[52]);"><img width="43" height="20" border="0" name="b52" src="empty.gif" /></a></td>
<td><a name="link53" href="javascript:eval(hr[53]);" onmouseover="display(dt[53],db[53]);"><img width="43" height="20" border="0" name="b53" src="empty.gif" /></a></td>
</tr>

<tr>
<td><a name="link61" href="javascript:eval(hr[61]);" onmouseover="display(dt[61],db[61]);"><img width="43" height="20" border="0" name="b61" src="empty.gif" /></a></td>
<td><a name="link62" href="javascript:eval(hr[62]);" onmouseover="display(dt[62],db[62]);"><img width="43" height="20" border="0" name="b62" src="empty.gif" /></a></td>
<td><a name="link63" href="javascript:eval(hr[63]);" onmouseover="display(dt[63],db[63]);"><img width="43" height="20" border="0" name="b63" src="empty.gif" /></a></td>
</tr>

<tr>
<td><a name="link71" href="javascript:eval(hr[71]);" onmouseover="display(dt[71],db[71]);"><img width="43" height="20" border="0" name="b71" src="empty.gif" /></a></td>
<td><a name="link72" href="javascript:eval(hr[72]);" onmouseover="display(dt[72],db[72]);"><img width="43" height="20" border="0" name="b72" src="empty.gif" /></a></td>
<td><a name="link73" href="javascript:eval(hr[73]);" onmouseover="display(dt[73],db[73]);"><img width="43" height="20" border="0" name="b73" src="empty.gif" /></a></td>
</tr>

<tr>
<td><a name="link81" href="javascript:eval(hr[81]);" onmouseover="display(dt[81],db[81]);"><img width="43" height="20" border="0" name="b81" src="empty.gif" /></a></td>
<td><a name="link82" href="javascript:eval(hr[82]);" onmouseover="display(dt[82],db[82]);"><img width="43" height="20" border="0" name="b82" src="empty.gif" /></a></td>
<td><a name="link83" href="javascript:eval(hr[83]);" onmouseover="display(dt[83],db[83]);"><img width="43" height="20" border="0" name="b83" src="empty.gif" /></a></td>
</tr>

<tr>
<td><a name="link91" href="javascript:eval(hr[91]);" onmouseover="display(dt[91],db[91]);"><img width="43" height="20" border="0" name="b91" src="empty.gif" /></a></td>
<td><a name="link92" href="javascript:eval(hr[92]);" onmouseover="display(dt[92],db[92]);"><img width="43" height="20" border="0" name="b92" src="empty.gif" /></a></td>
<td><a name="link93" href="javascript:eval(hr[93]);" onmouseover="display(dt[93],db[93]);"><img width="43" height="20" border="0" name="b93" src="empty.gif" /></a></td>
</tr>

<tr>
<td><a name="link101" href="javascript:eval(hr[101]);" onmouseover="display(dt[101],db[101]);"><img width="43" height="20" border="0" name="b101" src="empty.gif" /></a></td>
<td><a name="link102" href="javascript:eval(hr[102]);" onmouseover="display(dt[102],db[102]);"><img width="43" height="20" border="0" name="b102" src="empty.gif" /></a></td>
<td><a name="link103" href="javascript:eval(hr[103]);" onmouseover="display(dt[103],db[103]);"><img width="43" height="20" border="0" name="b103" src="empty.gif" /></a></td>
</tr>

<tr>
<td><a name="link111" href="javascript:eval(hr[111]);" onmouseover="display(dt[111],db[111]);"><img width="43" height="20" border="0" name="b111" src="empty.gif" /></a></td>
<td><a name="link112" href="javascript:eval(hr[112]);" onmouseover="display(dt[112],db[112]);"><img width="43" height="20" border="0" name="b112" src="empty.gif" /></a></td>
<td><a name="link113" href="javascript:eval(hr[113]);" onmouseover="display(dt[113],db[113]);"><img width="43" height="20" border="0" name="b113" src="empty.gif" /></a></td>
</tr>

</table>
</center>

<form name="server" action="/adm/logout" method="post" target="loncapaclient">
<input type="hidden" name="postdata" value="none" />
<input type="hidden" name="command" value="none" />
<input type="hidden" name="url" value="none" />
<input type="hidden" name="postsymb" value="none" />
</form>
</body>
</html>








FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>