Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINTENANCE] Adds curly braces around blocks in loops and conditionals #1032

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Resources/Public/JavaScript/PageView/AltoParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ dlfAltoParser.prototype.parseFeatures = function(document) {
* @return {Array}
*/
feature.getTextblocks = function() {
if (this.get('printspace') !== undefined && this.get('printspace').get('textblocks'))
return this.get('printspace').get('textblocks')
if (this.get('printspace') !== undefined && this.get('printspace').get('textblocks')) {
return this.get('printspace').get('textblocks');
}
return [];
};

Expand Down Expand Up @@ -229,8 +230,9 @@ dlfAltoParser.prototype.parseGeometry_ = function(node) {
y2 = y1 + height,
coordinatesWithoutScale = [[[x1, y1], [x2, y1], [x2, y2], [x1, y2], [x1, y1]]];

if (isNaN(width) || isNaN(height))
if (isNaN(width) || isNaN(height)) {
return undefined;
}

// If page dimensions are given in the ALTO, use them to rescale the coordinates
var scale = 1;
Expand Down Expand Up @@ -260,8 +262,9 @@ dlfAltoParser.prototype.parseGeometry_ = function(node) {
dlfAltoParser.prototype.parsePrintSpaceFeature_ = function(node) {
var printspace = $(node).find('PrintSpace');

if (printspace.length === 0)
if (printspace.length === 0) {
return;
}
return this.parseAltoFeature_(printspace[0]);
};

Expand Down
41 changes: 23 additions & 18 deletions Resources/Public/JavaScript/PageView/AnnotationParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,14 @@ DlfIiifAnnotationParser.prototype.parseGeometry = function(annotation) {
var xywh = this.getXYWHForAnnotation(annotation),
coordinatesWithoutScale = [[[xywh.x1, xywh.y1], [xywh.x2, xywh.y1], [xywh.x2, xywh.y2], [xywh.x1, xywh.y2], [xywh.x1, xywh.y1]]];

if (isNaN(xywh.width) || isNaN(xywh.height))
if (isNaN(xywh.width) || isNaN(xywh.height)) {
return undefined;
}

// return geometry without rescale
if (!dlfUtils.exists(this.image_) || !dlfUtils.exists(this.width_))
if (!dlfUtils.exists(this.image_) || !dlfUtils.exists(this.width_)) {
return new ol.geom.Polygon(coordinatesWithoutScale);
}

// rescale coordinates
var scale = this.image_.width / this.width_,
Expand All @@ -174,22 +176,25 @@ DlfIiifAnnotationParser.prototype.parseGeometry = function(annotation) {
DlfIiifAnnotationParser.prototype.getXYWHForAnnotation = function (annotation) {
var fragmentPos = annotation.on.indexOf("#xywh="),
xywh = fragmentPos > -1 ? annotation.on.substr(fragmentPos+6).split(",") : undefined;
if (xywh === undefined) return {
x1: 0,
y1: 0,
width: this.width,
height: this.height,
x2: this.width - 1,
y2: this.height - 1
};
return {
x1: parseInt(xywh[0]),
y1: parseInt(xywh[1]),
width: parseInt(xywh[2]),
height: parseInt(xywh[3]),
x2: parseInt(xywh[0]) + parseInt(xywh[2]) - 1,
y2: parseInt(xywh[1]) + parseInt(xywh[3]) - 1
};
if (xywh === undefined) {
return {
x1: 0,
y1: 0,
width: this.width,
height: this.height,
x2: this.width - 1,
y2: this.height - 1
};
} else {
return {
x1: parseInt(xywh[0]),
y1: parseInt(xywh[1]),
width: parseInt(xywh[2]),
height: parseInt(xywh[3]),
x2: parseInt(xywh[0]) + parseInt(xywh[2]) - 1,
y2: parseInt(xywh[1]) + parseInt(xywh[3]) - 1
};
}
};

/**
Expand Down
8 changes: 6 additions & 2 deletions Resources/Public/JavaScript/PageView/Utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,9 @@ dlfUtils.fetchIIPData = function (imageSourceObj) {
url: dlfViewerSource.IIP.getMetdadataURL(imageSourceObj.url) //'http://localhost:8000/fcgi-bin/iipsrv.fcgi?FIF=F4713/HD7.tif&obj=IIP,1.0&obj=Max-size&obj=Tile-size&obj=Resolution-number',
}).done(cb);
function cb(response, type) {
if (type !== 'success') throw new Error('Problems while fetching ImageProperties.xml');
if (type !== 'success') {
throw new Error('Problems while fetching ImageProperties.xml');
}

var imageDataObj = $.extend({
src: imageSourceObj.url,
Expand Down Expand Up @@ -621,7 +623,9 @@ dlfUtils.scaleToImageSize = function (features, imageObj, width, height, opt_off
};
}

if (image === undefined) return [];
if (image === undefined) {
return [];
}

var scale = image.scale,
offset = opt_offset !== undefined ? opt_offset : 0;
Expand Down