Zotero.File.getContentsFromURL(url)
This commit is contained in:
parent
886ce6b4a6
commit
edb66a779c
|
@ -25,6 +25,7 @@ Zotero.File = new function(){
|
||||||
this.getClosestDirectory = getClosestDirectory;
|
this.getClosestDirectory = getClosestDirectory;
|
||||||
this.getSample = getSample;
|
this.getSample = getSample;
|
||||||
this.getContents = getContents;
|
this.getContents = getContents;
|
||||||
|
this.getContentsFromURL = getContentsFromURL;
|
||||||
this.putContents = putContents;
|
this.putContents = putContents;
|
||||||
this.getCharsetFromFile = getCharsetFromFile;
|
this.getCharsetFromFile = getCharsetFromFile;
|
||||||
this.addCharsetListener = addCharsetListener;
|
this.addCharsetListener = addCharsetListener;
|
||||||
|
@ -115,6 +116,20 @@ Zotero.File = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the contents of a URL as a string
|
||||||
|
*
|
||||||
|
* Runs asynchronously, so should only be run on local (e.g. chrome) URLs
|
||||||
|
*/
|
||||||
|
function getContentsFromURL(url) {
|
||||||
|
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
|
||||||
|
.createInstance();
|
||||||
|
xmlhttp.open('GET', url, false);
|
||||||
|
xmlhttp.send(null);
|
||||||
|
return xmlhttp.responseText;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write string to a file, overwriting existing file if necessary
|
* Write string to a file, overwriting existing file if necessary
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user