-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEW: _setWarp for initial similarity transform
NEW: js/utils/XHRUtils.js for simpler XMLHttpRequest NEW: Load transform from '_warp.json' FIX: rotate(scaledPosition) for correct overlay repositioning TODO: remains to fix Freeze option, also Issue #270 Todo: cleanup console noise
- Loading branch information
1 parent
475b289
commit 2d59d03
Showing
4 changed files
with
107 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Utility functions for XMLHttpRequest (XHR) related stuff. | ||
* | ||
* @namespace XHRUtils | ||
*/ | ||
const XHRUtils = (function() { | ||
"use strict"; | ||
|
||
/** | ||
* Promisified XHR function | ||
* https://stackoverflow.com/questions/48969495/in-javascript-how-do-i-should-i-use-async-await-with-xmlhttprequest | ||
* @param {*} method | ||
* @param {*} url | ||
* @param {boolean} noCache | ||
*/ | ||
function makeRequest(method, url, noCache=true) { | ||
return new Promise(function (resolve, reject) { | ||
let xhr = new XMLHttpRequest(); | ||
xhr.open(method, url); | ||
|
||
if (noCache) { | ||
// Turn off caching of response | ||
xhr.setRequestHeader("Cache-Control", "no-cache, no-store, must-revalidate, max-age=0"); // HTTP 1.1 | ||
xhr.setRequestHeader("Pragma", "no-cache"); // HTTP 1.0 | ||
xhr.setRequestHeader("Expires", "0"); // Proxies | ||
} | ||
|
||
xhr.onload = function () { | ||
if (this.status >= 200 && this.status < 300) { | ||
resolve(xhr.responseText); | ||
} else { | ||
reject({ | ||
status: this.status, | ||
statusText: xhr.statusText | ||
}); | ||
} | ||
}; | ||
xhr.onerror = function () { | ||
reject({ | ||
status: this.status, | ||
statusText: xhr.statusText | ||
}); | ||
}; | ||
xhr.send(); | ||
}); | ||
} | ||
|
||
return { | ||
makeRequest | ||
}; | ||
})(); | ||
|
||
//I think this one may live in the global namespace | ||
const promiseHttpRequest = XHRUtils.makeRequest; |