Widget:File upload: verschil tussen versies
Uit Dorpsbelang Den Hout
Regel 27: | Regel 27: | ||
var settingsFilename<!--{if (isset($filename) && $filename!="")}--> = "<!--{$filename}-->"<!--{/if}-->; | var settingsFilename<!--{if (isset($filename) && $filename!="")}--> = "<!--{$filename}-->"<!--{/if}-->; | ||
− | console.log(settingsFilename.replace('< | + | console.log(createFilename('hoi')) |
− | + | ||
+ | |||
+ | function createFilename(filename){ | ||
+ | var ouput = settingsFilename; | ||
+ | var regex = /<(\w+)>/gm; | ||
+ | var m; | ||
+ | |||
+ | while ((m = regex.exec(settingsFilename)) !== null) { | ||
+ | // This is necessary to avoid infinite loops with zero-width matches | ||
+ | if (m.index === regex.lastIndex) { | ||
+ | regex.lastIndex++; | ||
+ | } | ||
+ | |||
+ | // The result can be accessed through the `m`-variable. | ||
+ | m.forEach((match, groupIndex) => { | ||
+ | |||
+ | if(match == "FILENAME"){ | ||
+ | output = output.replace('<'+match+'>', filename); | ||
+ | }else{ | ||
+ | var val = document.querySelector('[name='+match+']').value; | ||
+ | if(val){ | ||
+ | output = output.replace('<'+match+'>', val); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | // console.log(`Found match, group ${groupIndex}: ${match}`); | ||
+ | }); | ||
+ | } | ||
+ | return output; | ||
+ | } | ||
Versie van 7 sep 2020 09:10
This is the Widget:Multi upload page. It should be called in the following format:
{{#widget:Multi upload }}