From 24cf9694228af36084f9c4d7c45d65006e99613d Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Thu, 31 Jul 2014 21:47:23 +0200 Subject: [PATCH 1/5] Use strict equalities in web/ui_utils.js --- web/ui_utils.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/ui_utils.js b/web/ui_utils.js index 29ee01bb8..b38ec4bc3 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -30,7 +30,7 @@ var CustomStyle = (function CustomStyleClosure() { CustomStyle.getProp = function get(propName, element) { // check cache only when no element is given - if (arguments.length == 1 && typeof _cache[propName] == 'string') { + if (arguments.length === 1 && typeof _cache[propName] === 'string') { return _cache[propName]; } @@ -38,7 +38,7 @@ var CustomStyle = (function CustomStyleClosure() { var style = element.style, prefixed, uPropName; // test standard property first - if (typeof style[propName] == 'string') { + if (typeof style[propName] === 'string') { return (_cache[propName] = propName); } @@ -48,7 +48,7 @@ var CustomStyle = (function CustomStyleClosure() { // test vendor specific properties for (var i = 0, l = prefixes.length; i < l; i++) { prefixed = prefixes[i] + uPropName; - if (typeof style[prefixed] == 'string') { + if (typeof style[prefixed] === 'string') { return (_cache[propName] = prefixed); } } @@ -59,7 +59,7 @@ var CustomStyle = (function CustomStyleClosure() { CustomStyle.setProp = function set(propName, element, str) { var prop = this.getProp(propName); - if (prop != 'undefined') { + if (prop !== 'undefined') { element.style[prop] = str; } }; @@ -93,7 +93,7 @@ function getOutputScale(ctx) { return { sx: pixelRatio, sy: pixelRatio, - scaled: pixelRatio != 1 + scaled: pixelRatio !== 1 }; } @@ -161,7 +161,7 @@ function getPDFFileNameFromURL(url) { reFilename.exec(splitURI[3]); if (suggestedFilename) { suggestedFilename = suggestedFilename[0]; - if (suggestedFilename.indexOf('%') != -1) { + if (suggestedFilename.indexOf('%') !== -1) { // URL-encoded %2Fpath%2Fto%2Ffile.pdf should be file.pdf try { suggestedFilename = From ea85a2f7a70119cd7fe855cbb215336ee2928625 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Thu, 31 Jul 2014 21:49:29 +0200 Subject: [PATCH 2/5] Use strict equalities in web/viewer.js --- web/viewer.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/viewer.js b/web/viewer.js index 1be81e02c..f44d500e3 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -805,7 +805,7 @@ var PDFView = { var pdfOpenParams = PDFView.getAnchorUrl('#page=' + pageNumber); var destKind = dest[1]; if (typeof destKind === 'object' && 'name' in destKind && - destKind.name == 'XYZ') { + destKind.name === 'XYZ') { var scale = (dest[4] || this.currentScaleValue); var scaleNumber = parseFloat(scale); if (scaleNumber) { @@ -1668,9 +1668,9 @@ var PDFView = { // In case we are already on the first or the last page there is no need // to do anything. - if ((currentPage == 1 && pageFlipDirection == PageFlipDirection.UP) || - (currentPage == this.pages.length && - pageFlipDirection == PageFlipDirection.DOWN)) { + if ((currentPage === 1 && pageFlipDirection === PageFlipDirection.UP) || + (currentPage === this.pages.length && + pageFlipDirection === PageFlipDirection.DOWN)) { return; } @@ -1862,7 +1862,7 @@ function webViewerInitialized() { var mainContainer = document.getElementById('mainContainer'); var outerContainer = document.getElementById('outerContainer'); mainContainer.addEventListener('transitionend', function(e) { - if (e.target == mainContainer) { + if (e.target === mainContainer) { var event = document.createEvent('UIEvents'); event.initUIEvent('resize', false, false, window, 0); window.dispatchEvent(event); @@ -2107,7 +2107,7 @@ function selectScaleOption(value) { var predefinedValueFound = false; for (var i = 0; i < options.length; i++) { var option = options[i]; - if (option.value != value) { + if (option.value !== value) { option.selected = false; continue; } From 7ca6f0839f0f032684c38b90633c1947ecdd9756 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Thu, 31 Jul 2014 21:55:06 +0200 Subject: [PATCH 3/5] Use strict equalities in web/document_properties.js --- web/document_properties.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/document_properties.js b/web/document_properties.js index e0161fefe..eefbc0e1c 100644 --- a/web/document_properties.js +++ b/web/document_properties.js @@ -171,10 +171,10 @@ var DocumentProperties = { // As per spec, utRel = 'Z' means equal to universal time. // The other cases ('-' and '+') have to be handled here. - if (utRel == '-') { + if (utRel === '-') { hours += offsetHours; minutes += offsetMinutes; - } else if (utRel == '+') { + } else if (utRel === '+') { hours -= offsetHours; minutes += offsetMinutes; } From ddd3c8fc2fe7b8715bed6d6f146c206d133b5dd6 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Thu, 31 Jul 2014 22:01:54 +0200 Subject: [PATCH 4/5] Use strict equalities in web/debugger.js --- web/debugger.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/debugger.js b/web/debugger.js index 0eed36821..2251682d8 100644 --- a/web/debugger.js +++ b/web/debugger.js @@ -53,7 +53,7 @@ var FontInspector = (function FontInspectorClosure() { var selects = document.getElementsByTagName('input'); for (var i = 0; i < selects.length; ++i) { var select = selects[i]; - if (select.dataset.fontName != fontName) { + if (select.dataset.fontName !== fontName) { continue; } select.checked = !select.checked; @@ -216,7 +216,7 @@ var StepperManager = (function StepperManagerClosure() { } for (i = 0; i < steppers.length; ++i) { var stepper = steppers[i]; - if (stepper.pageIndex == pageIndex) { + if (stepper.pageIndex === pageIndex) { stepper.panel.removeAttribute('hidden'); } else { stepper.panel.setAttribute('hidden', true); @@ -225,7 +225,7 @@ var StepperManager = (function StepperManagerClosure() { var options = stepperChooser.options; for (i = 0; i < options.length; ++i) { var option = options[i]; - option.selected = option.value == pageIndex; + option.selected = (option.value | 0) === pageIndex; } }, saveBreakPoints: function saveBreakPoints(pageIndex, bps) { @@ -332,7 +332,7 @@ var Stepper = (function StepperClosure() { line.className = 'line'; line.dataset.idx = i; chunk.appendChild(line); - var checked = this.breakPoints.indexOf(i) != -1; + var checked = this.breakPoints.indexOf(i) !== -1; var args = operatorList.argsArray[i] || []; var breakCell = c('td'); @@ -419,7 +419,7 @@ var Stepper = (function StepperClosure() { var allRows = this.panel.getElementsByClassName('line'); for (var x = 0, xx = allRows.length; x < xx; ++x) { var row = allRows[x]; - if (row.dataset.idx == idx) { + if (parseInt(row.dataset.idx, 10) === idx) { row.style.backgroundColor = 'rgb(251,250,207)'; row.scrollIntoView(); } else { @@ -597,7 +597,7 @@ var PDFBug = (function PDFBugClosure() { activePanel = index; var tools = this.tools; for (var j = 0; j < tools.length; ++j) { - if (j == index) { + if (j === index) { buttons[j].setAttribute('class', 'active'); tools[j].active = true; tools[j].panel.removeAttribute('hidden'); From 097bf41285f69b6558f3104b2c0f73b393e6b344 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Thu, 31 Jul 2014 22:02:56 +0200 Subject: [PATCH 5/5] Use strict equalities in web/compatibility.js --- web/compatibility.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/compatibility.js b/web/compatibility.js index a21bf6a29..6d57b9200 100644 --- a/web/compatibility.js +++ b/web/compatibility.js @@ -237,7 +237,7 @@ if (typeof PDFJS === 'undefined') { 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; window.atob = function (input) { input = input.replace(/=+$/, ''); - if (input.length % 4 == 1) { + if (input.length % 4 === 1) { throw new Error('bad atob input'); } for ( @@ -293,7 +293,7 @@ if (typeof PDFJS === 'undefined') { var dataset = {}; for (var j = 0, jj = this.attributes.length; j < jj; j++) { var attribute = this.attributes[j]; - if (attribute.name.substring(0, 5) != 'data-') { + if (attribute.name.substring(0, 5) !== 'data-') { continue; } var key = attribute.name.substring(5).replace(/\-([a-z])/g, @@ -416,7 +416,7 @@ if (typeof PDFJS === 'undefined') { function isDisabled(node) { return node.disabled || (node.parentNode && isDisabled(node.parentNode)); } - if (navigator.userAgent.indexOf('Opera') != -1) { + if (navigator.userAgent.indexOf('Opera') !== -1) { // use browser detection since we cannot feature-check this bug document.addEventListener('click', ignoreIfTargetDisabled, true); }