forked from Bunteshaus/bunteshaus.de
small fixes
This commit is contained in:
parent
c2e3293dfb
commit
10cbba1935
|
@ -28,6 +28,7 @@
|
|||
<div class="w100 {{ if .group }} visibleIf margin_left_1rem" data-visibleif-rule="{{ .group }}group == 'true' {{ end }}" style="flex-direction: column;">
|
||||
<label class="w100 {{ if $pageform.names }}sr-only{{ end }}" for="{{ .title }}">{{- $name -}}{{- if .required -}}{{- " *" -}}{{- end -}}</label>
|
||||
<div style="display: flex; flex-wrap: wrap;">
|
||||
<button style="background: #8e3333;" class="button" type="button" value="Clear" onclick="clearThis({{ .title }});" />Clear</button>
|
||||
{{ $button_target := .title }}
|
||||
{{ range split .buttons ";"}}
|
||||
{{ $b := split . ","}}
|
||||
|
@ -38,6 +39,9 @@
|
|||
{{ end }}
|
||||
</div>
|
||||
<textarea class="w100 textarea" name="{{ .title }}" id="{{ .title }}" rows="10" {{ if .placeholder }}placeholder="{{ .placeholder }}"{{ end }}></textarea>
|
||||
{{ if eq .title "content" }}
|
||||
<div id="added-files" style="display: flex; flex-direction: column;"></div>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ else if eq .input_type "radio" }}
|
||||
<div class="radio {{- if .group }} visibleIf margin_left_1rem" data-visibleif-rule="{{ .group }}group == 'true'{{ end }}">
|
||||
|
|
|
@ -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 += "<div id=\"" + name + "\" style=\"display: flex; flex-direction: row;\">" + pic + "<button type=\"button\" onclick=\"rm_file('" + name + "')\" value=\"" + name + "\" id=\"" + name + "\">remove</button></div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (x == "bold") {
|
||||
let bold = prompt("Bold", "");
|
||||
|
@ -115,7 +124,7 @@ function button(str) {
|
|||
if (x == "more") {
|
||||
var out = "\n\n<!--more-->\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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue