2022-09-10 05:37:11 +00:00
|
|
|
{% extends "default.html" %}
|
|
|
|
|
|
|
|
{% block title %}
|
|
|
|
<title>Submit Hats</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">Submit Hat</h2>
|
|
|
|
<div class="settings-section rounded">
|
|
|
|
<div class="d-lg-flex">
|
|
|
|
<div class="body w-lg-100">
|
|
|
|
<form action="/submit/hats" 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" style="max-width:50%">
|
|
|
|
<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="50" pattern='[a-zA-Z0-9\-() ,_]{1,50}' required>
|
|
|
|
|
|
|
|
<label class="mt-3" for="author">Author</label>
|
|
|
|
<input autocomplete="off" type="text" id="author" class="form-control" name="author" value="{{v.username.lower()}}" maxlength="30" pattern='[a-z0-9_\-]{3,30}' required>
|
|
|
|
|
|
|
|
<label class="mt-3" for="description">Description</label>
|
|
|
|
<input autocomplete="off" type="text" id="description" class="form-control" name="description" maxlength="300" pattern='[^<>]{1,300}' required>
|
|
|
|
|
|
|
|
<div class="footer mt-5">
|
|
|
|
<div class="d-flex">
|
|
|
|
<input id="submit-hat" disabled type="submit" onclick="disable(this)" class="btn btn-primary ml-auto" value="Submit Hat">
|
|
|
|
</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('file-upload').setAttribute('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('submit-hat').disabled = false;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
function approve_hat(t, name) {
|
|
|
|
t.disabled = true;
|
|
|
|
t.classList.add("disabled");
|
|
|
|
post_toast_callback(`/admin/approve/hat/${name}`,
|
|
|
|
{
|
|
|
|
"description": document.getElementById(`${name}-description`).value,
|
|
|
|
"name": document.getElementById(`${name}-name`).value,
|
|
|
|
"price": document.getElementById(`${name}-price`).value,
|
|
|
|
},
|
|
|
|
(xhr) => {
|
|
|
|
if(xhr.status == 200) {
|
2022-09-10 09:31:43 +00:00
|
|
|
document.getElementById(`${name}-hat`).remove()
|
2022-09-10 05:37:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
setTimeout(() => {
|
|
|
|
t.disabled = false;
|
|
|
|
t.classList.remove("disabled");
|
|
|
|
}, 2000);
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<h2 class="mt-5 mx-4">Pending Carp Approval</h2>
|
|
|
|
<div class="row mt-5 mx-4">
|
|
|
|
<div class="col px-0">
|
|
|
|
<div class="settings">
|
|
|
|
{% for hat in hats %}
|
|
|
|
<div id="{{hat.name}}-hat" 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-10 11:07:58 +00:00
|
|
|
<img loading="lazy" src="/asset_submissions/hats/{{hat.name}}.webp" style="max-width:50%">
|
2022-09-10 05:37:11 +00:00
|
|
|
|
|
|
|
<div><label class="mt-3" for="{{hat.name}}-submitter">Submitter</label></div>
|
|
|
|
<input autocomplete="off" type="text" id="{{hat.name}}-submitter" class="form-control" maxlength="30" value="{{hat.submitter.username}}" readonly>
|
|
|
|
|
|
|
|
<label class="mt-3" for="{{hat.name}}-author">Author</label>
|
|
|
|
<input autocomplete="off" type="text" id="{{hat.name}}-author" class="form-control" maxlength="30" value="{{hat.author.username}}" readonly>
|
|
|
|
|
|
|
|
<label class="mt-3" for="{{hat.name}}-name">Name</label>
|
|
|
|
<input autocomplete="off" type="text" id="{{hat.name}}-name" class="form-control" name="name" maxlength="30" value="{{hat.name}}" pattern='hat[a-z0-9]{1,24}' required>
|
|
|
|
|
|
|
|
<label class="mt-3" for="{{hat.name}}-description">Description</label>
|
|
|
|
<input autocomplete="off" type="text" id="{{hat.name}}-description" class="form-control" name="description" maxlength="300" value="{{hat.description}}" pattern='[^<>&\n\t]{1,300}' required>
|
|
|
|
|
|
|
|
<div><label class="mt-3" for="{{hat.name}}-price">Price</label></div>
|
|
|
|
<input autocomplete="off" type="number" id="{{hat.name}}-price" class="form-control" name="price" min="0" value="{{hat.price}}" required>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% if v.admin_level > 2 %}
|
|
|
|
<div class="d-flex my-4 mx-3">
|
|
|
|
<a role="button" class="btn btn-secondary ml-auto mr-2" onclick="post_toast(this,'/admin/reject/hat/{{hat.name}}', true)">Reject</a>
|
|
|
|
<a role="button" class="btn btn-primary mr-0" onclick="approve_hat(this, '{{hat.name}}')">Approve</a>
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% endblock %}
|