Just a note on DataView (HTML5), since it isn't widely accepted yet.
Thought you could do an undefined check on it and if undefined, use backward compatibility:
backwards check example:
if (typeof DataView !== 'undefined') {
this.dataView=new DataView( buffer );
} else {
//compatibility
this.dataView=new DataView__( buffer );
}
function DataView__(buffer) {
//this.buffer = buffer;
this.byteArray=new Int8Array( buffer );
this.shortArray=new Int16Array( buffer );
this.intArray=new Int32Array( buffer );
this.floatArray=new Float32Array( buffer );
}
DataView__.prototype.setInt8 = function(addr,value) {
this.byteArray[addr]=value;
}
DataView__.prototype.setInt16 = function(addr,value) {
this.shortArray[addr>>1]=value;
}
DataView__.prototype.setInt32 = function(addr,value) {
this.intArray[addr>>2]=value;
}
DataView__.prototype.setFloat32 = function(addr,value) {
this.floatArray[addr>>2]=value;
}
DataView__.prototype.getInt8 = function(addr,value) {
return this.byteArray[addr];
}
DataView__.prototype.getInt16 = function(addr,value) {
return this.shortArray[addr>>1];
}
DataView__.prototype.getInt32 = function(addr,value) {
return this.intArray[addr>>2];
}
DataView__.prototype.getFloat32 = function(addr,value) {
return this.floatArray[addr>>2];
}
otherwise this breaks quite a few browsers.
|