From aa1adc8817f918486e553149cdc22d41e76fbc99 Mon Sep 17 00:00:00 2001 From: Sylvester Keil Date: Fri, 27 Jul 2018 15:56:00 +0200 Subject: [PATCH] Add Zotero.File.getResourceAsync --- chrome/content/zotero/xpcom/file.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index 42e82e54ed..513a4580b3 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -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;