Widget:File upload: verschil tussen versies

Uit Dorpsbelang Den Hout
Ga naar:navigatie, zoeken
Regel 14: Regel 14:
 
<div id="widget-file-upload-preview" ></div>
 
<div id="widget-file-upload-preview" ></div>
  
<label for="widget-file-upload-files" ><!--{if (isset($button) && $button!="")}--><!--{$button}--><!--{else}--><button>Upload</button><!--{/if}--><input type="file" id="widget-file-upload-files" name="files[]" style="display:none"  <!--{if (isset($multiple) && $multiple=="true")}-->multiple<!--{/if}--> /></label>
+
<label for="widget-file-upload-files" ><!--{if (isset($button) && $button!="")}--><!--{$button}--><!--{else}--><button>Upload</button><!--{/if}--><input type="file" id="widget-file-upload-files" name="files[]" style="display:none"  <!--{if (isset($multiple) && $multiple=="false")}--><!--{else}-->multiple<!--{/if}--> /></label>
 
<script>
 
<script>
  
function uuidv4() {
 
  return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
 
    (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
 
  );
 
}
 
  
 
var counter = 0;
 
var counter = 0;
  
var uuid = uuidv4();
+
var settingsPreview = <!--{$preview}-->;
 +
var settingsCaption = <!--{$caption}-->;
 +
var settingsDrop = <!--{$drop}-->;
 +
var settingsFilepagetemplate = <!--{$filepagetemplate}-->;
 +
var settingsFilepageparameters = <!--{$filepageparameters}-->;
 +
var settingsFilename = <!--{$filename}-->;
  
var filedate = Date.now();
+
console.log(settingsFilename)
  
 
function handleFileSelect() {
 
function handleFileSelect() {
createPrevieuws();
+
 
 +
  if(settingsPreview != "false"){
 +
      createPreviews();
 +
  }
 
}
 
}
  
 
function uploadFiles(evt){
 
function uploadFiles(evt){
var files = document.getElementById('widget-file-upload-files').files;
+
var files = document.getElementById('widget-file-upload-files').files;
 
var proms = [];  
 
var proms = [];  
 
     for(i = 0; i < files.length; ++i){
 
     for(i = 0; i < files.length; ++i){
Regel 43: Regel 46:
 
     }
 
     }
 
  Promise.all(proms).then(function(values) {
 
  Promise.all(proms).then(function(values) {
      console.log(values);
+
           document.getElementById('form-save').click();
           console.log('done');
 
        var codeid = document.createElement('input');
 
        codeid.setAttribute('type','hidden')
 
        codeid.setAttribute('name','uuid')
 
        codeid.setAttribute('value', uuid)
 
        document.getElementById('files').closest('form').appendChild(codeid)
 
        document.getElementById('form-save').click();
 
 
     });
 
     });
 
 
}
 
}
  
Regel 92: Regel 87:
 
}
 
}
  
function createPrevieuws(){
+
 
 +
function createPreviews(){
 
   var filesSelected = document.getElementById("widget-file-upload-files").files;
 
   var filesSelected = document.getElementById("widget-file-upload-files").files;
 
     if (filesSelected.length > 0) {
 
     if (filesSelected.length > 0) {

Versie van 7 sep 2020 08:39

Sjabloon:Managed

This is the Widget:Multi upload page. It should be called in the following format:

{{#widget:Multi upload }}