sneed
parent
6d21ad0272
commit
691b80431c
|
@ -3,6 +3,42 @@
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<script>
|
<script>
|
||||||
|
// Auto-suggest title given URL
|
||||||
|
|
||||||
|
function autoSuggestTitle() {
|
||||||
|
|
||||||
|
var urlField = document.getElementById("post-URL");
|
||||||
|
|
||||||
|
var titleField = document.getElementById("post-title");
|
||||||
|
|
||||||
|
var isValidURL = urlField.checkValidity();
|
||||||
|
|
||||||
|
if (isValidURL && urlField.value.length > 0 && titleField.value === "") {
|
||||||
|
|
||||||
|
var x = new XMLHttpRequest();
|
||||||
|
x.withCredentials=true;
|
||||||
|
x.onreadystatechange = function() {
|
||||||
|
if (x.readyState == 4 && x.status == 200) {
|
||||||
|
|
||||||
|
title=JSON.parse(x.responseText)["title"];
|
||||||
|
titleField.value=title;
|
||||||
|
|
||||||
|
checkForRequired()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x.open('get','/submit/title?url=' + urlField.value);
|
||||||
|
x.send(null);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// Run AutoSuggestTitle function on load
|
||||||
|
|
||||||
|
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) {
|
||||||
|
@ -80,7 +116,6 @@
|
||||||
} else {
|
} else {
|
||||||
button.disabled = true;
|
button.disabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
|
Loading…
Reference in New Issue