Add Zotero.File.getResourceAsync
This commit is contained in:
parent
c3bdf72f35
commit
aa1adc8817
1 changed files with 6 additions and 1 deletions
|
@ -33,6 +33,7 @@ Zotero.File = new function(){
|
|||
|
||||
this.getExtension = getExtension;
|
||||
this.getContentsFromURL = getContentsFromURL;
|
||||
this.getContentsFromURLAsync = getContentsFromURLAsync;
|
||||
this.putContents = putContents;
|
||||
this.getValidFileName = getValidFileName;
|
||||
this.truncateFileName = truncateFileName;
|
||||
|
@ -346,12 +347,16 @@ Zotero.File = new function(){
|
|||
this.getResource = function (res) {
|
||||
return getContentsFromURL(`resource://zotero/${res}`);
|
||||
}
|
||||
|
||||
this.getResourceAsync = function (res) {
|
||||
return getContentsFromURLAsync(`resource://zotero/${res}`);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return a promise for the contents of a URL as a string
|
||||
*/
|
||||
this.getContentsFromURLAsync = function (url, options={}) {
|
||||
function getContentsFromURLAsync (url, options={}) {
|
||||
return Zotero.HTTP.request("GET", url, Object.assign(options, { responseType: "text" }))
|
||||
.then(function (xmlhttp) {
|
||||
return xmlhttp.response;
|
||||
|
|
Loading…
Add table
Reference in a new issue