forked from Bunteshaus/bunteshaus.de
small fixes
This commit is contained in:
parent
82229b90ff
commit
c2e3293dfb
|
@ -6,7 +6,7 @@ description: "generator"
|
|||
type: "tools"
|
||||
tool: "generator"
|
||||
divide: "Getrennt durch Komma"
|
||||
js: ["visibleIf.js","generator.js"]
|
||||
js: ["visibleIf.js","jszip/jszip.js","jszip/filesaver.js","generator.js"]
|
||||
forms:
|
||||
- to: info@bunteshaus.de
|
||||
realnames: false
|
||||
|
|
|
@ -45,7 +45,8 @@
|
|||
</div>
|
||||
{{ else if eq .input_type "checkbox" }}
|
||||
<div class="w100 checkbox {{- if .group }} visibleIf margin_left_1rem" data-visibleif-rule="{{ .group }}group == 'true'{{ end }}">
|
||||
<label><input type="checkbox" name="{{ .title }}" id="{{ .title }}" value="{{ .name }}">{{- $name -}}{{- if .help }} ({{ .help }}){{ end }}</label>
|
||||
<input type="checkbox" name="{{ .title }}" id="{{ .title }}" value="{{ .name }}">
|
||||
<label for="{{ .title }}">{{- $name -}} <span class="font_size_smaller" style="font-size: smaller;"> ({{ if .help -}} {{ .help }}{{ end }})</span></label>
|
||||
</div>
|
||||
{{ else if eq .input_type "results" }}
|
||||
<div id='result' class="w100"></div>
|
||||
|
@ -97,7 +98,7 @@
|
|||
{{ end }}
|
||||
</fieldset>
|
||||
{{ if .new }}
|
||||
<label for="new{{- .title -}}">{{ .new }} <span class="font_size_smaller">({{- $divide -}}{{- if .help -}}, {{ .help }}{{ end }})</span></label>
|
||||
<label for="new{{- .title -}}">{{ .new }} <span class="font_size_smaller" style="font-size: smaller;">({{- $divide -}}{{- if .help -}}, {{ .help }}{{ end }})</span></label>
|
||||
<input class="w100" type="text" name="new{{- .title -}}" id="new{{- .title -}}" value="" {{ if .placeholder }}placeholder="{{ .placeholder }}"{{ end }} />
|
||||
{{ end }}
|
||||
</div>
|
||||
|
@ -141,7 +142,7 @@
|
|||
{{ end }}
|
||||
</fieldset>
|
||||
{{ if .new }}
|
||||
<label for="new{{- .title -}}">{{ .new }} <span class="font_size_smaller">({{- $divide -}}{{- if .help -}}, {{ .help }}{{ end }})</span></label>
|
||||
<label for="new{{- .title -}}">{{ .new }} <span class="font_size_smaller" style="font-size: smaller;">({{- $divide -}}{{- if .help -}}, {{ .help }}{{ end }})</span></label>
|
||||
<input class="w100" type="text" name="new{{- .title -}}" id="new{{- .title -}}" value="" {{ if .placeholder }}placeholder="{{ .placeholder }}"{{ end }} />
|
||||
{{ end }}
|
||||
</div>
|
||||
|
@ -192,7 +193,7 @@
|
|||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
<label for="{{- .title -}}"><span class="font_size_smaller">({{- $divide -}}{{- if .help -}}, {{ .help }}{{ end }})</span></label>
|
||||
<label for="{{- .title -}}"><span class="font_size_smaller" style="font-size: smaller;">({{- $divide -}}{{- if .help -}}, {{ .help }}{{ end }})</span></label>
|
||||
<input class="w100" type="text" name="{{ $in0 }}" id="{{ $in0 }}" value="" {{ if .placeholder }}placeholder="{{ .placeholder }}"{{ end }} />
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
var zip = new JSZip();
|
||||
|
||||
function check_checkboxes(name) {
|
||||
const checkboxes = document.querySelectorAll(`input[name="${name}"]:checked`);
|
||||
let values = [];
|
||||
|
@ -22,18 +24,14 @@ function Input(str) {
|
|||
let target = arr[0];
|
||||
var id = document.getElementById(target);
|
||||
var value = id.value;
|
||||
|
||||
function typeInInputfield(newText, el = document.getElementById(target)) {
|
||||
const [start, end] = [el.selectionStart, el.selectionEnd];
|
||||
el.setRangeText(newText, start, end);
|
||||
}
|
||||
|
||||
var out = x;
|
||||
|
||||
if ( value ) {
|
||||
var out = "," + x;
|
||||
}
|
||||
|
||||
if (out != null) {
|
||||
typeInInputfield(out);
|
||||
var end = id.value.length;
|
||||
|
@ -42,20 +40,17 @@ function Input(str) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function Clear(name)
|
||||
{
|
||||
clearRadioGroup(name);
|
||||
}
|
||||
|
||||
function clearRadioGroup(name)
|
||||
{
|
||||
var ele = document.getElementsByName(name);
|
||||
for(var i=0;i<ele.length;i++)
|
||||
ele[i].checked = false;
|
||||
function handleFile(f) {
|
||||
var name = f.name;
|
||||
var data = f.raw;
|
||||
zip.file(name, data);
|
||||
}
|
||||
|
||||
function Clear(name) {
|
||||
var ele = document.getElementsByName(name);
|
||||
for(var i=0;i<ele.length;i++)
|
||||
ele[i].checked = false;
|
||||
}
|
||||
|
||||
function button(str) {
|
||||
var arr = str.split(";");
|
||||
|
@ -78,11 +73,30 @@ function button(str) {
|
|||
if (headline != null) {var out = "## " + headline + "\n\n";}
|
||||
}
|
||||
if (x == "pic") {
|
||||
let desc = prompt("Description", "Wikipedia logo");
|
||||
if (desc != null) {
|
||||
let pic = prompt("Please enter URL or Number", "https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png");
|
||||
if (pic != null) {var out = "![" + desc + "](" + pic + ") ";}
|
||||
|
||||
|
||||
var input = document.createElement('input');
|
||||
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 desc = prompt(p, "Wikipedia logo");
|
||||
if (desc) {
|
||||
zip.file(files[i].name, files[i]);
|
||||
var pic = files[i].name;
|
||||
var out = "![" + desc + "](" + pic + ") \n\n";
|
||||
typeInTextarea(out);
|
||||
var end = id.value.length;
|
||||
id.setSelectionRange(end, end);
|
||||
id.focus({preventScroll: true});
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (x == "bold") {
|
||||
let bold = prompt("Bold", "");
|
||||
|
@ -245,68 +259,81 @@ function showInput(e) {
|
|||
|
||||
|
||||
if (title) {
|
||||
display.innerHTML += "---<br>";
|
||||
display.innerHTML += "title: \"" + title.trim() + "\"<br>";
|
||||
var output = "---\n";
|
||||
var output = output + "title: \"" + title.trim() + "\"\n";
|
||||
|
||||
|
||||
if (lastmod) {
|
||||
display.innerHTML += "lastmod: " + lastmod.trim() + "<br>";
|
||||
var output = output + "lastmod: " + lastmod.trim() + "\n";
|
||||
} else {
|
||||
display.innerHTML += "date: " + datestring.trim() + "<br>";
|
||||
var output = output + "date: " + datestring.trim() + "\n";
|
||||
}
|
||||
|
||||
if (featured != '') {
|
||||
display.innerHTML += "featured: true<br>";
|
||||
var output = output + "featured: true\n";
|
||||
}
|
||||
|
||||
if (about != '') {
|
||||
display.innerHTML += "about: true<br>";
|
||||
var output = output + "about: true\n";
|
||||
}
|
||||
|
||||
if (recurrent != '') {
|
||||
display.innerHTML += "recurrent: true<br>";
|
||||
var output = output + "recurrent: true\n";
|
||||
}
|
||||
|
||||
if (when) {
|
||||
display.innerHTML += "when: \"" + when + "\"<br>";
|
||||
var output = output + "when: \"" + when + "\"\n";
|
||||
}
|
||||
|
||||
if (nnews) {
|
||||
display.innerHTML += "news: \[" + nnews + "]<br>";
|
||||
var output = output + "news: \[" + nnews + "]\n";
|
||||
}
|
||||
|
||||
if (nevents) {
|
||||
display.innerHTML += "events: \[" + nevents + "]<br>";
|
||||
var output = output + "events: \[" + nevents + "]\n";
|
||||
}
|
||||
|
||||
if (nfoundations) {
|
||||
display.innerHTML += "foundations: \[" + nfoundations + "]<br>";
|
||||
var output = output + "foundations: \[" + nfoundations + "]\n";
|
||||
}
|
||||
|
||||
if (alltags) {
|
||||
display.innerHTML += "tags: \[" + alltags + "]<br>";
|
||||
var output = output + "tags: \[" + alltags + "]\n";
|
||||
}
|
||||
if (covid) {
|
||||
display.innerHTML += "covid: \"" + covid + "\"<br>";
|
||||
var output = output + "covid: \"" + covid + "\"\n";
|
||||
}
|
||||
if (price) {
|
||||
display.innerHTML += "price: \"" + price + "\"<br>";
|
||||
var output = output + "price: \"" + price + "\"\n";
|
||||
}
|
||||
|
||||
if (contact_mail) {
|
||||
display.innerHTML += "contact_mail: \"" + contact_mail + "\"<br>";
|
||||
var output = output + "contact_mail: \"" + contact_mail + "\"\n";
|
||||
}
|
||||
if (insta) {
|
||||
display.innerHTML += "insta: \"" + insta + "\"<br>";
|
||||
var output = output + "insta: \"" + insta + "\"\n";
|
||||
}
|
||||
display.innerHTML += "---<br>";
|
||||
var output = output + "---\n";
|
||||
if (summary) {
|
||||
display.innerHTML += summary.trim() + "\n" + "<!--more-->" + "\n";
|
||||
var output = output + summary.trim() + "\n" + "<!--more-->" + "\n";
|
||||
}
|
||||
if (content) {
|
||||
display.innerHTML += content.trim();
|
||||
var output = output + content.trim();
|
||||
}
|
||||
if (output) {
|
||||
display.innerHTML += output.trim();
|
||||
}
|
||||
|
||||
// Add an top-level, arbitrary text file with contents
|
||||
zip.file("index.de.md", output);
|
||||
|
||||
|
||||
// Generate the zip file asynchronously
|
||||
zip.generateAsync({type:"blob"})
|
||||
.then(function(cont) {
|
||||
// Force down of the Zip file
|
||||
saveAs(cont, "archive.zip");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
188
themes/buha/static/js/jszip/filesaver.js
Normal file
188
themes/buha/static/js/jszip/filesaver.js
Normal file
|
@ -0,0 +1,188 @@
|
|||
(function (global, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define([], factory);
|
||||
} else if (typeof exports !== "undefined") {
|
||||
factory();
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory();
|
||||
global.FileSaver = mod.exports;
|
||||
}
|
||||
})(this, function () {
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
* FileSaver.js
|
||||
* A saveAs() FileSaver implementation.
|
||||
*
|
||||
* By Eli Grey, http://eligrey.com
|
||||
*
|
||||
* License : https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md (MIT)
|
||||
* source : http://purl.eligrey.com/github/FileSaver.js
|
||||
*/
|
||||
// The one and only way of getting global scope in all environments
|
||||
// https://stackoverflow.com/q/3277182/1008999
|
||||
var _global = typeof window === 'object' && window.window === window ? window : typeof self === 'object' && self.self === self ? self : typeof global === 'object' && global.global === global ? global : void 0;
|
||||
|
||||
function bom(blob, opts) {
|
||||
if (typeof opts === 'undefined') opts = {
|
||||
autoBom: false
|
||||
};else if (typeof opts !== 'object') {
|
||||
console.warn('Deprecated: Expected third argument to be a object');
|
||||
opts = {
|
||||
autoBom: !opts
|
||||
};
|
||||
} // prepend BOM for UTF-8 XML and text/* types (including HTML)
|
||||
// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
|
||||
|
||||
if (opts.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
|
||||
return new Blob([String.fromCharCode(0xFEFF), blob], {
|
||||
type: blob.type
|
||||
});
|
||||
}
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
function download(url, name, opts) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url);
|
||||
xhr.responseType = 'blob';
|
||||
|
||||
xhr.onload = function () {
|
||||
saveAs(xhr.response, name, opts);
|
||||
};
|
||||
|
||||
xhr.onerror = function () {
|
||||
console.error('could not download file');
|
||||
};
|
||||
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
function corsEnabled(url) {
|
||||
var xhr = new XMLHttpRequest(); // use sync to avoid popup blocker
|
||||
|
||||
xhr.open('HEAD', url, false);
|
||||
|
||||
try {
|
||||
xhr.send();
|
||||
} catch (e) {}
|
||||
|
||||
return xhr.status >= 200 && xhr.status <= 299;
|
||||
} // `a.click()` doesn't work for all browsers (#465)
|
||||
|
||||
|
||||
function click(node) {
|
||||
try {
|
||||
node.dispatchEvent(new MouseEvent('click'));
|
||||
} catch (e) {
|
||||
var evt = document.createEvent('MouseEvents');
|
||||
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
|
||||
node.dispatchEvent(evt);
|
||||
}
|
||||
} // Detect WebView inside a native macOS app by ruling out all browsers
|
||||
// We just need to check for 'Safari' because all other browsers (besides Firefox) include that too
|
||||
// https://www.whatismybrowser.com/guides/the-latest-user-agent/macos
|
||||
|
||||
|
||||
var isMacOSWebView = /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent);
|
||||
var saveAs = _global.saveAs || ( // probably in some web worker
|
||||
typeof window !== 'object' || window !== _global ? function saveAs() {}
|
||||
/* noop */
|
||||
// Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView
|
||||
: 'download' in HTMLAnchorElement.prototype && !isMacOSWebView ? function saveAs(blob, name, opts) {
|
||||
var URL = _global.URL || _global.webkitURL;
|
||||
var a = document.createElement('a');
|
||||
name = name || blob.name || 'download';
|
||||
a.download = name;
|
||||
a.rel = 'noopener'; // tabnabbing
|
||||
// TODO: detect chrome extensions & packaged apps
|
||||
// a.target = '_blank'
|
||||
|
||||
if (typeof blob === 'string') {
|
||||
// Support regular links
|
||||
a.href = blob;
|
||||
|
||||
if (a.origin !== location.origin) {
|
||||
corsEnabled(a.href) ? download(blob, name, opts) : click(a, a.target = '_blank');
|
||||
} else {
|
||||
click(a);
|
||||
}
|
||||
} else {
|
||||
// Support blobs
|
||||
a.href = URL.createObjectURL(blob);
|
||||
setTimeout(function () {
|
||||
URL.revokeObjectURL(a.href);
|
||||
}, 4E4); // 40s
|
||||
|
||||
setTimeout(function () {
|
||||
click(a);
|
||||
}, 0);
|
||||
}
|
||||
} // Use msSaveOrOpenBlob as a second approach
|
||||
: 'msSaveOrOpenBlob' in navigator ? function saveAs(blob, name, opts) {
|
||||
name = name || blob.name || 'download';
|
||||
|
||||
if (typeof blob === 'string') {
|
||||
if (corsEnabled(blob)) {
|
||||
download(blob, name, opts);
|
||||
} else {
|
||||
var a = document.createElement('a');
|
||||
a.href = blob;
|
||||
a.target = '_blank';
|
||||
setTimeout(function () {
|
||||
click(a);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
navigator.msSaveOrOpenBlob(bom(blob, opts), name);
|
||||
}
|
||||
} // Fallback to using FileReader and a popup
|
||||
: function saveAs(blob, name, opts, popup) {
|
||||
// Open a popup immediately do go around popup blocker
|
||||
// Mostly only available on user interaction and the fileReader is async so...
|
||||
popup = popup || open('', '_blank');
|
||||
|
||||
if (popup) {
|
||||
popup.document.title = popup.document.body.innerText = 'downloading...';
|
||||
}
|
||||
|
||||
if (typeof blob === 'string') return download(blob, name, opts);
|
||||
var force = blob.type === 'application/octet-stream';
|
||||
|
||||
var isSafari = /constructor/i.test(_global.HTMLElement) || _global.safari;
|
||||
|
||||
var isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent);
|
||||
|
||||
if ((isChromeIOS || force && isSafari || isMacOSWebView) && typeof FileReader !== 'undefined') {
|
||||
// Safari doesn't allow downloading of blob URLs
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onloadend = function () {
|
||||
var url = reader.result;
|
||||
url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, 'data:attachment/file;');
|
||||
if (popup) popup.location.href = url;else location = url;
|
||||
popup = null; // reverse-tabnabbing #460
|
||||
};
|
||||
|
||||
reader.readAsDataURL(blob);
|
||||
} else {
|
||||
var URL = _global.URL || _global.webkitURL;
|
||||
var url = URL.createObjectURL(blob);
|
||||
if (popup) popup.location = url;else location.href = url;
|
||||
popup = null; // reverse-tabnabbing #460
|
||||
|
||||
setTimeout(function () {
|
||||
URL.revokeObjectURL(url);
|
||||
}, 4E4); // 40s
|
||||
}
|
||||
});
|
||||
_global.saveAs = saveAs.saveAs = saveAs;
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
module.exports = saveAs;
|
||||
}
|
||||
});
|
11583
themes/buha/static/js/jszip/jszip.js
Normal file
11583
themes/buha/static/js/jszip/jszip.js
Normal file
File diff suppressed because it is too large
Load Diff
13
themes/buha/static/js/jszip/jszip.min.js
vendored
Normal file
13
themes/buha/static/js/jszip/jszip.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user