text.js revision cba9e79b32f815c0140fe18a0db06cc88758456e
/**
* @license RequireJS text 2.0.10 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/requirejs/text for details
*/
/*jslint regexp: true */
/*global require, XMLHttpRequest, ActiveXObject,
define, window, process, Packages,
java, location, Components, FileUtils */
'use strict';
bodyRegExp = /<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,
defaultProtocol = hasLocation && location.protocol && location.protocol.replace(/\:/, ''),
defaultHostName = hasLocation && location.hostname,
defaultPort = hasLocation && (location.port || undefined),
buildMap = {},
masterConfig = (module.config && module.config()) || {};
text = {
version: '2.0.10',
strip: function (content) {
//Strips <?xml ...?> declarations so that external SVG and XML
//documents can be added to a document without worry. Also, if the string
//is an HTML document, only the part inside the body tag is returned.
if (content) {
content = content.replace(xmlRegExp, "");
var matches = content.match(bodyRegExp);
if (matches) {
content = matches[1];
}
} else {
content = "";
}
return content;
},
jsEscape: function (content) {
return content.replace(/(['\\])/g, '\\$1')
.replace(/[\f]/g, "\\f")
.replace(/[\b]/g, "\\b")
.replace(/[\n]/g, "\\n")
.replace(/[\t]/g, "\\t")
.replace(/[\r]/g, "\\r")
},
//Would love to dump the ActiveX crap in here. Need IE 6 to die first.
if (typeof XMLHttpRequest !== "undefined") {
return new XMLHttpRequest();
} else if (typeof ActiveXObject !== "undefined") {
for (i = 0; i < 3; i += 1) {
try {
} catch (e) {}
if (xhr) {
break;
}
}
}
return xhr;
},
/**
* Parses a resource name into its component parts. Resource names
* optional.
* @param {String} name the resource name
* @returns {Object} with properties "moduleName", "ext" and "strip"
* where strip is a boolean.
*/
strip = false,
} else {
}
if (index !== -1) {
//Pull off the strip arg.
if (ext) {
} else {
}
}
return {
};
},
xdRegExp: /^((\w+)\:)?\/\/([^\/\\]+)/,
/**
* Is an URL on another domain. Only works for browser use, returns
* false in non-browser environments. Only used to know if an
* optimized .js version of a text resource should be loaded
* instead.
* @param {String} url
* @returns Boolean
*/
if (!match) {
return true;
}
},
if (masterConfig.isBuild) {
}
},
//Name has format: some.module.filext!strip
//The strip part is optional.
//if strip is present, then that means only get the string contents
//removing the <?xml ...?> declarations so the content can be inserted
//into the current doc without problems.
// Do not bother with the work if a build and text will
// not be inlined.
onLoad();
return;
}
// Do not load if it is an empty: url
onLoad();
return;
}
//Load the text. Use XHR if possible and in a browser.
}, function (err) {
}
});
} else {
//Need to fetch the resource across domains. Assume
//the resource has been optimized into a JS module. Fetch
//by the module name + extension, but do not include the
//!strip part to avoid file system issues.
});
}
},
"define(function () { return '" +
content +
"';});\n");
}
},
//Use a '.js' file name so that it indicates it is a
//script that can be loaded across domains.
//Leverage own load() method to load plugin value, but only
//write out values that do not have the strip argument,
//to avoid any potential issues with ! in file names.
//Use own write() method to construct full module value.
//But need to create shell that translates writeFile's
//write() to the right interface.
};
};
}, config);
}
};
typeof process !== "undefined" &&
//Using special require.nodeRequire, something added by r.js.
try {
//Remove BOM (Byte Mark Order) from utf8 files if it is there.
}
} catch (e) {
errback(e);
}
};
//Allow plugins direct access to xhr headers
if (headers) {
}
}
}
//Allow overrides specified in config
if (masterConfig.onXhr) {
}
//Do not explicitly handle errors, those should be
//visible via console output in the browser.
//An http 4xx or 5xx error. Signal an error.
} else {
}
if (masterConfig.onXhrComplete) {
}
}
};
};
//Why Java, why is this so awkward?
var stringBuffer, line,
encoding = "utf-8",
input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)),
content = '';
try {
// Byte Order Mark (BOM) - The Unicode Standard, version 3.0, page 324
// Note that when we use utf-8, the BOM should appear as "EF BB BF", but it doesn't due to this bug in the JDK:
// Eat the BOM, since we've already found the encoding on this file,
// and we plan to concatenating this buffer with others; the BOM should
// only appear at the top of a file.
}
if (line !== null) {
}
}
//Make sure we return a JavaScript string and not a Java string.
} finally {
}
};
Components.interfaces)) {
//Avert your gaze!
readData = {};
if (xpcIsWindows) {
}
//XPCOM, you so crazy
try {
} catch (e) {
}
};
}
return text;
});