forked from MarseyWorld/MarseyWorld
106 lines
3.8 KiB
HTML
106 lines
3.8 KiB
HTML
{% extends "default.html" %}
|
|
|
|
{% block title %}
|
|
<title>Update {{type}}</title>
|
|
{% endblock %}
|
|
|
|
{% block pagetype %}message{% endblock %}
|
|
|
|
{% block content %}
|
|
{% if error %}
|
|
<div class="alert alert-danger alert-dismissible fade show mb-3 mt-4" role="alert">
|
|
<i class="fas fa-exclamation-circle my-auto"></i>
|
|
<span>
|
|
{{error}}
|
|
</span>
|
|
<button class="close" data-bs-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true"><i class="far fa-times"></i></span>
|
|
</button>
|
|
</div>
|
|
{% endif %}
|
|
{% if msg %}
|
|
<div class="alert alert-success alert-dismissible fade show my-3" role="alert">
|
|
<i class="fas fa-check-circle my-auto" aria-hidden="true"></i>
|
|
<span>
|
|
{{msg}}
|
|
</span>
|
|
<button class="close" data-bs-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true"><i class="far fa-times"></i></span>
|
|
</button>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="mx-4">
|
|
<h2 class="mt-5">Update {{type}}</h2>
|
|
<div class="settings-section rounded">
|
|
<div class="d-lg-flex">
|
|
<div class="body w-lg-100">
|
|
<form action="{{request.path}}" method="post" enctype="multipart/form-data">
|
|
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
|
|
|
<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>
|
|
<input autocomplete="off" id="file-upload" accept="image/*" type="file" name="image" {% if request.headers.get('cf-ipcountry')=="T1" %}disabled{% endif %} hidden>
|
|
</label>
|
|
</div>
|
|
|
|
<label class="mt-3" for="name">Name</label>
|
|
<input autocomplete="off" type="text" id="name" class="form-control" name="name" maxlength="30" placeholder="Required" value="{{name}}" required>
|
|
|
|
<div class="footer mt-4">
|
|
<div class="d-flex">
|
|
<input id="update-asset" type="submit" onclick="disable(this)" class="btn btn-primary ml-auto" value="Update {{type}}">
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.onpaste = function(event) {
|
|
files = event.clipboardData.files
|
|
|
|
filename = files[0]
|
|
|
|
if (filename)
|
|
{
|
|
filename = filename.name.toLowerCase()
|
|
f=document.getElementById('file-upload');
|
|
f.files = files;
|
|
document.getElementById('filename-show').textContent = filename;
|
|
if (filename.endsWith(".jpg") || filename.endsWith(".jpeg") || filename.endsWith(".png") || filename.endsWith(".gif") || filename.endsWith(".webp"))
|
|
{
|
|
var fileReader = new FileReader();
|
|
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').setAttribute('placeholder="Required" required', 'false');
|
|
}
|
|
}
|
|
|
|
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()
|
|
if (filename.endsWith(".jpg") || filename.endsWith(".jpeg") || filename.endsWith(".png") || filename.endsWith(".gif") || filename.endsWith(".webp"))
|
|
{
|
|
var fileReader = new FileReader();
|
|
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('submit-asset').disabled = false;
|
|
}
|
|
})
|
|
</script>
|
|
{% endblock %} |