Merge pull request from timvandermeij/strict-equalities

Use strict equalities in web/*
This commit is contained in:
Tim van der Meij 2014-08-01 19:26:14 +02:00
commit 49142e9d5a
5 changed files with 23 additions and 23 deletions

@ -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);
}

@ -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');

@ -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;
}

@ -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 =

@ -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;
}