feature (readonly): respect readonly restriction on the editor

This commit is contained in:
Mickael KERJEAN
2019-01-10 01:13:36 +11:00
parent 50506dcff9
commit 3b65cdf417
8 changed files with 64 additions and 7 deletions

View File

@ -90,6 +90,29 @@ export function http_delete(url){
});
}
export function http_options(url){
return new Promise((done, err) => {
var xhr = new XMLHttpRequest();
xhr.open("OPTIONS", url, true);
xhr.withCredentials = true;
xhr.onload = function(){
if(xhr.readyState === XMLHttpRequest.DONE){
if(xhr.status !== 200){
handle_error_response(xhr, err);
return
}
done(xhr.getAllResponseHeaders()
.split("\n")
.reduce((acc, r) => {
const a = r.split(": ");
acc[a[0]] = a[1];
return acc;
}, {}));
}
}
xhr.send(null);
})
}
function handle_error_response(xhr, err){