]> jspc29.x-matter.uni-frankfurt.de Git - labtools.git/commitdiff
add option to delete several files at once in presenter
authorJan Michel <j.michel@gsi.de>
Wed, 19 Oct 2016 07:45:48 +0000 (09:45 +0200)
committerJan Michel <j.michel@gsi.de>
Wed, 19 Oct 2016 07:46:09 +0000 (09:46 +0200)
presenter/deletePic.pl
presenter/scripts.js
presenter/showroom.pl

index ed545244861247d82812569b15627ab7436cc53e..3a015c9074043d3dd1a65f71df71d32ec5f1650e 100755 (executable)
@@ -13,14 +13,18 @@ if (!($room =~ /^[a-zA-Z0-9]+$/) || !(-d "store/$room")) {
 }
 
  
-my $t = $cgi->param("img");
-if(($t =~ /[\"\$\(\)\/]/ || !(-e "store/$room/$t")) && ($t =~ /.png$/i || $t =~ /.jpg$/i)) {
-  print "Invalid selection";
-  return 1;
+my $s = $cgi->param("img");
+my @r = split('%',$s);
+
+foreach my $t (@r) {
+  if(($t =~ /[\"\$\(\)\/]/ || !(-e "store/$room/$t")) && ($t =~ /.png$/i || $t =~ /.jpg$/i)) {
+    print "Invalid selection $t";
+    #return 1;
+  }
+  else {
+  system("rm store/$room/$t store/$room/thumb/$t");
 }
-
-system("rm store/$room/$t store/$room/thumb/$t");
-
+  }
 
 print <<REDOC;
 <!DOCTYPE html>
index 720d97d6707946e8e9e7afa61cb2c94aaec7226b..596425f52f7de04d17eaffb78b98fa06c1014e7a 100644 (file)
@@ -60,11 +60,20 @@ function presentNext(d) {
   }
 
 function deletePic(f) {
-  if(f != "") {
-    getData("deletePic.pl?img="+f+"&room="+currentRoom);
+
+  g = '';
+  x = document.getElementById('filelist');
+  for (var i = 0; i < x.options.length; i++) {
+   if(x.options[i].selected){
+      g= g + '%' + x.options[i].value;
+    }
+  } 
+  if(g != "") {
+    if(confirm('Really delete selected files?'))
+      getData("deletePic.pl?img="+g+"&room="+currentRoom);
     }
   else {
-    alert("Select a file to show!");
+    alert("Select a file to delete!");
     }
   }
 
@@ -108,5 +117,11 @@ function previewSelected() {
   }
 
 
+function togglemulti() {
+  document.getElementById("filelist").setAttribute('multiple','multiple');
+  }
+
+
+
 setTimeout('updatefiles();',500);
 setTimeout('updatepresentation(" ");',200);
index 1cc9b3255a64d4ad0f40abd65b3dd6ac8d2ca2e0..cc51d021a5b0ff969e42657bfca7345568869374 100755 (executable)
@@ -40,8 +40,9 @@ Select a file and press upload.
 <div id="files"> &nbsp; </div>
 <button type="button" onClick="window.open('store/$room/'+document.getElementById('filelist').value)">Show 2 Me</button>
 <button type="button" onClick="present(document.getElementById('filelist').value)">Show 2 All</button>
-<button type="button" onClick="deletePic(document.getElementById('filelist').value)">Delete</button>
-<div id="current"></div><div id="preview"></div>
+<br><button type="button" onClick="deletePic(document.getElementById('filelist').value)">Delete</button>
+<button type="button" onClick="togglemulti()" title='Enable selecting several files for deletion'>MS</button>
+<div id="current"></div><div id="preview"></div>You can use arrow keys to change slides!</div>
 </body></html>
 HDOC