Skip to content

Commit

Permalink
First timer: Remove jQuery part 1 (#540)
Browse files Browse the repository at this point in the history
* refactored two ajax request to simple xhr

* added verify to request success

* changed requests to fetch api

* Rebase

* check out package.json

* Revert package.json state to main

* change request url mistype and fixed response transform

* Rebase

* Rebase package-lock

* Update response 200 to response.ok

Co-authored-by: sashadev-sky <[email protected]>
  • Loading branch information
carlo-ev and sashadev-sky authored Apr 21, 2020
1 parent 6b1efd5 commit d2e6b3f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion dist/leaflet.distortableimage.js

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions src/edit/DistortableCollection.Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,28 +303,28 @@ L.DistortableCollection.Edit = L.Handler.extend({
statusUrl = opts.statusUrl + data;
// repeatedly fetch the status.json
self.updateInterval = setInterval(function intervalUpdater() {
$.ajax(statusUrl + '?' + Date.now(), {// bust cache with timestamp
type: 'GET',
crossDomain: true,
}).done(function(data) {
opts.updater(data);
});
var request = new Request(statusUrl+'?'+Date.now(), {method: 'GET'});
fetch(request).then(function(response) {
if (response.ok) {
return response.text();
}
}).then(opts.updater);
}, opts.frequency);
}

// initiate the export
function _defaultFetchStatusUrl(opts) {
$.ajax({
url: opts.exportStartUrl,
crossDomain: true,
type: 'POST',
data: {
collection: JSON.stringify(opts.collection),
scale: opts.scale,
upload: true,
},
success: function(data) { opts.handleStatusRes(data); }, // this handles the initial response
});
var form = new FormData();
form.append('collection', JSON.stringify(opts.collection));
form.append('scale', opts.scale);
form.append('upload', true);
var requestOptions = {method: 'POST', body: form};
var request = new Request(opts.exportStartUrl, requestOptions);
fetch(request).then(function(response) {
if (response.ok) {
return response.text();
}
}).then(opts.handleStatusRes);
}

// If the user has passed collection property
Expand Down

0 comments on commit d2e6b3f

Please sign in to comment.