From 82d28ee89cefd0aae2f58366d6732ffe75719d0e Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Wed, 4 Feb 2015 23:45:43 -0800 Subject: [PATCH] Installed jshint, cleaned up lots of little issues --- js/browser.js | 3 +-- js/context.js | 8 +++--- js/file.js | 10 +++---- js/font.js | 4 +-- js/hotkeys.js | 4 +-- js/main-window.js | 63 ++++++++++++++++++++++---------------------- js/media.js | 8 +++--- js/multi-display.js | 5 +--- js/skin.js | 8 +++--- js/visualizer.js | 4 +-- js/window-manager.js | 2 +- 11 files changed, 57 insertions(+), 62 deletions(-) diff --git a/js/browser.js b/js/browser.js index f540f01d..1c114d07 100644 --- a/js/browser.js +++ b/js/browser.js @@ -9,6 +9,5 @@ Browser = { _supportsCanvas: function() { return !!document.createElement('canvas').getContext; } - -} +}; diff --git a/js/context.js b/js/context.js index 3685f470..f48f3fc0 100644 --- a/js/context.js +++ b/js/context.js @@ -8,12 +8,12 @@ Context = { document.onclick = function() { self.option.classList.remove('selected'); - } + }; this.option.onclick = function(event) { self.option.classList.toggle('selected'); event.stopPropagation(); - } + }; var skinSelectNodes = document.getElementsByClassName('skin-select'); for(var i = 0; i < skinSelectNodes.length; i++) { @@ -21,7 +21,7 @@ Context = { var skinFile = new MyFile(); skinFile.setUrl(this.dataset.skinUrl); self.winamp.setSkin(skinFile); - } + }; } document.getElementById('context-play-file').onclick = function(event) { @@ -36,4 +36,4 @@ Context = { self.winamp.close(); }; } -} +}; diff --git a/js/file.js b/js/file.js index fa0b62e8..fa567858 100644 --- a/js/file.js +++ b/js/file.js @@ -6,10 +6,10 @@ MyFile = function(){ this.fileReference = null; this.setUrl = function(url){ this.url = url; - } + }; this.setFileReference = function(fileReference){ this.fileReference = fileReference; - } + }; this.processBuffer = function(bufferHandler) { if(this.url) { var oReq = new XMLHttpRequest(); @@ -22,7 +22,7 @@ MyFile = function(){ }; oReq.send(null); - return + return; } else if(this.fileReference) { this.reader.onload = function (e) { @@ -34,10 +34,10 @@ MyFile = function(){ }; this.reader.readAsArrayBuffer(this.fileReference); - return + return; } console.error('Tried to process an unpopulated file object'); return false; - } + }; }; diff --git a/js/font.js b/js/font.js index 855a528d..dbaba716 100644 --- a/js/font.js +++ b/js/font.js @@ -22,7 +22,7 @@ Font = { horizontalOffset = column * 5; x = '-' + horizontalOffset + 'px'; - y = '-' + verticalOffset + 'px' + y = '-' + verticalOffset + 'px'; node.style.backgroundPosition = x + ' ' + y; node.classList.add('character'); @@ -79,4 +79,4 @@ Font = { "Ä": [2,2], "?": [2,3], "*": [2,4], " ": [2,5], "<": [1,22], ">": [1,23], "{": [1,22], "}": [1,23] } -} +}; diff --git a/js/hotkeys.js b/js/hotkeys.js index 90026177..79714952 100644 --- a/js/hotkeys.js +++ b/js/hotkeys.js @@ -43,7 +43,7 @@ Hotkeys = { if(keylog.toString() == trigger.toString()) { winamp.toggleLlama(); } - } + }; } -} +}; diff --git a/js/main-window.js b/js/main-window.js index b8636f8b..e58e447c 100644 --- a/js/main-window.js +++ b/js/main-window.js @@ -60,7 +60,7 @@ MainWindow = { this.nodes.shade.onclick = function() { self.nodes.window.classList.toggle('shade'); - } + }; this.nodes.buttonD.onmousedown = function() { if(self.nodes.window.classList.contains('doubled')) { @@ -69,41 +69,41 @@ MainWindow = { self.textDisplay.setRegisterText('message', 'Enable doublesize mode'); } self.textDisplay.showRegister('message'); - } + }; this.nodes.buttonD.onmouseup = function() { self.textDisplay.showRegister('songTitle'); - } + }; this.nodes.buttonD.onclick = function() { self.winamp.toggleDoubledMode(); - } + }; this.nodes.play.onclick = function() { self.winamp.play(); - } + }; this.nodes.songTitle.onmousedown = function() { self.textDisplay.pauseRegisterMarquee('songTitle'); - } + }; this.nodes.songTitle.onmouseup = function() { setTimeout(function () { self.textDisplay.startRegisterMarquee('songTitle'); }, 1000); - } + }; this.nodes.position.onmousedown = function() { if(!self.nodes.window.classList.contains('stop')){ self.textDisplay.showRegister('position'); self.nodes.window.classList.add('setting-position'); } - } + }; this.nodes.position.onmouseup = function() { self.textDisplay.showRegister('songTitle'); self.nodes.window.classList.remove('setting-position'); - } + }; this.nodes.position.oninput = function() { var newPercentComplete = self.nodes.position.value; @@ -112,80 +112,80 @@ MainWindow = { var duration = self._timeString(self.winamp.getDuration()); var message = "Seek to: " + newElapsed + "/" + duration + " (" + newPercentComplete + "%)"; self.textDisplay.setRegisterText('position', message); - } + }; this.nodes.position.onchange = function() { if(self.winamp.getState() != 'stop'){ self.winamp.seekToPercentComplete(this.value); } - } + }; this.nodes.previous.onclick = function() { self.winamp.previous(); - } + }; this.nodes.next.onclick = function() { self.winamp.next(); - } + }; this.nodes.pause.onclick = function() { self.winamp.pause(); - } + }; this.nodes.stop.onclick = function() { self.winamp.stop(); - } + }; this.nodes.eject.onclick = function() { self.winamp.openFileDialog(); - } + }; this.nodes.repeat.onclick = function() { self.winamp.toggleRepeat(); - } + }; this.nodes.shuffle.onclick = function() { self.winamp.toggleShuffle(); - } + }; this.nodes.shadeTime.onclick = function() { self.winamp.toggleTimeMode(); - } + }; this.nodes.volume.onmousedown = function() { self.textDisplay.showRegister('volume'); - } + }; this.nodes.volume.onmouseup = function() { self.textDisplay.showRegister('songTitle'); - } + }; this.nodes.volume.oninput = function() { self.winamp.setVolume(this.value); - } + }; this.nodes.time.onclick = function() { self.winamp.toggleTimeMode(); - } + }; this.nodes.balance.onmousedown = function() { self.textDisplay.showRegister('balance'); - } + }; this.nodes.balance.onmouseup = function() { self.textDisplay.showRegister('songTitle'); - } + }; this.nodes.balance.oninput = function() { if(Math.abs(this.value) < 25) { this.value = 0; } self.winamp.setBalance(this.value); - } + }; this.nodes.visualizer.onclick = function() { self.winamp.toggleVisualizer(); - } + }; window.addEventListener('timeUpdated', function() { self.updateTime(); }); window.addEventListener('startWaiting', function() { self.setWorkingIndicator(); }); @@ -244,7 +244,7 @@ MainWindow = { var shadeMinusCharacter = ' '; if(this.nodes.time.classList.contains('countdown')) { digits = this.winamp._timeObject(this.winamp.getTimeRemaining()); - var shadeMinusCharacter = '-'; + shadeMinusCharacter = '-'; } else { digits = this.winamp._timeObject(this.winamp.getTimeElapsed()); } @@ -313,7 +313,7 @@ MainWindow = { setBalance: function() { var balance = this.winamp.getBalance(); var string = ''; - if(balance == 0) { + if(balance === 0) { string = 'Balance: Center'; } else if(balance > 0) { string = 'Balance: ' + balance + '% Right'; @@ -321,7 +321,7 @@ MainWindow = { string = 'Balance: ' + Math.abs(balance) + '% Left'; } this.textDisplay.setRegisterText('balance', string); - balance = Math.abs(balance) / 100 + balance = Math.abs(balance) / 100; var sprite = Math.round(balance * 28); var offset = (sprite - 1) * 15; this.nodes.balance.style.backgroundPosition = '-9px -' + offset + 'px'; @@ -387,5 +387,4 @@ MainWindow = { var timeObject = this.winamp._timeObject(time); return timeObject[0] + timeObject[1] + ':' + timeObject[2] + timeObject[3]; } - -} +}; diff --git a/js/media.js b/js/media.js index c0ec94f7..09afa594 100644 --- a/js/media.js +++ b/js/media.js @@ -89,11 +89,11 @@ Media = { if(this.autoPlay) { this.play(0); } - } + }; var error = function (error) { //console.error("failed to decode:", error); - } + }; // Decode the target file into an arrayBuffer and pass it to loadBuffer this._context.decodeAudioData(buffer, loadAudioBuffer.bind(this), error); }, @@ -185,7 +185,7 @@ Media = { // Hack for Firefox. Having either channel set to 0 seems to revert us // to equal balance. - var changeVal = changeVal - .00000001; + changeVal = changeVal - 0.00000001; if(balance > 0) { // Right this._leftGain.gain.value = 1 - changeVal; @@ -256,4 +256,4 @@ Media = { } return this._position; } -} +}; diff --git a/js/multi-display.js b/js/multi-display.js index 1472e7f9..18890090 100644 --- a/js/multi-display.js +++ b/js/multi-display.js @@ -58,7 +58,4 @@ MultiDisplay = { self._marqueeLoop(); }, 220); } -} - - - +}; diff --git a/js/skin.js b/js/skin.js index 10fac5eb..fbb47b79 100644 --- a/js/skin.js +++ b/js/skin.js @@ -64,7 +64,7 @@ SkinManager = { var file = this._findFileInZip(fileName, zip); if (file) { - var value = "background-image: url(data:image/bmp;base64," + btoa(file.asBinary()) + ")" + var value = "background-image: url(data:image/bmp;base64," + btoa(file.asBinary()) + ")"; cssRules += selector + "{" + value + "}\n"; // CSS has to change if this file is present @@ -81,7 +81,7 @@ SkinManager = { _parseVisColors: function(zip) { var entries = this._findFileInZip("VISCOLOR.TXT", zip).asText().split("\n"); - var regex = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/ + var regex = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/; var colors = []; // changed to a hard number to deal with empty lines at the end... // plus its only meant to be an exact amount of numbers anywayz @@ -99,7 +99,7 @@ SkinManager = { _findFileInZip: function(name, zip) { return zip.filter(function (relativePath, file){ - return new RegExp("(^|/)" + name, 'i').test(relativePath) + return new RegExp("(^|/)" + name, 'i').test(relativePath); })[0]; }, @@ -110,4 +110,4 @@ SkinManager = { this.styleNode = document.createElement('style'); document.head.appendChild(this.styleNode); } -} +}; diff --git a/js/visualizer.js b/js/visualizer.js index 4b32f2e0..f37221bb 100644 --- a/js/visualizer.js +++ b/js/visualizer.js @@ -133,7 +133,7 @@ Visualizer = { // Canvas coordinates are in the middle of the pixel by default. // When we want to draw pixel perfect lines, we will need to // account for that here - if(x == 0) { + if(x === 0) { this.canvasCtx.moveTo(x, y); } else { this.canvasCtx.lineTo(x, y); @@ -160,4 +160,4 @@ Visualizer = { printBar(j*8, height); } } -} +}; diff --git a/js/window-manager.js b/js/window-manager.js index 8a0e3e6d..ff88e48e 100644 --- a/js/window-manager.js +++ b/js/window-manager.js @@ -55,4 +55,4 @@ WindowManager = { window.addEventListener('mouseup',handleUp); }); } -} +};