Use strict comparisons

This commit is contained in:
Sebastian Meyer 2020-03-04 15:10:06 +01:00
parent 28f23028d3
commit 2bcabcdd23
8 changed files with 50 additions and 50 deletions

View File

@ -23,7 +23,7 @@ if (jQuery.fn.scrollTo === undefined) {
var manualOffsetTop = $(elem).parent().height() / 2;
$(this).animate({
scrollTop: $(this).scrollTop() - $(this).offset().top + $(elem).offset().top - manualOffsetTop
}, speed == undefined ? 1000 : speed);
}, speed === undefined ? 1000 : speed);
return this;
};
}
@ -208,7 +208,7 @@ function DlfAnnotationControl(map, image, annotationContainers) {
.attr('title', this.dic['annotations-on']);
// if annotation is activated via cookie than run activation methode
if (dlfUtils.getCookie("tx-dlf-pageview-annotation-select") == 'enabled') {
if (dlfUtils.getCookie("tx-dlf-pageview-annotation-select") === 'enabled') {
// activate the annotation behavior
this.activate(anchorEl);
}
@ -222,7 +222,7 @@ DlfAnnotationControl.prototype.showAnnotationText = function(featuresParam) {
var feature = features[i],
annotations = feature.get('annotations'),
labelEl;
if (feature.get('label') != '') {
if (feature.get('label') !== '') {
labelEl = $('<span class="annotation-list-label"/>');
labelEl.text(feature.get('label'));
$('#tx-dlf-annotationselection').append(labelEl);
@ -332,7 +332,7 @@ DlfAnnotationControl.prototype.fetchAnnotationContainersFromServer = function(an
url: annotationList.uri,
async: false
});
responseJson = request.responseJSON != null ? request.responseJSON : request.responseText != null ? $.parseJSON(request.responseText) : null;
responseJson = request.responseJSON !== null ? request.responseJSON : request.responseText !== null ? $.parseJSON(request.responseText) : null;
if (responseJson.label === undefined) {
responseJson.label = annotationList.label;
}

View File

@ -93,7 +93,7 @@ DlfIiifAnnotationParser.prototype.parseAnnotationList = function(annotationList,
var onCanvas = DlfIiifAnnotationParser.getTargetIdentifierWithoutFragment(annotation.on);
if (currentCanvas != onCanvas) continue;
if (currentCanvas !== onCanvas) continue;
var feature = this.parseAnnotation(annotation);
@ -123,7 +123,7 @@ DlfIiifAnnotationParser.prototype.parseAnnotationList = function(annotationList,
listFeature.setId(annotationListId);
listFeature.setProperties({
'type': 'annotationList',
'label': annotationList.label != null ? annotationList.label : '',
'label': annotationList.label !== null ? annotationList.label : '',
'width': maxX - minX + 1,
'height': maxY - minY + 1,
'x1': minX,
@ -197,7 +197,7 @@ DlfIiifAnnotationParser.prototype.getXYWHForAnnotation = function (annotation) {
* @private
*/
DlfIiifAnnotationParser.getTargetIdentifierWithoutFragment = function(uri) {
if (uri == null) {
if (uri === null) {
return null;
}
return uri.split("#")[0];

View File

@ -20,7 +20,7 @@ jQuery.fn.scrollTo = function(elem, speed) {
var manualOffsetTop = $(elem).parent().height() / 2;
$(this).animate({
scrollTop: $(this).scrollTop() - $(this).offset().top + $(elem).offset().top - manualOffsetTop
}, speed == undefined ? 1000 : speed);
}, speed === undefined ? 1000 : speed);
return this;
};
@ -263,7 +263,7 @@ var dlfViewerFullTextControl = function(map, image, fulltextUrl) {
.attr('title', this.dic['fulltext-on']);
// if fulltext is activated via cookie than run activation methode
if (dlfUtils.getCookie("tx-dlf-pageview-fulltext-select") == 'enabled') {
if (dlfUtils.getCookie("tx-dlf-pageview-fulltext-select") === 'enabled') {
// activate the fulltext behavior
this.activate(anchorEl);
}

View File

@ -370,7 +370,7 @@ dlfViewerImageManipulationControl.prototype.createSlider_ = function(className,
element = valueEl[0],
labelValue = dlfUtils.exists(opt_labelFn) ? opt_labelFn(value) : value + '%';
if (orientation == 'vertical') {
if (orientation === 'vertical') {
var style_top = 100 - ((value - baseMin) / (baseMax - baseMin) * 100);
element.style.top = style_top + '%';
element.innerHTML = labelValue;

View File

@ -100,7 +100,7 @@ ol.Map.prototype.rotate = function(rotation) {
'duration':200
}));
view.rotate(rotate, center);
if (this.ov_view != null) {
if (this.ov_view !== null) {
this.ov_view.rotate(rotate);
}
};
@ -110,7 +110,7 @@ ol.Map.prototype.rotate = function(rotation) {
*/
ol.Map.prototype.rotateLeft = function() {
this.rotate(-5);
if (this.ov_view != null) {
if (this.ov_view !== null) {
this.ov_view.rotate(-5);
}
};
@ -120,7 +120,7 @@ ol.Map.prototype.rotateLeft = function() {
*/
ol.Map.prototype.rotateRight = function() {
this.rotate(5);
if (this.ov_view != null) {
if (this.ov_view !== null) {
this.ov_view.rotate(5);
}
};
@ -130,7 +130,7 @@ ol.Map.prototype.rotateRight = function() {
*/
ol.Map.prototype.resetRotation = function() {
this.getView().rotate(0, this.getView().getCenter());
if (this.ov_view != null) {
if (this.ov_view !== null) {
this.ov_view.rotate(0);
}
};

View File

@ -49,7 +49,7 @@ Number.isInteger = Number.isInteger || function(value) {
* Polyfill for Number.isNaN
*/
Number.isNaN = Number.isNaN || function(value) {
return value !== null && (value != value || +value != value);
return value !== null && (value !== value || +value !== value);
};
/**
@ -73,7 +73,7 @@ dlfViewerSource.tileLoadFunction = function(tileSize, tile, url) {
tileHeight = Array.isArray(tileSize) ? tileSize[1] : tileSize;
$(img).load(function() {
if (img.naturalWidth > 0 &&
(img.naturalWidth != tileWidth || img.naturalHeight != tileHeight)) {
(img.naturalWidth !== tileWidth || img.naturalHeight !== tileHeight)) {
var canvas = document.createElement('canvas');
canvas.width = tileWidth;
canvas.height = tileHeight;
@ -81,7 +81,7 @@ dlfViewerSource.tileLoadFunction = function(tileSize, tile, url) {
var ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
var key = dlfViewerSource.findKey(tile, function(v) {return v == img;});
var key = dlfViewerSource.findKey(tile, function(v) {return v === img;});
if (key) {
tile[key] = canvas;
}
@ -114,9 +114,9 @@ dlfViewerSource.IIIF = function(options) {
resolutions = $.extend([], options.resolutions),
sizes = options.sizes === undefined ? [] : options.sizes,
supports = options.supports === undefined ? [] : options.supports,
supportsListedSizes = sizes != undefined && Array.isArray(sizes) && sizes.length > 0,
supportsListedTiles = tileSize != undefined && (Number.isInteger(tileSize) && tileSize > 0 || Array.isArray(tileSize) && tileSize.length > 0),
supportsArbitraryTiling = supports != undefined && Array.isArray(supports) &&
supportsListedSizes = sizes !== undefined && Array.isArray(sizes) && sizes.length > 0,
supportsListedTiles = tileSize !== undefined && (Number.isInteger(tileSize) && tileSize > 0 || Array.isArray(tileSize) && tileSize.length > 0),
supportsArbitraryTiling = supports !== undefined && Array.isArray(supports) &&
(supports.includes('regionByPx') || supports.includes('regionByPct')) &&
(supports.includes('sizeByWh') || supports.includes('sizeByH') ||
supports.includes('sizeByW') || supports.includes('sizeByPct')),
@ -125,27 +125,27 @@ dlfViewerSource.IIIF = function(options) {
tileHeight,
maxZoom;
url += url.lastIndexOf('/') == url.length - 1 ? '' : '/';
url += url.lastIndexOf('/') === url.length - 1 ? '' : '/';
// sort resolutions because the spec does not specify any order
resolutions.sort(function(a, b) {
return b - a;
});
if (supportsListedTiles || supportsArbitraryTiling) {
if (tileSize != undefined) {
if (tileSize !== undefined) {
if (Number.isInteger(tileSize) && tileSize > 0) {
tileWidth = tileSize;
tileHeight = tileSize;
} else if (Array.isArray(tileSize) && tileSize.length > 0) {
if (tileSize.length == 1 || tileSize[1] == undefined && Number.isInteger(tileSize[0])) {
if (tileSize.length === 1 || tileSize[1] === undefined && Number.isInteger(tileSize[0])) {
tileWidth = tileSize[0];
tileHeight = tileSize[0];
}
if (tileSize.length == 2) {
if (tileSize.length === 2) {
if (Number.isInteger(tileSize[0]) && Number.isInteger(tileSize[1])) {
tileWidth = tileSize[0];
tileHeight = tileSize[1];
} else if (tileSize[0] == undefined && Number.isInteger(tileSize[1])) {
} else if (tileSize[0] === undefined && Number.isInteger(tileSize[1])) {
tileWidth = tileSize[1];
tileHeight = tileSize[1];
}
@ -156,7 +156,7 @@ dlfViewerSource.IIIF = function(options) {
tileWidth = 256;
tileHeight = 256;
}
if (resolutions.length == 0) {
if (resolutions.length === 0) {
maxZoom = Math.max(
Math.ceil(Math.log(width / tileWidth) / Math.LN2),
Math.ceil(Math.log(height / tileHeight) / Math.LN2)
@ -186,7 +186,7 @@ dlfViewerSource.IIIF = function(options) {
var ignoredSizesIndex = [];
for (var i = 0; i < sizes.length; i++) {
var resolution = width / sizes[i][0];
if (resolutions.length > 0 && resolutions[resolutions.length - 1] == resolution) {
if (resolutions.length > 0 && resolutions[resolutions.length - 1] === resolution) {
ignoredSizesIndex.push(i);
continue;
}
@ -209,8 +209,8 @@ dlfViewerSource.IIIF = function(options) {
// define tilegrid with offset extent
var extent = [offset[0], offset[1] - height, offset[0] + width, offset[1]];
var tileGrid = new ol.tilegrid.TileGrid({
extent: extent,
resolutions: resolutions,
extent,
resolutions,
origin: ol.extent.getTopLeft(extent),
tileSize: [tileWidth, tileHeight]
});
@ -256,7 +256,7 @@ dlfViewerSource.IIIF = function(options) {
if (regionY + tileHeight * scale > height) {
sizeH = Math.floor((height - regionY + scale - 1) / scale);
}
if (regionX == 0 && regionW == width && regionY == 0 && regionH == height) {
if (regionX === 0 && regionW === width && regionY === 0 && regionH === height) {
// canonical full image region parameter is 'full', not 'x,y,w,h'
regionParam = 'full';
} else if (!supportsArbitraryTiling || supports.includes('regionByPx')) {
@ -268,7 +268,7 @@ dlfViewerSource.IIIF = function(options) {
pctH = formatPercentage(regionH / height * 100);
regionParam = 'pct:' + pctX + ',' + pctY + ',' + pctW + ',' + pctH;
}
if (version == 'version3' && (!supportsArbitraryTiling || supports.includes('sizeByWh'))) {
if (version === 'version3' && (!supportsArbitraryTiling || supports.includes('sizeByWh'))) {
sizeParam = sizeW + ',' + sizeH;
} else if (!supportsArbitraryTiling || supports.includes('sizeByW')) {
sizeParam = sizeW + ',';
@ -284,21 +284,21 @@ dlfViewerSource.IIIF = function(options) {
if (supportsListedSizes) {
var regionWidth = sizes[zoom][0],
regionHeight = sizes[zoom][1];
if (version == 'version3') {
if (regionWidth == width && regionHeight == height) {
if (version === 'version3') {
if (regionWidth === width && regionHeight === height) {
sizeParam = 'max';
} else {
sizeParam = regionWidth + ',' + regionHeight;
}
} else {
if (regionWidth == width) {
if (regionWidth === width) {
sizeParam = 'full';
} else {
sizeParam = regionWidth + ',';
}
}
} else {
sizeParam = version == 'version3' ? 'max' : 'full';
sizeParam = version === 'version3' ? 'max' : 'full';
}
}
return url + regionParam + '/' + sizeParam + '/0/' + quality + '.' + format;
@ -306,9 +306,9 @@ dlfViewerSource.IIIF = function(options) {
var tileImageParams = {
crossOrigin: origin,
projection: projection,
tileGrid: tileGrid,
tileUrlFunction: tileUrlFunction
projection,
tileGrid,
tileUrlFunction
};
if (ol.has.CANVAS) {

View File

@ -157,14 +157,14 @@ dlfViewer.prototype.addCustomControls = function(controlNames) {
// Adds fulltext behavior only if there is fulltext available and no double page
// behavior is active
if (this.fulltexts[0] !== undefined && this.fulltexts[0].url !== '' && this.images.length == 1) {
if (this.fulltexts[0] !== undefined && this.fulltexts[0].url !== '' && this.images.length === 1) {
fulltextControl = new dlfViewerFullTextControl(this.map, this.images[0], this.fulltexts[0].url);
} else {
$('#tx-dlf-tools-fulltext').remove();
}
if (this.annotationContainers[0] !== undefined && this.annotationContainers[0].annotationContainers !== undefined
&& this.annotationContainers[0].annotationContainers.length > 0 && this.images.length == 1) {
&& this.annotationContainers[0].annotationContainers.length > 0 && this.images.length === 1) {
// Adds annotation behavior only if there are annotations available and view is single page
annotationControl = new DlfAnnotationControl(this.map, this.images[0], this.annotationContainers[0]);
if (fulltextControl !== undefined) {
@ -324,14 +324,14 @@ dlfViewer.prototype.displayHighlightWord = function() {
var key = 'tx_dlf[highlight_word]',
urlParams = dlfUtils.getUrlParams();
if (urlParams != undefined && urlParams.hasOwnProperty(key) && this.fulltexts[0] !== undefined && this.fulltexts[0].url !== '' && this.images.length > 0) {
if (urlParams !== undefined && urlParams.hasOwnProperty(key) && this.fulltexts[0] !== undefined && this.fulltexts[0].url !== '' && this.images.length > 0) {
var value = urlParams[key],
values = value.split(';'),
fulltextData = dlfViewerFullTextControl.fetchFulltextDataFromServer(this.fulltexts[0].url, this.images[0]),
fulltextDataImageTwo = undefined;
// check if there is another image / fulltext to look for
if (this.images.length == 2 & this.fulltexts[1] !== undefined && this.fulltexts[1].url !== '') {
if (this.images.length === 2 & this.fulltexts[1] !== undefined && this.fulltexts[1].url !== '') {
var image = $.extend({}, this.images[1]);
image.width = image.width + this.images[0].width;
fulltextDataImageTwo = dlfViewerFullTextControl.fetchFulltextDataFromServer(this.fulltexts[1].url, this.images[1], this.images[0].width);

View File

@ -13,12 +13,12 @@
// Internet Explorer does not support String.prototype.endsWith
if (String.prototype.endsWith === undefined) {
String.prototype.endsWith = function(searchString, length) {
if (searchString == null || searchString == '' || length!=null && searchString.length > length || searchString.length > this.length) {
if (searchString === null || searchString === '' || length!=null && searchString.length > length || searchString.length > this.length) {
return false;
}
length = length == null || length > this.length || length <= 0 ? this.length : length;
length = length === null || length > this.length || length <= 0 ? this.length : length;
var substr = this.substr(0, length);
return substr.lastIndexOf(searchString) == length - searchString.length;
return substr.lastIndexOf(searchString) === length - searchString.length;
};
}
@ -462,7 +462,7 @@ dlfUtils.buildImageV3 = function buildImageV2(mimetype, uri, jsonld) {
tilesize: jsonld.tiles !== undefined ? [jsonld.tiles.map(function(a) {
return a.width;
})[0], jsonld.tiles.map(function (a) {
return a.height == undefined ? a.width : a.height;
return a.height === undefined ? a.width : a.height;
})[0]] : undefined,
sizes: jsonld.sizes === undefined ? undefined : jsonld.sizes.map(function(size) {
return [size.width, size.height];
@ -490,7 +490,7 @@ dlfUtils.buildImageV3 = function buildImageV2(mimetype, uri, jsonld) {
* @returns {{src: *, width, height, tilesize: [*,*], qualities: *, formats: *, resolutions: *, mimetype: *}}
*/
dlfUtils.buildImageV2 = function buildImageV2(mimetype, uri, jsonld) {
if (typeof jsonld.profile == "string") {
if (typeof jsonld.profile === "string") {
jsonld.profile = [jsonld.profile, {}];
}
if (jsonld.profile !== undefined && jsonld.profile.length < 2) {
@ -505,7 +505,7 @@ dlfUtils.buildImageV2 = function buildImageV2(mimetype, uri, jsonld) {
tilesize: jsonld.tiles !== undefined ? [jsonld.tiles.map(function(a) {
return a.width;
})[0], jsonld.tiles.map(function (a) {
return a.height == undefined ? a.width : a.height;
return a.height === undefined ? a.width : a.height;
})[0]] : undefined,
sizes: jsonld.sizes === undefined ? undefined : jsonld.sizes.map(function(size) {
return [size.width, size.height];
@ -573,10 +573,10 @@ dlfUtils.getIiifComplianceLevelProfile = function(jsonld, version) {
}
break;
case 'version2':
if (typeof jsonld.profile == 'string' && regexVersion2.test(jsonld.profile)) {
if (typeof jsonld.profile === 'string' && regexVersion2.test(jsonld.profile)) {
level = jsonld.profile;
}
if (Array.isArray(jsonld.profile) && jsonld.profile.length >= 1 && typeof jsonld.profile[0] == 'string' && regexVersion2.test(jsonld.profile[0])) {
if (Array.isArray(jsonld.profile) && jsonld.profile.length >= 1 && typeof jsonld.profile[0] === 'string' && regexVersion2.test(jsonld.profile[0])) {
level = jsonld.profile[0];
}
break;