diff options
author | Richard Wall <richard@largo> | 2011-06-19 23:04:44 +0100 |
---|---|---|
committer | Richard Wall <richard@largo> | 2011-06-19 23:04:44 +0100 |
commit | 505df29da4cdeda1911fe6749736f36c56c52b09 (patch) | |
tree | 1b223d940a97250f70bf1c78c9b72ec88d849503 | |
parent | a8094881c80a07ce085cd188ed673aabf19ad0c1 (diff) |
jarmon namespace
-rw-r--r-- | jarmon/jarmon.js | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/jarmon/jarmon.js b/jarmon/jarmon.js index 21c4c39..4419fa1 100644 --- a/jarmon/jarmon.js +++ b/jarmon/jarmon.js @@ -45,20 +45,20 @@ if(typeof jarmon == 'undefined') { // ============================================================ // Exception class -function InvalidBinaryFile(msg) { +jarmon.InvalidBinaryFile = function(msg) { this.message=msg; this.name="Invalid BinaryFile"; -} +}; // pretty print -InvalidBinaryFile.prototype.toString = function() { +jarmon.InvalidBinaryFile.prototype.toString = function() { return this.name + ': "' + this.message + '"'; -} +}; // ===================================================================== // BinaryFile class // Allows access to element inside a binary stream -function BinaryFile(strData, iDataOffset, iDataLength) { +jarmon.BinaryFile = function(strData, iDataOffset, iDataLength) { var data = strData; var dataOffset = iDataOffset || 0; var dataLength = 0; @@ -84,7 +84,8 @@ function BinaryFile(strData, iDataOffset, iDataLength) { return IEBinary_getByteAt(data, iOffset + dataOffset); }; } else { - throw new InvalidBinaryFile("Unsupported type " + (typeof strData)); + throw new jarmon.InvalidBinaryFile( + "Unsupported type " + (typeof strData)); } this.getLength = function() { @@ -100,7 +101,8 @@ function BinaryFile(strData, iDataOffset, iDataLength) { }; this.getShortAt = function(iOffset) { - var iShort = (this.getByteAt(iOffset + 1) << 8) + this.getByteAt(iOffset); + var iShort = ( + this.getByteAt(iOffset + 1) << 8) + this.getByteAt(iOffset); if (iShort < 0) iShort += 65536; return iShort; }; @@ -139,7 +141,8 @@ function BinaryFile(strData, iDataOffset, iDataLength) { // Added this.getCStringAt = function(iOffset, iMaxLength) { var aStr = []; - for (var i=iOffset,j=0;(i<iOffset+iMaxLength) && (this.getByteAt(i)>0);i++,j++) { + for (var i=iOffset,j=0;(i<iOffset+iMaxLength) && + (this.getByteAt(i)>0);i++,j++) { aStr[j] = String.fromCharCode(this.getByteAt(i)); } return aStr.join(""); @@ -232,9 +235,9 @@ jarmon.downloadBinary = function(url) { dataFilter: function(data, dataType) { // In IE we return the responseBody if(typeof(this._nativeXhr.responseBody) != 'undefined') { - return new BinaryFile(this._nativeXhr.responseBody); + return new jarmon.BinaryFile(this._nativeXhr.responseBody); } else { - return new BinaryFile(data); + return new jarmon.BinaryFile(data); } }, success: function(data, textStatus, jqXHR) { |