2022-09-09 09:13:50 +00:00
|
|
|
{% extends "default.html" %}
|
|
|
|
|
|
|
|
{% block title %}
|
|
|
|
<title>Submit Marseys</title>
|
|
|
|
{% endblock %}
|
|
|
|
|
2022-09-09 23:57:45 +00:00
|
|
|
{% block pagetype %}message{% endblock %}
|
|
|
|
|
2022-09-09 09:13:50 +00:00
|
|
|
{% block content %}
|
2022-09-09 09:39:03 +00:00
|
|
|
<style>
|
2022-09-09 09:44:49 +00:00
|
|
|
input:not(.btn) {
|
2022-09-09 09:39:03 +00:00
|
|
|
text-transform: lowercase;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
2022-09-10 00:07:17 +00:00
|
|
|
{% 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 %}
|
|
|
|
|
2022-09-09 09:13:50 +00:00
|
|
|
<div class="mx-4">
|
|
|
|
<h2 class="mt-5">Submit Marsey</h2>
|
|
|
|
<div class="settings-section rounded">
|
|
|
|
<div class="d-lg-flex">
|
|
|
|
<div class="body w-lg-100">
|
2022-09-10 00:07:17 +00:00
|
|
|
<form action="/submit/marseys" method="post" enctype="multipart/form-data">
|
2022-09-09 09:13:50 +00:00
|
|
|
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
|
|
|
|
|
|
|
<div id="image-upload-block">
|
|
|
|
<div><label class="mt-3">Image</label></div>
|
|
|
|
|
2022-09-11 06:33:36 +00:00
|
|
|
<img loading="lazy" id="image-preview" class="d-none" style="max-width:50%;border:5px white solid">
|
2022-09-09 09:13:50 +00:00
|
|
|
<label class="btn btn-secondary m-0" for="file-upload">
|
2022-09-09 09:47:14 +00:00
|
|
|
<div id="filename-show">Select Image</div>
|
2022-09-09 09:13:50 +00:00
|
|
|
<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>
|
2022-09-13 11:00:47 +00:00
|
|
|
<input autocomplete="off" type="text" id="name" class="form-control" name="name" maxlength="30" pattern='[Mm][Aa][Rr][Ss][Ee][Yy][a-zA-Z0-9]{1,24}' placeholder="Required" value="{{name}}" required>
|
2022-09-09 09:13:50 +00:00
|
|
|
|
|
|
|
<label class="mt-3" for="author">Author</label>
|
2022-09-13 11:00:47 +00:00
|
|
|
<input autocomplete="off" type="text" id="author" class="form-control" name="author" maxlength="30" pattern='[a-zA-Z0-9_\-]{3,30}' placeholder="Required" value="{{username}}" required>
|
2022-09-09 09:13:50 +00:00
|
|
|
|
2022-09-09 09:39:03 +00:00
|
|
|
<label class="mt-3" for="tags">Tags (must be separated by spaces)</label>
|
2022-09-13 11:00:47 +00:00
|
|
|
<input autocomplete="off" type="text" id="tags" class="form-control" name="tags" maxlength="200" pattern='[a-zA-Z0-9: ]{1,200}' placeholder="Required" value="{{tags}}" required>
|
2022-09-09 09:13:50 +00:00
|
|
|
|
|
|
|
<div class="footer mt-5">
|
|
|
|
<div class="d-flex">
|
|
|
|
<input id="submit-marsey" disabled type="submit" onclick="disable(this)" class="btn btn-primary ml-auto" value="Submit Marsey">
|
|
|
|
</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()
|
2022-09-10 00:15:06 +00:00
|
|
|
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]);
|
2022-09-11 06:33:36 +00:00
|
|
|
fileReader.addEventListener("load", function () {
|
|
|
|
document.getElementById('image-preview').setAttribute('src', this.result);
|
|
|
|
document.getElementById('image-preview').classList.remove('d-none');
|
|
|
|
});
|
2022-09-09 09:13:50 +00:00
|
|
|
}
|
2022-09-12 07:11:18 +00:00
|
|
|
document.getElementById('file-upload').setAttribute('placeholder="Required" required', 'false');
|
2022-09-09 09:13:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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]);
|
2022-09-11 06:33:36 +00:00
|
|
|
fileReader.addEventListener("load", function () {
|
|
|
|
document.getElementById('image-preview').setAttribute('src', this.result);
|
|
|
|
document.getElementById('image-preview').classList.remove('d-none');
|
|
|
|
});
|
2022-09-09 09:13:50 +00:00
|
|
|
document.getElementById('submit-marsey').disabled = false;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
function approve_marsey(t, name) {
|
|
|
|
t.disabled = true;
|
|
|
|
t.classList.add("disabled");
|
|
|
|
post_toast_callback(`/admin/approve/marsey/${name}`,
|
|
|
|
{
|
|
|
|
"tags": document.getElementById(`${name}-tags`).value,
|
2022-09-10 04:36:24 +00:00
|
|
|
"name": document.getElementById(`${name}-name`).value,
|
2022-09-09 09:13:50 +00:00
|
|
|
},
|
|
|
|
(xhr) => {
|
|
|
|
if(xhr.status == 200) {
|
2022-09-10 09:31:43 +00:00
|
|
|
document.getElementById(`${name}-marsey`).remove()
|
2022-09-09 09:13:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
setTimeout(() => {
|
|
|
|
t.disabled = false;
|
|
|
|
t.classList.remove("disabled");
|
|
|
|
}, 2000);
|
|
|
|
}
|
2022-09-11 07:03:34 +00:00
|
|
|
|
|
|
|
function remove_marsey(t, name) {
|
|
|
|
t.disabled = true;
|
|
|
|
t.classList.add("disabled");
|
|
|
|
post_toast_callback(`/remove/marsey/${name}`,
|
|
|
|
{
|
|
|
|
},
|
|
|
|
(xhr) => {
|
|
|
|
if(xhr.status == 200) {
|
|
|
|
document.getElementById(`${name}-marsey`).remove()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
setTimeout(() => {
|
|
|
|
t.disabled = false;
|
|
|
|
t.classList.remove("disabled");
|
|
|
|
}, 2000);
|
|
|
|
}
|
2022-09-09 09:13:50 +00:00
|
|
|
</script>
|
|
|
|
|
2022-09-09 23:41:54 +00:00
|
|
|
<h2 class="mt-5 mx-4">Pending Carp Approval</h2>
|
2022-09-09 09:13:50 +00:00
|
|
|
<div class="row mt-5 mx-4">
|
|
|
|
<div class="col px-0">
|
|
|
|
<div class="settings">
|
|
|
|
{% for marsey in marseys %}
|
|
|
|
<div id="{{marsey.name}}-marsey" class="settings-section rounded">
|
|
|
|
<div class="d-lg-flex">
|
|
|
|
<div class="body w-lg-100">
|
|
|
|
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
|
|
|
|
|
|
|
<div><label class="mt-3">Image</label></div>
|
2022-09-13 10:47:50 +00:00
|
|
|
<img loading="lazy" src="/asset_submissions/marseys/{{marsey.name}}.webp?s={{range(1, 10000000)|random}}" style="max-width:50%;border:5px white solid">
|
2022-09-09 09:13:50 +00:00
|
|
|
|
2022-09-10 05:37:11 +00:00
|
|
|
<div><label class="mt-3" for="{{marsey.name}}-submitter">Submitter</label></div>
|
|
|
|
<input autocomplete="off" type="text" id="{{marsey.name}}-submitter" class="form-control" maxlength="30" value="{{marsey.submitter}}" readonly>
|
|
|
|
|
2022-09-09 09:13:50 +00:00
|
|
|
<label class="mt-3" for="{{marsey.name}}-author">Author</label>
|
|
|
|
<input autocomplete="off" type="text" id="{{marsey.name}}-author" class="form-control" maxlength="30" value="{{marsey.author}}" readonly>
|
2022-09-10 05:37:11 +00:00
|
|
|
|
|
|
|
<label class="mt-3" for="{{marsey.name}}-name">Name</label>
|
2022-09-12 07:11:18 +00:00
|
|
|
<input autocomplete="off" type="text" id="{{marsey.name}}-name" class="form-control" name="name" maxlength="30" value="{{marsey.name}}" pattern='marsey[a-z0-9]{1,24}' placeholder="Required" required>
|
2022-09-10 05:37:11 +00:00
|
|
|
|
2022-09-09 09:13:50 +00:00
|
|
|
<label class="mt-3" for="{{marsey.name}}-tags">Tags</label>
|
2022-09-12 07:11:18 +00:00
|
|
|
<input autocomplete="off" type="text" id="{{marsey.name}}-tags" class="form-control" name="tags" maxlength="200" value="{{marsey.tags}}" pattern='[a-z0-9: ]{1,200}' placeholder="Required" required>
|
2022-09-09 09:13:50 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-09-11 07:03:34 +00:00
|
|
|
<div class="d-flex my-4 mx-3">
|
2022-10-28 20:08:32 +00:00
|
|
|
<button role="button" class="btn btn-primary ml-auto" onclick="remove_marsey(this, '{{marsey.name}}')">Remove</button>
|
2022-10-06 06:56:37 +00:00
|
|
|
{% if v.admin_level >= PERMS['MODERATE_PENDING_SUBMITTED_MARSEYS'] %}
|
2022-10-28 20:08:32 +00:00
|
|
|
<button role="button" class="btn btn-primary ml-3" onclick="approve_marsey(this, '{{marsey.name}}')">Approve</button>
|
2022-09-11 07:03:34 +00:00
|
|
|
{% endif %}
|
|
|
|
</div>
|
2022-09-09 09:13:50 +00:00
|
|
|
</div>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% endblock %}
|