File:  [LON-CAPA] / loncom / publisher / publisher.html
Revision 1.37: download - view: text, annotated - select for diffs
Wed Apr 7 18:02:47 2004 UTC (20 years, 1 month ago) by sakharuk
Branches: MAIN
CVS tags: HEAD
CHanges to print problem from the construction space as an exam one. It works but may be looks not so good. Trying to simplify.

    1: <html>
    2: <head>
    3: <title>LON-CAPA Publishing Frame</title>
    4: <script language="JavaScript">
    5: 
    6: function frameloc() {
    7:     if (parent.LONCAPAToBePublished.location.pathname.indexOf("/~")!=-1) {
    8:        parent.lastknownpriv=parent.LONCAPAToBePublished.location.pathname;
    9:     }
   10: // alert ('We are at '+parent.lastknownpriv);
   11:     return unescape(parent.lastknownpriv);
   12: }
   13: 
   14: function getfilename() {
   15:    document.publisher.filename.value=frameloc();
   16:    if ((document.publisher.filename.value.charAt(
   17:         document.publisher.filename.value.length-1)!='/') &&
   18:        (document.publisher.filename.value.indexOf('/adm/pubdir')==-1)) {
   19:         document.publisher.submit();
   20:    } else {
   21:       alert('MT{Cannot publish directory}');
   22:    }
   23: }
   24: 
   25: function getdfilename() {
   26:   document.dpublisher.filename.value=frameloc();
   27:   if (document.dpublisher.filename.value.indexOf('/adm/pubdir')==-1) {
   28:       document.dpublisher.submit();
   29:   }
   30: }
   31: 
   32: function getufilename() {
   33:   document.upublisher.filename.value=frameloc();
   34:   if (document.upublisher.filename.value.indexOf('/adm/pubdir')!=-1) {
   35:       document.upublisher.filename.value=document.dpublisher.filename.value;
   36:   }
   37:   document.upublisher.submit();
   38: }
   39: 
   40: function getrfilename() {
   41:   document.rpublisher.filename.value=frameloc();
   42:    if ((document.rpublisher.filename.value.charAt(
   43:         document.rpublisher.filename.value.length-1)!='/') &&
   44:        (document.rpublisher.filename.value.indexOf('/adm/pubdir')==-1)) {
   45:         document.rpublisher.submit();
   46:    } else {
   47:       alert('MT{Cannot retrieve directory}');
   48:    }
   49: }
   50: 
   51: function getactionfilename() {
   52:   document.fileaction.filename.value=frameloc();
   53:   var test=document.fileaction.action.selectedIndex;
   54:   if (test == 8) { // trying to create a directory
   55:       if (document.fileaction.filename.value.indexOf('/adm/pubdir')!=-1) {
   56:           document.fileaction.filename.value=document.dpublisher.filename.value;
   57:       }
   58:       if ((document.fileaction.filename.value.charAt(
   59:            document.fileaction.filename.value.length-1)!='/') &&
   60:            (document.fileaction.filename.value.indexOf('/adm/pubdir')==-1)) {
   61:           alert('MT{Must create new subdirectory inside a directory}');
   62:           return;
   63:       }
   64:    }
   65:    document.fileaction.submit();
   66: }
   67: 
   68: function getdelfilename() {
   69:   document.del.filename.value=frameloc();
   70:   document.del.submit();
   71: }
   72: 
   73: function getcurseed() {
   74:   if (parent.LONCAPAToBePublished.document.lonhomework
   75:        &&
   76:       parent.LONCAPAToBePublished.document.lonhomework.rndseed
   77:        &&
   78:       parent.LONCAPAToBePublished.document.lonhomework.rndseed.value) {
   79:     return parent.LONCAPAToBePublished.document.lonhomework.rndseed.value;
   80:   }
   81:   return 0;
   82: }
   83: 
   84: function getproblemtype() {
   85:   if (parent.LONCAPAToBePublished.document.lonhomework) {
   86:      var optionelement;
   87:      var valueIndex=0;
   88:      for (var optionIndex=0;
   89:           optionIndex < parent.LONCAPAToBePublished.document.lonhomework.problemtype.options.length;
   90: 	  optionIndex++)
   91:      {
   92:          optionElement=parent.LONCAPAToBePublished.document.lonhomework.problemtype.options[optionIndex];
   93: 	 if (optionElement.selected) {
   94: 	    return optionElement.value;
   95:          }	  
   96:      } 	  
   97:   }
   98:   return 0;
   99: }
  100: 
  101: function getpostdata() {
  102:   document.printout.postdata.value=frameloc();
  103:   document.printout.curseed.value=getcurseed();
  104:   document.printout.problemtype.value=getproblemtype();
  105:   document.printout.submit();
  106: }
  107: </script>
  108:     </head>
  109:     <body bgcolor="#ccffdd" text='#002200' link='#003333' vlink='#006666'>
  110:       <font size="-2">
  111: 	<table border="0" align="center"><tr><th bgcolor="#004400" height="20">
  112: 	      <table border="0" cellspacing="2" cellpadding="2"><tr valign="middle">
  113: 		  <form name="publisher" action="/adm/publish" target="_parent" method="post">
  114: 		    <td bgcolor="#ccddaa" align="center">
  115: 		      <input type="hidden" name="filename" value="" />
  116: 	              <input type="button" value="MT{Publish this Resource}" onClick="getfilename();" />
  117: 		    </td>
  118: 		  </form>
  119: 		  <form name="dpublisher" action="/adm/pubdir" target="LONCAPAToBePublished" method="post">
  120: 		    <td bgcolor="#ccddaa" align="center">
  121: 		      <input type="hidden" name="filename" value="" />
  122: 		      <input type="button" value="MT{List Directory}" onClick="getdfilename();" />
  123: 		    </td>
  124: 		  </form>
  125: 		  <form name="upublisher" action="/adm/upload" target="_parent"
  126: 			method="post" enctype="multipart/form-data">
  127: 		    <td bgcolor="#ccddaa" valign="top" align="center">
  128: 		      <input type="hidden" name="filename" value="" />
  129: 		      <input type="file" name="upfile" size="20" />
  130: 		      <input type="button" value="MT{Upload file}"  onClick="getufilename();" />
  131: 		    </td>
  132: 		  </form>
  133: 		  <form name="printout" target="_parent" action="/adm/printout" target="LONCAPAToBePublished" method="post" onSubmit="getpostdata();">
  134: 		    <td rowspan="2" bgcolor="#ccddaa" align="center">
  135: 		      <input type="hidden" name="postdata" value="" />
  136: 		      <input type="hidden" name="curseed" value="" />
  137: 		      <input type="hidden" name="problemtype" value="" />
  138: 		      <input type="button" value="MT{Print}" onClick="getpostdata();" />
  139: 		    </td>
  140: 		  </form>
  141: 
  142: 		</tr>
  143: 		<tr valign="middle">
  144: 		  <form name="rpublisher" action="/adm/retrieve" target="_parent" method="post">
  145: 		    <td bgcolor="#ccddaa" align="center">
  146: 		      <input type="hidden" name="filename" value="" />
  147: 		      <input type="button" value="MT{Retrieve Old Version}" onClick="getrfilename();" />
  148: 		    </td>
  149: 		  </form>
  150: 		  <form name="del" action="/adm/cfile" target="_parent" method="post">
  151: 		    <td bgcolor="#ccddaa">
  152: 		      <input type="hidden" name="filename" value="" />
  153: 		      <input type="hidden" name="action" value="delete" />
  154: 	              <input type="button" value="MT{Delete}" onClick="getdelfilename();" />
  155: 		    </td>
  156: 		  </form>
  157: 		  <form name="fileaction" action="/adm/cfile" target="_parent" method="post" onSubmit="getactionfilename();">
  158: 		    <td bgcolor="#ccddaa" align="center">
  159: 		      <nobr>
  160: 			<input type="hidden" name="filename" value="" />
  161: 			  <select name="action">
  162: 			    <option>MT{Select Action}</option>
  163: 			    <option value="newfile">MT{New file}:</option>
  164: 			    <option value="newhtmlfile">MT{New HTML file}:</option>
  165: 			    <option value="newproblemfile">MT{New problem}:</option>
  166:                             <option value="newpagefile">MT{New assembled page}:</option>
  167:                             <option value="newsequencefile">MT{New assembled sequence}:</option>
  168:                             <option value="newrightsfile">MT{New custom rights file}:</option>
  169:                             <option value="newstyfile">MT{New style file}:</option>
  170: 			    <option value="newdir">MT{New subdirectory}:</option>
  171: 			    <option value="rename">MT{Rename current file to}:</option>
  172: 			    <option value="move">MT{Move current file to}:</option>
  173: 			    <option value="copy">MT{Copy current file to}:</option>
  174: 			  </select>&nbsp;<input type="text" name="newfilename" value="MT{Type Name Here}" onFocus="if (this.value == 'MT{Type Name Here}') this.value=''" />&nbsp;<input type="button" value="MT{Go}" onClick="getactionfilename();" />
  175: 		      </nobr>
  176: 		    </td>
  177: 		  </form>
  178: 		</td>
  179: 		</form>
  180: 		</tr>
  181: 	      </table>
  182: 	    </th>
  183: 	  </tr>
  184: 	</table>
  185:       </font>
  186:     </body>
  187:   </html>

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