From 643ee211cad542a7f58116367f9793cb272d2b16 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Tue, 18 Jun 2013 17:55:19 -0400 Subject: [PATCH] Remove unused variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mostly unused function arguments but there were also a fair number of legacy names which are now no longer used. One question which comes up – mostly in tilesource.js – is whether there is any value in leaving unused variables for functions which are intended to be overridden anyway. I'm inclined to say that the docs + tests need to be sufficient as there's no enforcement that whatever is in the base implementation will actually be followed by any of the real functions. --- src/controldock.js | 4 ---- src/drawer.js | 3 +-- src/dzitilesource.js | 6 +----- src/fullscreen.js | 3 +-- src/iiiftilesource.js | 7 +------ src/navigator.js | 5 ++--- src/openseadragon.js | 18 ++++++------------ src/referencestrip.js | 18 +++--------------- src/tilesource.js | 10 +++------- src/tilesourcecollection.js | 2 +- src/viewer.js | 7 ++----- src/viewport.js | 4 +--- 12 files changed, 22 insertions(+), 65 deletions(-) diff --git a/src/controldock.js b/src/controldock.js index d7a17556..2121966e 100644 --- a/src/controldock.js +++ b/src/controldock.js @@ -33,10 +33,6 @@ */ (function( $ ){ - - //id hash for private properties; - var THIS = {}; - /** * @class */ diff --git a/src/drawer.js b/src/drawer.js index df644ece..e0cba1d9 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -672,8 +672,7 @@ function updateTile( drawer, drawLevel, haveDrawn, x, y, level, levelOpacity, le numberOfTiles, drawer.normHeight ), - drawTile = drawLevel, - newbest; + drawTile = drawLevel; if( drawer.viewer ){ drawer.viewer.raiseEvent( 'update-tile', { diff --git a/src/dzitilesource.js b/src/dzitilesource.js index ea0b482b..7ca2a279 100644 --- a/src/dzitilesource.js +++ b/src/dzitilesource.js @@ -126,11 +126,7 @@ $.extend( $.DziTileSource.prototype, $.TileSource.prototype, { */ configure: function( data, url ){ - var dziPath, - dziName, - tilesUrl, - options, - host; + var options; if( !$.isPlainObject(data) ){ diff --git a/src/fullscreen.js b/src/fullscreen.js index c695283f..bde5b78c 100644 --- a/src/fullscreen.js +++ b/src/fullscreen.js @@ -112,7 +112,7 @@ element[this.prefix + 'RequestFullScreen'](); }; - fullScreenApi.cancelFullScreen = function( element ) { + fullScreenApi.cancelFullScreen = function() { return (this.prefix === '') ? document.cancelFullScreen() : document[this.prefix + 'CancelFullScreen'](); @@ -130,7 +130,6 @@ fullScreenApi.cancelFullScreen = fullScreenApi.requestFullScreen; } - // export api $.extend( $, fullScreenApi ); diff --git a/src/iiiftilesource.js b/src/iiiftilesource.js index cee77d0a..ae1896df 100644 --- a/src/iiiftilesource.js +++ b/src/iiiftilesource.js @@ -111,7 +111,6 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, { */ configure: function( data, url ){ var service, - identifier, options, host; @@ -236,11 +235,7 @@ function configureFromXml( tileSource, xmlDoc ){ var root = xmlDoc.documentElement, rootName = root.tagName, - configuration = null, - scale_factors, - formats, - qualities, - i; + configuration = null; if ( rootName == "info" ) { diff --git a/src/navigator.js b/src/navigator.js index 25753509..80d4a962 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -49,8 +49,7 @@ */ $.Navigator = function( options ){ - var _this = this, - viewer = options.viewer, + var viewer = options.viewer, viewerSize = $.getElementSize( viewer.element), unneededElement; @@ -199,7 +198,7 @@ $.extend( $.Navigator.prototype, $.EventHandler.prototype, $.Viewer.prototype, { bottomright = this.viewport.pixelFromPoint( bounds.getBottomRight()).minus(this.totalBorderWidths); //update style for navigator-box - (function(style, borderWidth){ + (function(style) { style.top = topleft.y + 'px'; style.left = topleft.x + 'px'; diff --git a/src/openseadragon.js b/src/openseadragon.js index 5b7b52a2..b6d7b5f2 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -747,11 +747,11 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ */ getEvent: function( event ) { if( event ){ - $.getEvent = function( event ){ + $.getEvent = function( event ) { return event; }; } else { - $.getEvent = function( event ){ + $.getEvent = function() { return window.event; }; } @@ -1283,7 +1283,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ request = new XMLHttpRequest(); } else if ( window.ActiveXObject ) { /*jshint loopfunc:true*/ - for ( i = 0; i < ACTIVEX.length; i++ ) { + for ( var i = 0; i < ACTIVEX.length; i++ ) { try { request = new ActiveXObject( ACTIVEX[ i ] ); $.createAjaxRequest = function( ){ @@ -1316,9 +1316,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ var async = true, request = $.createAjaxRequest(), - actual, - options, - i; + options; if( $.isPlainObject( url ) ){ @@ -1453,12 +1451,9 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ * Fully deprecated. Will throw an error. * @function * @name OpenSeadragon.createFromDZI - * @param {String} xmlUrl - * @param {String} xmlString - * @param {Function} callback * @deprecated - use OpenSeadragon.Viewer.prototype.open */ - createFromDZI: function( dzi, callback, tileHost ) { + createFromDZI: function() { throw "OpenSeadragon.createFromDZI is deprecated, use Viewer.open."; }, @@ -1476,8 +1471,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ if ( window.ActiveXObject ) { $.parseXml = function( string ){ - var xmlDoc = null, - parser; + var xmlDoc = null; xmlDoc = new ActiveXObject( "Microsoft.XMLDOM" ); xmlDoc.async = false; diff --git a/src/referencestrip.js b/src/referencestrip.js index e9d778a0..800933da 100644 --- a/src/referencestrip.js +++ b/src/referencestrip.js @@ -61,8 +61,6 @@ $.ReferenceStrip = function( options ){ var _this = this, viewer = options.viewer, viewerSize = $.getElementSize( viewer.element ), - miniViewer, - minPixelRatio, element, style, i; @@ -273,14 +271,12 @@ $.extend( $.ReferenceStrip.prototype, $.EventHandler.prototype, $.Viewer.prototy * @function * @name OpenSeadragon.ReferenceStrip.prototype.update */ - update: function( viewport ){ - - if( THIS[ this.id ].animating ){ + update: function() { + if ( THIS[ this.id ].animating ) { $.console.log('image reference strip update'); return true; } return false; - } }); @@ -484,15 +480,7 @@ function onStripEnter( tracker ) { * @function */ function onStripExit( tracker ) { - - var viewerSize = $.getElementSize( this.viewer.element ); - - //$.setElementOpacity(tracker.element, 0.4); - //tracker.element.style.border = 'none'; - //tracker.element.style.background = '#fff'; - - - if( 'horizontal' == this.scroll ){ + if ( 'horizontal' == this.scroll ) { //tracker.element.style.paddingTop = "10px"; tracker.element.style.marginBottom = "-" + ( $.getElementSize( tracker.element ).y / 2 ) + "px"; diff --git a/src/tilesource.js b/src/tilesource.js index 717aecba..3168606e 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -84,9 +84,7 @@ * The maximum pyramid level this tile source supports or should attempt to load. */ $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLevel ) { - var _this = this, - callback = null, - readyHandler = null, + var callback = null, args = arguments, options, i; @@ -274,16 +272,14 @@ $.TileSource.prototype = { * @throws {Error} */ getImageInfo: function( url ) { - var _this = this, - error, + var _this = this, callbackName, callback, readySource, options, urlParts, filename, - lastDot, - tilesUrl; + lastDot; if( url ) { diff --git a/src/tilesourcecollection.js b/src/tilesourcecollection.js index dcf3b8df..218b2e4c 100644 --- a/src/tilesourcecollection.js +++ b/src/tilesourcecollection.js @@ -39,7 +39,7 @@ * @extends OpenSeadragon.TileSource */ $.TileSourceCollection = function( tileSize, tileSources, rows, layout ) { - + var options; if( $.isPlainObject( tileSize ) ){ options = tileSize; diff --git a/src/viewer.js b/src/viewer.js index 47cb9072..10b0735a 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -174,8 +174,7 @@ $.Viewer = function( options ) { $.ControlDock.call( this, options ); //Deal with tile sources - var initialTileSource, - customTileSource; + var initialTileSource; if ( this.xmlPath ){ //Deprecated option. Now it is preferred to use the tileSources option @@ -569,7 +568,6 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, var body = document.body, bodyStyle = body.style, docStyle = document.documentElement.style, - containerStyle = this.element.style, canvasStyle = this.canvas.style, _this = this, oldBounds, @@ -635,7 +633,7 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, body.appendChild( this.element ); if( $.supportsFullScreen ){ - THIS[ this.hash ].onfullscreenchange = function( event ) { + THIS[ this.hash ].onfullscreenchange = function() { // The event object doesn't carry information about the // fullscreen state of the browser, but it is possible to // retrieve it through the fullscreen API @@ -817,7 +815,6 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, onNextHandler = $.delegate( this, onNext ), onPreviousHandler = $.delegate( this, onPrevious ), navImages = this.navImages, - buttons = [], useGroup = true ; if( this.showSequenceControl && THIS[ this.hash ].sequenced ){ diff --git a/src/viewport.js b/src/viewport.js index 5c6a95c2..3c560fd9 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -309,10 +309,8 @@ $.Viewport.prototype = { right, top, bottom, - center, dx = 0, - dy = 0, - dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0; + dy = 0; if ( actualZoom != constrainedZoom ) { this.zoomTo( constrainedZoom, this.zoomPoint, immediately );