Skip to content

Commit

Permalink
add main to package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
jrburke committed Feb 19, 2013
1 parent 5736b99 commit a7f641a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"volo": {
"url": "https://raw.github.com/jrburke/requirejs/{version}/require.js"
}
},
"main": "require.js"
}
35 changes: 33 additions & 2 deletions tests/plugins/fromText/refine.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

/*jslint strict: false, plusplus: false */
/*global define: false, require: false, XMLHttpRequest: false, ActiveXObject: false,
window: false, Packages: false, java: false, process: false */
window: false, Packages: false, java: false, process: false, Components, FileUtils */

(function () {
//Load the text plugin, so that the XHR calls can be made.
var buildMap = {}, fetchText, fs,
var buildMap = {}, fetchText, fs, Cc, Ci,
progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];

function createXhr() {
Expand Down Expand Up @@ -94,6 +94,37 @@
}
callback(content);
};
} else if (typeof Components !== 'undefined' && Components.classes &&
Components.interfaces) {
//Avert your gaze!
Cc = Components.classes,
Ci = Components.interfaces;
Components.utils['import']('resource://gre/modules/FileUtils.jsm');

fetchText = function (url, callback) {
var inStream, convertStream,
readData = {},
fileObj = new FileUtils.File(url);

//XPCOM, you so crazy
try {
inStream = Cc['@mozilla.org/network/file-input-stream;1']
.createInstance(Ci.nsIFileInputStream);
inStream.init(fileObj, 1, 0, false);

convertStream = Cc['@mozilla.org/intl/converter-input-stream;1']
.createInstance(Ci.nsIConverterInputStream);
convertStream.init(inStream, "utf-8", inStream.available(),
Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);

convertStream.readString(inStream.available(), readData);
convertStream.close();
inStream.close();
callback(readData.value);
} catch (e) {
throw new Error((fileObj && fileObj.path || '') + ': ' + e);
}
};
}

define(function () {
Expand Down

0 comments on commit a7f641a

Please sign in to comment.