Widget:Multi upload: verschil tussen versies

Uit Dorpsbelang Den Hout
Ga naar:navigatie, zoeken
Regel 30: Regel 30:
 
}
 
}
  
function uploadFiles(filename){
+
function uploadFiles(mode, filename){
 
var files = document.getElementById('files').files;
 
var files = document.getElementById('files').files;
 
var proms = [];  
 
var proms = [];  
Regel 40: Regel 40:
 
         var fileName = files[i].name;
 
         var fileName = files[i].name;
 
         }
 
         }
var prom =  doApiCall(file, fileName);
+
var prom =  doApiCall(file, fileName, mode);
 
         proms.push(prom)
 
         proms.push(prom)
 
     }
 
     }
Regel 51: Regel 51:
 
     //    codeid.setAttribute('value', uuid)
 
     //    codeid.setAttribute('value', uuid)
 
     //    document.getElementById('files').closest('form').appendChild(codeid)
 
     //    document.getElementById('files').closest('form').appendChild(codeid)
        submitRealField()
+
    //  submitRealField()
 +
  document.getElementById('real-submit').click();
 
     });
 
     });
  
Regel 57: Regel 58:
  
  
function doApiCall(fileToUpload,fileName){
+
function doApiCall(fileToUpload,fileName, mode){
 
return new Promise(function(resolve, reject){
 
return new Promise(function(resolve, reject){
 
formdata = new FormData();  
 
formdata = new FormData();  
 
formdata.append("action", "upload");
 
formdata.append("action", "upload");
formdata.append("filename", filedate+fileName);
+
formdata.append("filename", fileName);
 
//formdata.append("filename", fileName);
 
//formdata.append("filename", fileName);
 
formdata.append("token", mw.user.tokens.get( 'editToken' ) );
 
formdata.append("token", mw.user.tokens.get( 'editToken' ) );
Regel 82: Regel 83:
 
                         resolve(data)
 
                         resolve(data)
 
                 //  setTimeout(function(){
 
                 //  setTimeout(function(){
                       editFilePage(fileName);
+
                       editFilePage(fileName, mode);
 
                 //  },100)
 
                 //  },100)
 
},
 
},
Regel 132: Regel 133:
 
}
 
}
  
function editFilePage(file){
+
function editFilePage(file, mode){
 
 
var newWikitextEdit = '{{File for case|Case file='+uuid+'|File uploaded by=User:'+mw.user.getName()+'|type='+file.substr( file.length -3 )+'}}';
 
  
 +
  if(mode == "logo"){
 +
    var newWikitextEdit = '{{Domein logo|Domein='+document.querySelector('input[name="Domein"]').value+'|File uploaded by=User:'+mw.user.getName()+'|type='+file.substr( file.length -3 )+'}}';
 +
  }else{
 +
      var newWikitextEdit = '{{Bericht file|Bericht='+document.querySelector('input[name="Domein"]').value.replace('.','-')+'/'+document.querySelector('input[name="Titel"]').value.replace(' ','-')+'|Domein='+document.querySelector('input[name="Domein"]').value+'|File uploaded by=User:'+mw.user.getName()+'|type='+file.substr( file.length -3 )+'}}';
 +
  }
  
 
     var params = {
 
     var params = {
 
         action: 'edit',
 
         action: 'edit',
         title: 'File:'+filedate+file,
+
         title: 'File:'file,
 
         text: newWikitextEdit,
 
         text: newWikitextEdit,
 
         format: 'json'
 
         format: 'json'

Versie van 18 aug 2020 20:47

Sjabloon:Managed

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

{{#widget:Multi upload }}