forked from rDrama/rDrama
1
0
Fork 0
master
Aevann1 2021-09-26 13:28:01 +02:00
parent 2eb6e5fbdd
commit 8c584b57a9
1 changed files with 50 additions and 50 deletions

View File

@ -151,83 +151,83 @@
};
// // Run AutoSuggestTitle function on load
// Run AutoSuggestTitle function on load
// if (window.location.pathname=='/submit') {
// window.onload = autoSuggestTitle();
// }
if (window.location.pathname=='/submit') {
window.onload = autoSuggestTitle();
}
// // Paste to create submission
// Paste to create submission
// document.addEventListener('paste', function (event) {
document.addEventListener('paste', function (event) {
// var nothingFocused = document.activeElement === document.body;
var nothingFocused = document.activeElement === document.body;
// if (nothingFocused) {
if (nothingFocused) {
// var clipText = event.clipboardData.getData('Text');
var clipText = event.clipboardData.getData('Text');
// var url = new RegExp('^(?:[a-z]+:)?//', 'i');
var url = new RegExp('^(?:[a-z]+:)?//', 'i');
// if (url.test(clipText) && window.location.pathname !== '/submit') {
// window.location.href = '/submit?url=' + clipText;
// }
// else if (url.test(clipText) && window.location.pathname == '/submit') {
if (url.test(clipText) && window.location.pathname !== '/submit') {
window.location.href = '/submit?url=' + clipText;
}
else if (url.test(clipText) && window.location.pathname == '/submit') {
// document.getElementById("post-URL").value = clipText;
document.getElementById("post-URL").value = clipText;
// autoSuggestTitle()
autoSuggestTitle()
// }
// }
// });
}
}
});
// Submit Page Front-end Validation
Submit Page Front-end Validation
// function checkForRequired() {
function checkForRequired() {
// // Divs
// Divs
// var title = document.getElementById("post-title");
var title = document.getElementById("post-title");
// var url = document.getElementById("post-URL");
var url = document.getElementById("post-URL");
// var text = document.getElementById("post-text");
var text = document.getElementById("post-text");
// var button = document.getElementById("create_button");
var button = document.getElementById("create_button");
// var image = document.getElementById("file-upload");
var image = document.getElementById("file-upload");
// // Toggle reuqired attribute
// Toggle reuqired attribute
// if (url.value.length > 0 || image.value.length > 0) {
// text.required = false;
// url.required=false;
// } else if (text.value.length > 0 || image.value.length > 0) {
// url.required = false;
// } else {
// text.required = true;
// url.required = true;
// }
if (url.value.length > 0 || image.value.length > 0) {
text.required = false;
url.required=false;
} else if (text.value.length > 0 || image.value.length > 0) {
url.required = false;
} else {
text.required = true;
url.required = true;
}
// // Validity check
// Validity check
// var isValidTitle = title.checkValidity();
var isValidTitle = title.checkValidity();
// var isValidURL = url.checkValidity();
var isValidURL = url.checkValidity();
// var isValidText = text.checkValidity();
var isValidText = text.checkValidity();
// // Disable submit button if invalid inputs
// Disable submit button if invalid inputs
// if (isValidTitle && (isValidURL || image.value.length>0)) {
// button.disabled = false;
// } else if (isValidTitle && isValidText) {
// button.disabled = false;
// } else {
// button.disabled = true;
// }
// }
if (isValidTitle && (isValidURL || image.value.length>0)) {
button.disabled = false;
} else if (isValidTitle && isValidText) {
button.disabled = false;
} else {
button.disabled = true;
}
}
// markdown