[LON-CAPA-cvs] cvs: loncom /publisher lonpubdir.pm

raeburn raeburn at source.lon-capa.org
Sat Jun 10 19:01:15 EDT 2023


raeburn		Sat Jun 10 23:01:15 2023 EDT

  Modified files:              
    /loncom/publisher	lonpubdir.pm 
  Log:
  - Shortcuts in "Create a new directory or LON-CAPA document" box.
    - Change Quickactions to Shortcuts
    = Add missing &mt()
    - Display prompts to enter new file name or subdirectory name when 
      "Type name here" textbox is empty 
  
  
Index: loncom/publisher/lonpubdir.pm
diff -u loncom/publisher/lonpubdir.pm:1.174 loncom/publisher/lonpubdir.pm:1.175
--- loncom/publisher/lonpubdir.pm:1.174	Fri May 27 04:24:55 2022
+++ loncom/publisher/lonpubdir.pm	Sat Jun 10 23:01:15 2023
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Authoring Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.174 2022/05/27 04:24:55 raeburn Exp $
+# $Id: lonpubdir.pm,v 1.175 2023/06/10 23:01:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -549,7 +549,14 @@
 				       acti => 'Actions for current directory',
 				       updc => 'Upload a new document',
 				       pick => 'Please select an action to perform using the new filename',
+                                       shcu => 'Shortcuts',
                                       );
+    my %js_lt = &Apache::lonlocal::texthash(
+                                       nanf => 'Name of New File',
+                                       nans => 'Name of New Subdirectory',
+                                       psfn => 'Please specify file name',
+    ); 
+    &js_escape(\%js_lt);
     my $mytype = $lt{'type'}; # avoid conflict with " and ' in javascript
     # Calculate free space in bytes.
     # $disk_quota is in MB and $current_disk_usage is in kB
@@ -584,7 +591,7 @@
       <fieldset>
         <legend>$lt{'updc'}</legend>
         <input type="hidden" name="filename" value="/priv$thisdisfn/" />
-        <input type="file" name="upfile" class="LC_flUpload" size="20" />
+        <input type="file" name="upfile" class="LC_flUpload" />
         <input type="hidden" id="LC_free_space" value="$free_space" />
         <input type="button" value="$lt{'uplo'}"  onclick="checkUpload(this.form)" />
       </fieldset>
@@ -619,9 +626,9 @@
                     <option value="newtaskfile">$lt{'nbt'}:</option>
                     <option value="newlibraryfile">$lt{'nlib'}:</option>
 	            <option value="newdir">$lt{'nsub'}:</option>
-		  </select> <input type="text" name="newfilename" placeholder="$lt{'type'}" value="" onfocus="if (this.value == is.empty()) this.value=''" /> <input type="button" value="Go" onclick="validate_go();" />
+		  </select> <input type="text" id="newnameid" name="newfilename" placeholder="$lt{'type'}" value="" onfocus="if (this.value == is.empty()) this.value=''" /> <input type="button" value="Go" onclick="validate_go();" />
 		<br />
-                <span>Quickactions:
+                <span>$lt{'shcu'}:
                  <input type="hidden" name="mode"/>
                  <a href="javascript:void(0)" onclick="javascript:validate_action('blank')">
 		    <img src="/adm/lonIcons/unknown.gif" title="Create blank problem file"></a>
@@ -634,26 +641,36 @@
                 </span>
                  <script type="text/javascript">
                      function validate_action(action){
-
-                         if (document.getElementsByName(\'newfilename\')[0].value != \'\'){
-                             if (action == "blank") {
-								 document.fileaction.action.value=\'newproblemfile\';
-								 document.fileaction.mode.value=\'blank\';
-							 } else if (action == "problemtempl") {
-								 document.fileaction.action.value=\'newproblemfile\';
-                                 validate_go();
-                             } else if (action == "blankhtml") {
-                                 document.fileaction.action.value=\'newhtmlfile\';
-                                 validate_go();
-                             } else if (action == "folder") {
-                                 document.fileaction.action.value=\'newdir\';
-                                 document.fileaction.mode.value=\'folder\';
+                         if (document.getElementById('newnameid')) {
+                             if (document.getElementById('newnameid').value == '') {
+                                 var newname;
+                                 var prompttext = "$js_lt{'nanf'}";
+                                 if (action == 'folder') {
+                                     prompttext = "$js_lt{'nans'}";
+                                 }
+                                 newname=prompt(prompttext);
+                                 if (newname != '') {
+                                     document.getElementById('newnameid').value = newname;
+                                 }
+                             }
+                             if (document.getElementById('newnameid').value != '') {
+                                 if (action == 'blank') {
+				     document.fileaction.action.value='newproblemfile';
+				     document.fileaction.mode.value='blank';
+			         } else if (action == 'problemtempl') {
+				     document.fileaction.action.value='newproblemfile';
+                                     validate_go();
+                                 } else if (action == 'blankhtml') {
+                                     document.fileaction.action.value='newhtmlfile';
+                                     validate_go();
+                                 } else if (action == 'folder') {
+                                     document.fileaction.action.value='newdir';
+                                     document.fileaction.mode.value='folder';
+                                 }
+                                 fileaction.submit();
+                             } else {
+                                 alert("$js_lt{'psfn'}");
                              }
-                             fileaction.submit();
-                         } else {
-                             alert(\'Please specify file name.\');
-                             // TODO: ask for filename? if so, do some refactoring
-
                          }
                      }
                  </script>




More information about the LON-CAPA-cvs mailing list