updates on #98

This commit is contained in:
Henrique Dias
2016-12-11 10:41:03 +00:00
parent 744d8c917e
commit 76c91576cf
3 changed files with 19 additions and 13 deletions

View File

@@ -39,16 +39,19 @@ document.addEventListener('listing', event => {
let button = document.getElementById('new');
let html = button.changeToLoading();
let request = new XMLHttpRequest();
request.open("POST", window.location);
request.open("PUT", toWebDavURL(window.location.pathname + name));
request.setRequestHeader('Filename', name);
request.setRequestHeader('Archetype', archetype);
request.send();
request.onreadystatechange = function() {
if (request.readyState == 4) {
button.changeToDone((request.status != 200), html);
if (request.status == 200) {
window.location = window.location.pathname + name;
if (request.status != 200 && request.status != 201) {
button.changeToDone(true, html);
return;
}
button.changeToDone(false, html);
window.location = window.location.pathname + name;
}
}
}