Zotero.File.getContentsFromURL(url)

This commit is contained in:
Dan Stillman 2007-07-20 18:19:03 +00:00
parent 886ce6b4a6
commit edb66a779c

View File

@ -25,6 +25,7 @@ Zotero.File = new function(){
this.getClosestDirectory = getClosestDirectory;
this.getSample = getSample;
this.getContents = getContents;
this.getContentsFromURL = getContentsFromURL;
this.putContents = putContents;
this.getCharsetFromFile = getCharsetFromFile;
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
*