diff --git a/themes/buha/static/js/generator.js b/themes/buha/static/js/generator.js
index 38f602e7..bdf262e7 100644
--- a/themes/buha/static/js/generator.js
+++ b/themes/buha/static/js/generator.js
@@ -52,6 +52,12 @@ function Clear(name) {
ele[i].checked = false;
}
+function rm_file(fname) {
+ var rmid = document.getElementById(fname);
+ rmid.remove(); // Removes the div with the 'div-02' id
+ zip.remove(fname);
+}
+
function button(str) {
var arr = str.split(";");
let x = arr[1];
@@ -76,27 +82,30 @@ function button(str) {
var input = document.createElement('input');
+ var fout = document.getElementById('added-files');
input.type = 'file';
input.multiple = 'multiple';
input.id = 'inpic';
input.click();
input.onchange = e => {
var files = e.target.files;
+
for (var i = 0; i < files.length; i++) {
- var p = "Desc for " + files[i].name;
+ var name = files[i].name.trim();
+ var p = "Desc for " + name;
var desc = prompt(p, "Wikipedia logo");
if (desc) {
- zip.file(files[i].name, files[i]);
- var pic = files[i].name;
+ zip.file(name, files[i]);
+ var pic = name;
var out = "![" + desc + "](" + pic + ") \n\n";
typeInTextarea(out);
var end = id.value.length;
id.setSelectionRange(end, end);
id.focus({preventScroll: true});
+ fout.innerHTML += "
" + pic + "
";
}
}
}
- return;
}
if (x == "bold") {
let bold = prompt("Bold", "");
@@ -115,7 +124,7 @@ function button(str) {
if (x == "more") {
var out = "\n\n\n\n";
}
- if (out != null) {
+ if (out != null && x != "pic") {
typeInTextarea(out);
var end = id.value.length;
id.setSelectionRange(end, end);
@@ -145,6 +154,7 @@ function showInput(e) {
var d = new Date();
var datestring = d.getFullYear() + "-" + ("0"+(d.getMonth()+1)).slice(-2) + "-" + ("0" + d.getDate()).slice(-2) + "T" + ("0" + d.getHours()).slice(-2) + ":" + ("0" + d.getMinutes()).slice(-2) + ":00+02:00";
+ var datestring_shorter = d.getFullYear() + "-" + ("0"+(d.getMonth()+1)).slice(-2) + "-" + ("0" + d.getDate()).slice(-2);
var form = document.querySelector('form[id="generatorform"]');
var title = form.elements['title'].value;
@@ -326,13 +336,20 @@ function showInput(e) {
// Add an top-level, arbitrary text file with contents
zip.file("index.de.md", output);
+ var pattern = /[^a-z\d\-_\s]+$/i;
+ var t = title.replace(/^["'](.+(?=["']$))["']$/, '$1').toLowerCase();
+ var t = t.trim();
+ var t = t.replaceAll(/\s+/g, '-');
-
+ var t = t.replace(/[^\w.-]+/g, "");
+
+ var archive_name = datestring_shorter + "-" + t + ".zip";
+
// Generate the zip file asynchronously
zip.generateAsync({type:"blob"})
.then(function(cont) {
// Force down of the Zip file
- saveAs(cont, "archive.zip");
+ saveAs(cont, archive_name);
});
}
}