Difference between revisions of "Widget:Multi upload"
From cm2.liecourt.com
(Created page with "<div id="imgTest" class="upload-preview"></div> <label for="files" class="attachment"><i class="fa fa-paperclip"></i><input type="file" id="files" name="files[]" class="d-non...") |
(Fill database) |
||
Line 1: | Line 1: | ||
+ | <noinclude>{{Managed | ||
+ | |Version=1.0 | ||
+ | |Version notes=1.0 - First managed version | ||
+ | |Short description= | ||
+ | }} | ||
+ | |||
+ | This is the '''Widget:Multi upload''' page. It should be called in the following format: | ||
+ | |||
+ | <pre> | ||
+ | {{#widget:Multi upload }} | ||
+ | </pre> | ||
+ | |||
+ | </noinclude><includeonly> | ||
<div id="imgTest" class="upload-preview"></div> | <div id="imgTest" class="upload-preview"></div> | ||
− | <label for="files" class="attachment"><i class="fa fa-paperclip"></i><input type="file" id="files" name="files[]" class="d-none" multiple /></label>< | + | <label for="files" class="attachment"><i class="fa fa-paperclip"></i><input type="file" id="files" name="files[]" class="d-none" multiple /></label><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 uuid = uuidv4(); | ||
var filedate = Date.now(); | var filedate = Date.now(); | ||
Line 21: | Line 42: | ||
console.log(values); | console.log(values); | ||
console.log('done'); | 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) | ||
+ | submitRealField() | ||
}); | }); | ||
Line 98: | Line 124: | ||
function editFilePage(file){ | function editFilePage(file){ | ||
− | var newWikitextEdit = '{{File for case|Case file= | + | var newWikitextEdit = '{{File for case|Case file='+uuid+'|File uploaded by=User:'+mw.user.getName()+'|type='+file.substr( file.length -3 )+'}}'; |
Line 116: | Line 142: | ||
document.getElementById('files').addEventListener('change', handleFileSelect, false); //is a <input type="file" id="files" name="files[]" multiple /> | document.getElementById('files').addEventListener('change', handleFileSelect, false); //is a <input type="file" id="files" name="files[]" multiple /> | ||
− | |||
</script> | </script> | ||
+ | |||
+ | </includeonly> |
Revision as of 14:07, 27 May 2020
This is the Widget:Multi upload page. It should be called in the following format:
{{#widget:Multi upload }}