2022-09-17 15:08:24 +00:00
{% extends "default.html" %}
2022-11-19 22:20:38 +00:00
{% block pagetitle %}Update {{type}}{% endblock %}
2022-09-17 15:08:24 +00:00
{% block pagetype %}message{% endblock %}
{% block content %}
2022-12-11 23:44:34 +00:00
{% if error %}{{macros.alert(error, true)}}{% endif %}
{% if msg %}{{macros.alert(msg, false)}}{% endif %}
2022-09-17 15:08:24 +00:00
< div class = "mx-4" >
2022-09-18 17:38:53 +00:00
< h2 class = "mt-5" > Update {{type}}< / h2 >
2022-09-17 15:08:24 +00:00
< div class = "settings-section rounded" >
< div class = "d-lg-flex" >
< div class = "body w-lg-100" >
2022-09-18 17:38:53 +00:00
< form action = "{{request.path}}" method = "post" enctype = "multipart/form-data" >
2022-11-15 09:19:08 +00:00
< input type = "hidden" name = "formkey" value = "{{v|formkey}}" >
2022-09-17 15:08:24 +00:00
< div id = "image-upload-block" >
< div > < label class = "mt-3" > Image< / label > < / div >
< img loading = "lazy" id = "image-preview" class = "d-none" style = "max-width:50%;border:5px white solid" >
< label class = "btn btn-secondary m-0" for = "file-upload" >
< div id = "filename-show" > Select Image< / div >
2022-11-15 09:19:08 +00:00
< input autocomplete = "off" id = "file-upload" accept = "image/*" type = "file" name = "image" { % if g . is_tor % } disabled { % endif % } hidden >
2022-09-17 15:08:24 +00:00
< / label >
< / div >
< label class = "mt-3" for = "name" > Name< / label >
2022-11-05 21:08:41 +00:00
< input autocomplete = "off" type = "text" id = "name" class = "form-control" name = "name" maxlength = "30" placeholder = "Required" { % if name % } value = "{{name}}" { % endif % } required >
2022-09-17 15:08:24 +00:00
2022-10-19 23:45:44 +00:00
{% if type == "Marsey" %}
2022-10-19 22:45:05 +00:00
< label class = "mt-3" for = "tags" > Tags< / label >
2022-11-05 21:08:41 +00:00
< input autocomplete = "off" type = "text" id = "name" class = "form-control" name = "tags" maxlength = "200" placeholder = "Leave empty to keep current tags" { % if tags % } value = "{{tags}}" { % endif % } >
2022-10-19 23:45:44 +00:00
{% endif %}
2022-09-17 15:08:24 +00:00
< div class = "footer mt-4" >
< div class = "d-flex" >
2022-09-18 17:38:53 +00:00
< input id = "update-asset" type = "submit" onclick = "disable(this)" class = "btn btn-primary ml-auto" value = "Update {{type}}" >
2022-09-17 15:08:24 +00:00
< / div >
< / div >
< / form >
< / div >
< / div >
< / div >
< / div >
2022-12-27 01:22:39 +00:00
< script nonce = "{{g.nonce}}" >
2022-09-17 15:08:24 +00:00
document.onpaste = function(event) {
2022-11-13 14:16:42 +00:00
files = structuredClone(event.clipboardData.files);
2022-09-17 15:08:24 +00:00
filename = files[0]
if (filename)
{
filename = filename.name.toLowerCase()
f=document.getElementById('file-upload');
f.files = files;
document.getElementById('filename-show').textContent = filename;
2022-11-05 21:01:23 +00:00
if (IMAGE_FORMATS.some(s => filename.endsWith(s)))
2022-09-17 15:08:24 +00:00
{
2022-12-04 15:40:32 +00:00
const fileReader = new FileReader();
2022-09-17 15:08:24 +00:00
fileReader.readAsDataURL(f.files[0]);
fileReader.addEventListener("load", function () {
document.getElementById('image-preview').setAttribute('src', this.result);
document.getElementById('image-preview').classList.remove('d-none');
});
}
}
}
document.getElementById('file-upload').addEventListener('change', function(){
f=document.getElementById('file-upload');
document.getElementById('filename-show').textContent = document.getElementById('file-upload').files[0].name.substr(0, 20);
filename = f.files[0].name.toLowerCase()
2022-11-05 21:01:23 +00:00
if (IMAGE_FORMATS.some(s => filename.endsWith(s)))
2022-09-17 15:08:24 +00:00
{
2022-12-04 15:40:32 +00:00
const fileReader = new FileReader();
2022-09-17 15:08:24 +00:00
fileReader.readAsDataURL(f.files[0]);
fileReader.addEventListener("load", function () {
document.getElementById('image-preview').setAttribute('src', this.result);
document.getElementById('image-preview').classList.remove('d-none');
});
2022-09-18 17:38:53 +00:00
document.getElementById('submit-asset').disabled = false;
2022-09-17 15:08:24 +00:00
}
})
< / script >
2022-10-23 09:27:20 +00:00
{% endblock %}