Skip to content

Commit

Permalink
made tiff.js Chrome compatible
Browse files Browse the repository at this point in the history
-- got rid of default parameters (as cool as they are)
-- got rid of const (as nice as it is)
  • Loading branch information
city41 committed Nov 21, 2012
1 parent b38453b commit 80c9069
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tiff.js
Expand Up @@ -41,7 +41,7 @@ TIFFParser.prototype = {
getFieldTagName: function (fieldTag) {
// See: http://www.digitizationguidelines.gov/guidelines/TIFF_Metadata_Final.pdf
// See: http://www.digitalpreservation.gov/formats/content/tiff_tags.shtml
const fieldTagNames = {
var fieldTagNames = {
// TIFF Baseline
0x013B: 'Artist',
0x0102: 'BitsPerSample',
Expand Down Expand Up @@ -164,7 +164,7 @@ TIFFParser.prototype = {
},

getFieldTypeName: function (fieldType) {
const fieldTypeNames = {
var fieldTypeNames = {
0x0001: 'BYTE',
0x0002: 'ASCII',
0x0003: 'SHORT',
Expand Down Expand Up @@ -204,7 +204,8 @@ TIFFParser.prototype = {
return fieldTypeLength;
},

getBits: function (numBits, byteOffset, bitOffset = 0) {
getBits: function (numBits, byteOffset, bitOffset) {
bitOffset = bitOffset || 0;
var extraBytes = Math.floor(bitOffset / 8);
var newByteOffset = byteOffset + extraBytes;
var totalBits = bitOffset + numBits;
Expand Down Expand Up @@ -304,7 +305,10 @@ TIFFParser.prototype = {
return Math.floor((colorSample * multiplier) + (multiplier - 1));
},

makeRGBAFillValue: function(r, g, b, a = 1.0) {
makeRGBAFillValue: function(r, g, b, a) {
if(typeof a === 'undefined') {
a = 1.0;
}
return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
},

Expand Down Expand Up @@ -338,7 +342,9 @@ TIFFParser.prototype = {
}
},

parseTIFF: function (tiffArrayBuffer, canvas = document.createElement("canvas")) {
parseTIFF: function (tiffArrayBuffer, canvas) {
canvas = canvas || document.createElement('canvas');

this.tiffDataView = new DataView(tiffArrayBuffer);
this.canvas = canvas;

Expand Down

0 comments on commit 80c9069

Please sign in to comment.