Use the Fetch API instead of PrototypeJS

This commit is contained in:
nemunaire 2019-09-01 17:13:03 +02:00
commit d5fd91902f
3 changed files with 21 additions and 7606 deletions

7588
static/js/prototype.js vendored

File diff suppressed because it is too large Load diff

View file

@ -3,12 +3,16 @@ var api_url = "/api/images";
var img_url = "/images/";
function get_picts(then, then_value) {
new Ajax.Request(api_url, {
method: 'get',
onSuccess: function(transport) {
picts = transport.responseText.evalJSON();
if (then) then(then_value);
},
fetch(api_url)
.then(function(response) {
return response.json();
})
.then(function(my_picts) {
picts = my_picts;
if (then) then(then_value);
})
.catch(function(error) {
display_error(error);
});
}
@ -69,16 +73,16 @@ function show_picture(id) {
function get_picture(id) {
if (id == null) id = "last";
new Ajax.Request(api_url + "/" + id, {
method: 'get',
onSuccess: function(transport) {
var response = transport.responseText.evalJSON();
display_picture(response);
},
onFailure: function(transport) {
var response = transport.responseText.evalJSON();
display_error(response["errmsg"]);
}
fetch(api_url + "/" + id)
.then(function(response) {
return response.json();
})
.then(function(my_pict) {
display_picture(my_pict);
})
.catch(function(error) {
display_error(error);
});
}