Improvements for CommonJS.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I
2010-01-28 14:19:23 -08:00
parent 42712166e9
commit 06261559fc
5 changed files with 89 additions and 43 deletions
+6 -4
View File
@@ -170,7 +170,7 @@ function determineAndDispatchHTTPRequestEvents(/*HTTPRequest*/ aRequest)
function FileRequest(/*String*/ aFilePath, onsuccess, onfailure)
{
#if BROWSER
#ifdef BROWSER
var request = new HTTPRequest();
request.onsuccess = onsuccess;
@@ -179,14 +179,16 @@ function FileRequest(/*String*/ aFilePath, onsuccess, onfailure)
request.open("GET", aFilePath, YES);
request.send("");
#else
if (!require("file").exists(aFilePath))
if (!FILE.exists(aFilePath))
return onfailure();
this._responseText = FILE.read(aFilePath, { charset: "UTF-8" });
onsuccess({ type:"success", request:this });
#endif
}
#if COMMONJS
#ifdef COMMONJS
FileRequest.prototype.responseText = function()
{
return this._responseText;
@@ -199,6 +201,6 @@ FileRequest.prototype.responseXML = function()
FileRequest.prototype.responsePropertyList = function()
{
return PropertyList.createFromString(responseText);
return PropertyList.createFromString(this.responseText());
}
#endif