docbrown/app/views/admin/articles/_image_upload_script.html.erb
Josh Puetz 1c566e0ec4
[deploy] Move /internal to `/admin (#9639)
* First draft - all the big changes

* Changing some more references to 'internal'

* Relocate internal request tests to admin

* Relocate internal system tests to admin

* Fix trailing space

* Test fix

* Move queries from internal to admin

* Docs updates

* Rename internal stimuls controllers to admin (plus docs)

* Rename admin layout

* Fix routing after rebase

* Fixes for latest added admin interfaces

* Serviceworker ignore paths
2020-08-07 10:36:26 -04:00

31 lines
998 B
Text

<script>
window.addEventListener('load', function() {
function generateUploadFormdata(image) {
var token = document.getElementsByName('authenticity_token')[0].value;
var formData = new FormData();
formData.append('authenticity_token', token);
formData.append('image', image[0]);
return formData;
}
function uploadImageCb(ajaxReq) {
if (ajaxReq.status === 200 && ajaxReq.readyState === XMLHttpRequest.DONE) {
var address = document.getElementById('uploaded-image');
address.value = JSON.parse(ajaxReq.response).link;
address.style.display = "inline-block";
address.style.width = "90%";
address.select();
var uploadedMessage = '';
document.getElementById('image-upload-submit').style.display = 'none';
}
}
function createAjaxReq() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else {
return new ActiveXObject("Microsoft.XMLHTTP");
}
}
});
</script>