fsd
This commit is contained in:
parent
071f47bec4
commit
d6936395b7
2 changed files with 42 additions and 43 deletions
|
@ -1,3 +1,39 @@
|
|||
document.getElementById('post-title').value = localStorage.getItem("post_title")
|
||||
document.getElementById('post-text').value = localStorage.getItem("post_text")
|
||||
document.getElementById('post-url').value = localStorage.getItem("post_url")
|
||||
|
||||
function checkForRequired() {
|
||||
const title = document.getElementById("post-title");
|
||||
const url = document.getElementById("post-url");
|
||||
const text = document.getElementById("post-text");
|
||||
const button = document.getElementById("create_button");
|
||||
const image = document.getElementById("file-upload");
|
||||
const image2 = document.getElementById("file-upload-submit");
|
||||
|
||||
if (url.value.length > 0 || image.files.length > 0 || image2.files.length > 0) {
|
||||
text.required = false;
|
||||
url.required=false;
|
||||
} else if (text.value.length > 0 || image.files.length > 0 || image2.files.length > 0) {
|
||||
url.required = false;
|
||||
} else {
|
||||
text.required = true;
|
||||
url.required = true;
|
||||
}
|
||||
|
||||
const isValidTitle = title.checkValidity();
|
||||
const isValidURL = url.checkValidity();
|
||||
const isValidText = text.checkValidity();
|
||||
|
||||
if (isValidTitle && (isValidURL || image.files.length > 0 || image2.files.length > 0)) {
|
||||
button.disabled = false;
|
||||
} else if (isValidTitle && isValidText) {
|
||||
button.disabled = false;
|
||||
} else {
|
||||
button.disabled = true;
|
||||
}
|
||||
}
|
||||
checkForRequired();
|
||||
|
||||
function hide_image() {
|
||||
x=document.getElementById('image-upload-block');
|
||||
url=document.getElementById('post-url').value;
|
||||
|
@ -44,7 +80,7 @@ document.getElementById('file-upload').addEventListener('change', function(){
|
|||
f=document.getElementById('file-upload');
|
||||
document.getElementById('urlblock').classList.add('d-none');
|
||||
document.getElementById('filename-show').textContent = document.getElementById('file-upload').files[0].name.substr(0, 20);
|
||||
filename = f.files[0].name.toLowerCase().substr(0, 20)
|
||||
filename = f.files[0].name.toLowerCase()
|
||||
if (filename.endsWith(".jpg") || filename.endsWith(".jpeg") || filename.endsWith(".png") || filename.endsWith(".webp") || filename.endsWith(".webp"))
|
||||
{
|
||||
var fileReader = new FileReader();
|
||||
|
|
|
@ -220,53 +220,16 @@
|
|||
</div>
|
||||
{% endblock %}
|
||||
|
||||
<script>
|
||||
document.getElementById('post-title').value = localStorage.getItem("post_title")
|
||||
document.getElementById('post-text').value = localStorage.getItem("post_text")
|
||||
document.getElementById('post-url').value = localStorage.getItem("post_url")
|
||||
|
||||
{% if request.path == '/submit' %}
|
||||
{% if request.path == '/submit' %}
|
||||
<script>
|
||||
let sub = document.getElementById('sub')
|
||||
if (sub) sub.value = localStorage.getItem("sub")
|
||||
{% endif %}
|
||||
|
||||
function checkForRequired() {
|
||||
|
||||
var title = document.getElementById("post-title");
|
||||
var url = document.getElementById("post-url");
|
||||
var text = document.getElementById("post-text");
|
||||
var button = document.getElementById("create_button");
|
||||
var image = document.getElementById("file-upload");
|
||||
var image2 = document.getElementById("file-upload-submit");
|
||||
|
||||
if (url.value.length > 0 || image.value.length > 0 || image2.value.length > 0) {
|
||||
text.required = false;
|
||||
url.required=false;
|
||||
} else if (text.value.length > 0 || image.value.length > 0 || image2.value.length > 0) {
|
||||
url.required = false;
|
||||
} else {
|
||||
text.required = true;
|
||||
url.required = true;
|
||||
}
|
||||
|
||||
var isValidTitle = title.checkValidity();
|
||||
var isValidURL = url.checkValidity();
|
||||
var isValidText = text.checkValidity();
|
||||
|
||||
if (isValidTitle && (isValidURL || image.value.length > 0 || image2.value.length > 0)) {
|
||||
button.disabled = false;
|
||||
} else if (isValidTitle && isValidText) {
|
||||
button.disabled = false;
|
||||
} else {
|
||||
button.disabled = true;
|
||||
}
|
||||
}
|
||||
checkForRequired()
|
||||
</script>
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
<script src="/assets/js/marked.js?v=250"></script>
|
||||
<script src="/assets/js/formatting.js?v=240"></script>
|
||||
<script src="/assets/js/submit.js?v=253"></script>
|
||||
<script src="/assets/js/submit.js?v=254"></script>
|
||||
{% include "emoji_modal.html" %}
|
||||
{% include "gif_modal.html" %}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue