Installed jshint, cleaned up lots of little issues

This commit is contained in:
Jordan Eldredge 2015-02-04 23:45:43 -08:00
parent c18ebd0237
commit 82d28ee89c
11 changed files with 57 additions and 62 deletions

View file

@ -9,6 +9,5 @@ Browser = {
_supportsCanvas: function() {
return !!document.createElement('canvas').getContext;
}
}
};

View file

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

View file

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

View file

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

View file

@ -43,7 +43,7 @@ Hotkeys = {
if(keylog.toString() == trigger.toString()) {
winamp.toggleLlama();
}
}
};
}
}
};

View file

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

View file

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

View file

@ -58,7 +58,4 @@ MultiDisplay = {
self._marqueeLoop();
}, 220);
}
}
};

View file

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

View file

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

View file

@ -55,4 +55,4 @@ WindowManager = {
window.addEventListener('mouseup',handleUp);
});
}
}
};