forked from TejasPrabhu/Job-Analyzer
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from subodh30/documentation
Documentation + UI changes
- Loading branch information
Showing
36 changed files
with
9,517 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Implement simple cached AJAX functions. | ||
|
||
var _cache = {}; | ||
|
||
/* | ||
* Get a promise for the HTTP get responseText. | ||
*/ | ||
function httpGetPromise(url) { | ||
const promise = new Promise((_resolve, _reject) => { | ||
httpGet(url, (responseText) => { | ||
_resolve(responseText); | ||
}, | ||
(error) => { | ||
_reject(error); | ||
}); | ||
}); | ||
return promise | ||
} | ||
|
||
function httpGet(url, onload, onerror) { | ||
if (_cache[url]) { | ||
_cachedHttpGet(url, onload, onerror); | ||
} | ||
else{ | ||
_httpGet(url, onload, onerror); | ||
} | ||
} | ||
|
||
function _cachedHttpGet(url, onload, onerror) { | ||
setTimeout(() => { onload(_cache[url]) }, 0); | ||
} | ||
|
||
function _httpGet(url, onload, onerror) { | ||
|
||
var xobj = new XMLHttpRequest(); | ||
xobj.open('GET', url, true); // Asynchronous | ||
|
||
xobj.onload = function () { | ||
// add document to cache. | ||
_cache[url] = xobj.responseText; | ||
onload(xobj.responseText); | ||
}; | ||
|
||
xobj.onerror = function (error) { | ||
console.log(error) | ||
onerror(error) | ||
}; | ||
|
||
xobj.send(null); | ||
} |
Oops, something went wrong.