Some more linting

alternate-visualiser
William Toohey 10 years ago
parent 33f492cc7e
commit f4c587b47c
  1. 377
      js/HuesUI.js

@ -32,35 +32,35 @@ function HuesUI(parent) {
this.root.className = this.constructor.name; this.root.className = this.constructor.name;
parent.appendChild(this.root); parent.appendChild(this.root);
this.root.style.display = "none"; this.root.style.display = "none";
this.core = null; this.core = null;
this.imageName = null; this.imageName = null;
this.imageLink = null; this.imageLink = null;
this.songName = null; this.songName = null;
this.songLink = null; this.songLink = null;
this.hueName = null; this.hueName = null;
this.imagePrev = null; this.imagePrev = null;
this.imageNext = null; this.imageNext = null;
this.songPrev = null; this.songPrev = null;
this.songNext = null; this.songNext = null;
this.beatCount = null; this.beatCount = null;
this.timer = null; this.timer = null;
this.xBlur = null; this.xBlur = null;
this.yBlur = null; this.yBlur = null;
this.settingsToggle = null; this.settingsToggle = null;
this.hideToggle = null; this.hideToggle = null;
// Put this near the links to song/image lists/ Bottom right alignment // Put this near the links to song/image lists/ Bottom right alignment
this.listContainer = null; this.listContainer = null;
this.hidden = false; this.hidden = false;
this.initUI(); this.initUI();
} }
@ -70,21 +70,21 @@ HuesUI.prototype.initUI = function() {
// Major info, image, song names // Major info, image, song names
var imageName = document.createElement("div"); var imageName = document.createElement("div");
this.imageName = imageName; this.imageName = imageName;
this.imageLink = document.createElement("a"); this.imageLink = document.createElement("a");
this.imageLink.target = "_blank"; this.imageLink.target = "_blank";
this.imageName.appendChild(this.imageLink); this.imageName.appendChild(this.imageLink);
var songName = document.createElement("div"); var songName = document.createElement("div");
this.songName = songName; this.songName = songName;
this.songLink = document.createElement("a"); this.songLink = document.createElement("a");
this.songLink.target = "_blank"; this.songLink.target = "_blank";
this.songName.appendChild(this.songLink); this.songName.appendChild(this.songLink);
var hueName = document.createElement("div"); var hueName = document.createElement("div");
this.hueName = hueName; this.hueName = hueName;
// Prev/next controls // Prev/next controls
var imagePrev = document.createElement("div"); var imagePrev = document.createElement("div");
imagePrev.textContent = "<"; imagePrev.textContent = "<";
@ -102,7 +102,7 @@ HuesUI.prototype.initUI = function() {
songNext.textContent = ">"; songNext.textContent = ">";
songNext.onclick = function() {that.core.nextSong();}; songNext.onclick = function() {that.core.nextSong();};
this.songNext = songNext; this.songNext = songNext;
var songList = document.createElement("div"); var songList = document.createElement("div");
songList.textContent = "SONGS"; songList.textContent = "SONGS";
songList.onclick = function() {that.core.toggleSongList();}; songList.onclick = function() {that.core.toggleSongList();};
@ -111,35 +111,35 @@ HuesUI.prototype.initUI = function() {
imageList.textContent = "IMAGES"; imageList.textContent = "IMAGES";
imageList.onclick = function() {that.core.toggleImageList();}; imageList.onclick = function() {that.core.toggleImageList();};
this.imageList = imageList; this.imageList = imageList;
// Beat timer, x and y blur, millis timer // Beat timer, x and y blur, millis timer
this.timer = document.createElement("div"); this.timer = document.createElement("div");
this.timer.textContent = "T=$0x0000"; this.timer.textContent = "T=$0x0000";
this.beatCount = document.createElement("div"); this.beatCount = document.createElement("div");
this.beatCount.textContent = "B=$0x000"; this.beatCount.textContent = "B=$0x000";
this.xBlur = document.createElement("div"); this.xBlur = document.createElement("div");
this.xBlur.textContent = "X=$0x00"; this.xBlur.textContent = "X=$0x00";
this.yBlur = document.createElement("div"); this.yBlur = document.createElement("div");
this.yBlur.textContent = "Y=$0x00"; this.yBlur.textContent = "Y=$0x00";
// Config stuff // Config stuff
this.settingsToggle = document.createElement("div"); this.settingsToggle = document.createElement("div");
this.settingsToggle.innerHTML = '<i class="fa fa-cog"></i>'; this.settingsToggle.innerHTML = '<i class="fa fa-cog"></i>';
this.settingsToggle.onclick = function() { this.settingsToggle.onclick = function() {
that.core.settings.toggle(); that.core.settings.toggle();
}; };
this.hideToggle = document.createElement("div"); this.hideToggle = document.createElement("div");
this.hideToggle.innerHTML = "&#x25BC;"; this.hideToggle.innerHTML = "&#x25BC;";
this.hideToggle.onclick = function() { this.hideToggle.onclick = function() {
that.toggleHide(); that.toggleHide();
}; };
this.listContainer = document.createElement("div"); this.listContainer = document.createElement("div");
this.resizeHandler = function() { this.resizeHandler = function() {
that.resize(); that.resize();
}; };
@ -149,7 +149,7 @@ HuesUI.prototype.connectCore = function(core) {
this.core = core; this.core = core;
this.root.style.display = "block"; this.root.style.display = "block";
this.listContainer.appendChild(core.resourceManager.listView); this.listContainer.appendChild(core.resourceManager.listView);
window.addEventListener('resize', this.resizeHandler); window.addEventListener('resize', this.resizeHandler);
this.resizeHandler(); this.resizeHandler();
}; };
@ -191,20 +191,22 @@ HuesUI.prototype.updateVolume = function(vol) {};
HuesUI.prototype.setSongText = function() { HuesUI.prototype.setSongText = function() {
var song = this.core.currentSong; var song = this.core.currentSong;
if(!song) if(!song) {
return; return;
}
this.songLink.textContent = song.title.toUpperCase(); this.songLink.textContent = song.title.toUpperCase();
this.songLink.href = song.source; this.songLink.href = song.source;
}; };
HuesUI.prototype.setImageText = function() { HuesUI.prototype.setImageText = function() {
var image = this.core.currentImage; var image = this.core.currentImage;
if(!image) if(!image) {
return; return;
}
var name = image.fullname ? image.fullname : image.name; var name = image.fullname ? image.fullname : image.name;
this.imageLink.textContent = name.toUpperCase(); this.imageLink.textContent = name.toUpperCase();
@ -213,7 +215,7 @@ HuesUI.prototype.setImageText = function() {
HuesUI.prototype.setColourText = function() { HuesUI.prototype.setColourText = function() {
var colour = this.core.colours[this.core.colourIndex]; var colour = this.core.colours[this.core.colourIndex];
this.hueName.textContent = colour.n.toUpperCase(); this.hueName.textContent = colour.n.toUpperCase();
}; };
@ -254,7 +256,7 @@ function RetroUI() {
this.imageModeAuto = null; this.imageModeAuto = null;
this.imageModeAuto = null; this.imageModeAuto = null;
this.subControls = null; this.subControls = null;
HuesUI.call(this); HuesUI.call(this);
} }
@ -263,14 +265,14 @@ RetroUI.prototype.constructor = RetroUI;
RetroUI.prototype.initUI = function() { RetroUI.prototype.initUI = function() {
HuesUI.prototype.initUI.call(this); HuesUI.prototype.initUI.call(this);
var that = this; var that = this;
var container = document.createElement("div"); var container = document.createElement("div");
container.className = "hues-r-container"; container.className = "hues-r-container";
this.root.appendChild(container); this.root.appendChild(container);
this.container = container; this.container = container;
this.mode = document.createElement("div"); this.mode = document.createElement("div");
container.appendChild(this.mode); container.appendChild(this.mode);
container.appendChild(this.imageName); container.appendChild(this.imageName);
@ -278,23 +280,23 @@ RetroUI.prototype.initUI = function() {
container.appendChild(this.beatCount); container.appendChild(this.beatCount);
container.appendChild(this.xBlur); container.appendChild(this.xBlur);
container.appendChild(this.yBlur); container.appendChild(this.yBlur);
this.colourIndex = document.createElement("div"); this.colourIndex = document.createElement("div");
this.colourIndex.textContent = "C=$0x00"; this.colourIndex.textContent = "C=$0x00";
container.appendChild(this.colourIndex); container.appendChild(this.colourIndex);
this.version = document.createElement("div"); this.version = document.createElement("div");
container.appendChild(this.version); container.appendChild(this.version);
container.appendChild(this.hueName); container.appendChild(this.hueName);
container.appendChild(this.songName); container.appendChild(this.songName);
this.beatBar = document.createElement("div"); this.beatBar = document.createElement("div");
container.appendChild(this.beatBar); container.appendChild(this.beatBar);
this.controls = document.createElement("div"); this.controls = document.createElement("div");
this.controls.className = "hues-r-controls"; this.controls.className = "hues-r-controls";
var imageMode = document.createElement("div"); var imageMode = document.createElement("div");
this.imageModeManual = document.createElement("div"); this.imageModeManual = document.createElement("div");
this.imageModeManual.textContent = "NORMAL"; this.imageModeManual.textContent = "NORMAL";
@ -306,7 +308,7 @@ RetroUI.prototype.initUI = function() {
this.imageModeAuto.className = "hues-r-automode hues-r-button"; this.imageModeAuto.className = "hues-r-automode hues-r-button";
imageMode.appendChild(this.imageModeManual); imageMode.appendChild(this.imageModeManual);
imageMode.appendChild(this.imageModeAuto); imageMode.appendChild(this.imageModeAuto);
this.imagePrev.className = "hues-r-button"; this.imagePrev.className = "hues-r-button";
this.imageNext.className = "hues-r-button"; this.imageNext.className = "hues-r-button";
this.songPrev.className = "hues-r-button"; this.songPrev.className = "hues-r-button";
@ -314,14 +316,14 @@ RetroUI.prototype.initUI = function() {
this.controls.appendChild(this.imagePrev); this.controls.appendChild(this.imagePrev);
this.controls.appendChild(imageMode); this.controls.appendChild(imageMode);
this.controls.appendChild(this.imageNext); this.controls.appendChild(this.imageNext);
this.songList.className = "hues-r-songs hues-r-button"; this.songList.className = "hues-r-songs hues-r-button";
this.controls.appendChild(this.songPrev); this.controls.appendChild(this.songPrev);
this.controls.appendChild(this.songList); this.controls.appendChild(this.songList);
this.controls.appendChild(this.songNext); this.controls.appendChild(this.songNext);
this.root.appendChild(this.controls); this.root.appendChild(this.controls);
var subControl = document.createElement("div"); var subControl = document.createElement("div");
subControl.className = "hues-r-subcontrols"; subControl.className = "hues-r-subcontrols";
subControl.appendChild(this.settingsToggle); subControl.appendChild(this.settingsToggle);
@ -329,9 +331,9 @@ RetroUI.prototype.initUI = function() {
subControl.appendChild(this.imageList); subControl.appendChild(this.imageList);
subControl.appendChild(this.hideToggle); subControl.appendChild(this.hideToggle);
this.subControls = subControl; this.subControls = subControl;
this.root.appendChild(subControl); this.root.appendChild(subControl);
this.hideRestore = document.createElement("div"); this.hideRestore = document.createElement("div");
this.hideRestore.className = "hues-r-hiderestore"; this.hideRestore.className = "hues-r-hiderestore";
this.hideRestore.innerHTML = "&#x25B2;"; this.hideRestore.innerHTML = "&#x25B2;";
@ -339,7 +341,7 @@ RetroUI.prototype.initUI = function() {
that.toggleHide(); that.toggleHide();
}; };
this.root.appendChild(this.hideRestore); this.root.appendChild(this.hideRestore);
this.listContainer.className = "hues-r-listcontainer"; this.listContainer.className = "hues-r-listcontainer";
this.root.appendChild(this.listContainer); this.root.appendChild(this.listContainer);
}; };
@ -362,7 +364,7 @@ RetroUI.prototype.toggleHide = function(stylename) {
RetroUI.prototype.connectCore = function(core) { RetroUI.prototype.connectCore = function(core) {
HuesUI.prototype.connectCore.call(this, core); HuesUI.prototype.connectCore.call(this, core);
this.version.textContent = "V=$" + core.version; this.version.textContent = "V=$" + core.version;
this.modeUpdated(); this.modeUpdated();
}; };
@ -373,9 +375,10 @@ RetroUI.prototype.modeUpdated = function() {
RetroUI.prototype.setImageText = function() { RetroUI.prototype.setImageText = function() {
var image = this.core.currentImage; var image = this.core.currentImage;
if(!image) if(!image) {
return; return;
}
this.imageLink.textContent = "I=" + image.name.toUpperCase(); this.imageLink.textContent = "I=" + image.name.toUpperCase();
this.imageLink.href = image.source; this.imageLink.href = image.source;
@ -383,7 +386,7 @@ RetroUI.prototype.setImageText = function() {
RetroUI.prototype.setColourText = function(colour) { RetroUI.prototype.setColourText = function(colour) {
HuesUI.prototype.setColourText.call(this, colour); HuesUI.prototype.setColourText.call(this, colour);
this.colourIndex.textContent = "C=" + this.intToHex2(this.core.colourIndex); this.colourIndex.textContent = "C=" + this.intToHex2(this.core.colourIndex);
}; };
@ -392,13 +395,13 @@ RetroUI.prototype.beat = function() {
var rest = beats.slice(1); var rest = beats.slice(1);
this.beatBar.textContent = ">>" + rest; this.beatBar.textContent = ">>" + rest;
this.beatCount.textContent = "B=" + this.intToHex3(this.core.getSafeBeatIndex()); this.beatCount.textContent = "B=" + this.intToHex3(this.core.getSafeBeatIndex());
}; };
function WeedUI() { function WeedUI() {
RetroUI.call(this); RetroUI.call(this);
this.xVariance = 10; this.xVariance = 10;
this.yVariance = 20; this.yVariance = 20;
} }
@ -408,12 +411,12 @@ WeedUI.prototype.constructor = WeedUI;
WeedUI.prototype.initUI = function() { WeedUI.prototype.initUI = function() {
RetroUI.prototype.initUI.call(this); RetroUI.prototype.initUI.call(this);
this.container.removeChild(this.beatBar); this.container.removeChild(this.beatBar);
this.controls.className = "hues-w-controls"; this.controls.className = "hues-w-controls";
this.subControls.className = "hues-w-subcontrols"; this.subControls.className = "hues-w-subcontrols";
var beatBar = document.createElement("div"); var beatBar = document.createElement("div");
beatBar.className = "hues-w-beatbar"; beatBar.className = "hues-w-beatbar";
this.root.appendChild(beatBar); this.root.appendChild(beatBar);
@ -428,7 +431,7 @@ WeedUI.prototype.initUI = function() {
beatRight.className = "hues-w-beatright"; beatRight.className = "hues-w-beatright";
beatBar.appendChild(beatRight); beatBar.appendChild(beatRight);
this.beatRight = beatRight; this.beatRight = beatRight;
this.imageModeManual.textContent = "ONE"; this.imageModeManual.textContent = "ONE";
this.imageModeAuto.textContent = "MANY"; this.imageModeAuto.textContent = "MANY";
}; };
@ -448,16 +451,16 @@ WeedUI.prototype.beat = function() {
this.beatLeft.textContent = rest; this.beatLeft.textContent = rest;
this.beatRight.textContent = rest; this.beatRight.textContent = rest;
this.beatCount.textContent = "B=" + this.intToHex3(this.core.getSafeBeatIndex()); this.beatCount.textContent = "B=" + this.intToHex3(this.core.getSafeBeatIndex());
if(["x", "o", "X", "O"].indexOf(beats[0]) != -1) { if(["x", "o", "X", "O"].indexOf(beats[0]) != -1) {
var beatCenter = document.createElement("div"); var beatCenter = document.createElement("div");
beatCenter.className = "hues-w-beataccent"; beatCenter.className = "hues-w-beataccent";
var rot = this.round10(15 - Math.random() * 30); var rot = this.round10(15 - Math.random() * 30);
var x = this.round10(- this.xVariance / 2 + Math.random() * this.xVariance); var x = this.round10(- this.xVariance / 2 + Math.random() * this.xVariance);
var y = this.round10(30 - this.yVariance / 2 + Math.random() * this.yVariance); var y = this.round10(30 - this.yVariance / 2 + Math.random() * this.yVariance);
var transform = "rotate(" + rot + "deg) translate(" + x + "px," + y + "px)"; var transform = "rotate(" + rot + "deg) translate(" + x + "px, " + y + "px)";
beatCenter.style.MozTransform = transform; beatCenter.style.MozTransform = transform;
beatCenter.style.webkitTransform = transform; beatCenter.style.webkitTransform = transform;
beatCenter.style.transform = transform; beatCenter.style.transform = transform;
@ -491,11 +494,11 @@ function ModernUI() {
this.volInput = null; this.volInput = null;
this.volLabel = null; this.volLabel = null;
this.hideRestore = null; this.hideRestore = null;
this.currentBeat = "."; this.currentBeat = ".";
HuesUI.call(this); HuesUI.call(this);
this.hidden = 0; // we have a 3 stage hide this.hidden = 0; // we have a 3 stage hide
} }
@ -504,17 +507,17 @@ ModernUI.prototype.constructor = ModernUI;
ModernUI.prototype.initUI = function() { ModernUI.prototype.initUI = function() {
HuesUI.prototype.initUI.call(this); HuesUI.prototype.initUI.call(this);
var that = this; var that = this;
this.imageName.className = "hues-m-imagename"; this.imageName.className = "hues-m-imagename";
this.songName.className = "hues-m-songtitle"; this.songName.className = "hues-m-songtitle";
var controls = document.createElement("div"); var controls = document.createElement("div");
controls.className = "hues-m-controls"; controls.className = "hues-m-controls";
this.root.appendChild(controls); this.root.appendChild(controls);
this.controls = controls; this.controls = controls;
controls.appendChild(this.imageName); controls.appendChild(this.imageName);
controls.appendChild(this.songName); controls.appendChild(this.songName);
@ -522,20 +525,20 @@ ModernUI.prototype.initUI = function() {
leftBox.className = "hues-m-leftbox"; leftBox.className = "hues-m-leftbox";
controls.appendChild(leftBox); controls.appendChild(leftBox);
this.leftBox = leftBox; this.leftBox = leftBox;
this.hueName.className = "hues-m-huename"; this.hueName.className = "hues-m-huename";
leftBox.appendChild(this.hueName); leftBox.appendChild(this.hueName);
var volCluster = document.createElement("div"); var volCluster = document.createElement("div");
volCluster.className = "hues-m-vol-cluster"; volCluster.className = "hues-m-vol-cluster";
leftBox.appendChild(volCluster); leftBox.appendChild(volCluster);
this.settingsToggle.className = "hues-m-cog"; this.settingsToggle.className = "hues-m-cog";
volCluster.appendChild(this.settingsToggle); volCluster.appendChild(this.settingsToggle);
this.hideToggle.className = "hues-m-hide"; this.hideToggle.className = "hues-m-hide";
volCluster.appendChild(this.hideToggle); volCluster.appendChild(this.hideToggle);
var volBar = document.createElement("div"); var volBar = document.createElement("div");
volBar.className = "hues-m-vol-bar"; volBar.className = "hues-m-vol-bar";
volCluster.appendChild(volBar); volCluster.appendChild(volBar);
@ -548,7 +551,7 @@ ModernUI.prototype.initUI = function() {
}; };
volBar.appendChild(label); volBar.appendChild(label);
this.volLabel = label; this.volLabel = label;
var infoToggle = document.createElement("div"); var infoToggle = document.createElement("div");
infoToggle.innerHTML = '?'; infoToggle.innerHTML = '?';
infoToggle.className = "hues-m-question"; infoToggle.className = "hues-m-question";
@ -567,17 +570,17 @@ ModernUI.prototype.initUI = function() {
input.oninput = function() { input.oninput = function() {
that.core.soundManager.setVolume(parseFloat(input.value)); that.core.soundManager.setVolume(parseFloat(input.value));
}; };
var rightBox = document.createElement("div"); var rightBox = document.createElement("div");
rightBox.className = "hues-m-rightbox"; rightBox.className = "hues-m-rightbox";
controls.appendChild(rightBox); controls.appendChild(rightBox);
this.rightBox = rightBox; this.rightBox = rightBox;
//Song/image controls //Song/image controls
var songs = document.createElement("div"); var songs = document.createElement("div");
songs.className = "hues-m-controlblock"; songs.className = "hues-m-controlblock";
this.songList.className = "hues-m-songbutton"; this.songList.className = "hues-m-songbutton";
var songControls = document.createElement("div"); var songControls = document.createElement("div");
songControls.className = "hues-m-controlbuttons"; songControls.className = "hues-m-controlbuttons";
this.songPrev.className = "hues-m-prevbutton"; this.songPrev.className = "hues-m-prevbutton";
@ -592,14 +595,14 @@ ModernUI.prototype.initUI = function() {
songControls.appendChild(this.songNext); songControls.appendChild(this.songNext);
songs.appendChild(songControls); songs.appendChild(songControls);
rightBox.appendChild(songs); rightBox.appendChild(songs);
var images = document.createElement("div"); var images = document.createElement("div");
images.className = "hues-m-controlblock"; images.className = "hues-m-controlblock";
this.imageList.className = "hues-m-songbutton"; this.imageList.className = "hues-m-songbutton";
var imageControls = document.createElement("div"); var imageControls = document.createElement("div");
imageControls.className = "hues-m-controlbuttons"; imageControls.className = "hues-m-controlbuttons";
this.imageMode = document.createElement("div"); this.imageMode = document.createElement("div");
this.imageMode.innerHTML = "&#9654;"; // PLAY this.imageMode.innerHTML = "&#9654;"; // PLAY
this.imageMode.className = "hues-m-actbutton"; this.imageMode.className = "hues-m-actbutton";
@ -612,7 +615,7 @@ ModernUI.prototype.initUI = function() {
imageControls.appendChild(this.imageNext); imageControls.appendChild(this.imageNext);
images.appendChild(imageControls); images.appendChild(imageControls);
rightBox.appendChild(images); rightBox.appendChild(images);
var leftInfo = document.createElement("div"); var leftInfo = document.createElement("div");
leftInfo.className = "hues-m-leftinfo"; leftInfo.className = "hues-m-leftinfo";
var rightInfo = document.createElement("div"); var rightInfo = document.createElement("div");
@ -640,19 +643,19 @@ ModernUI.prototype.initUI = function() {
beatRight.className = "hues-m-beatright"; beatRight.className = "hues-m-beatright";
beatBar.appendChild(beatRight); beatBar.appendChild(beatRight);
this.beatRight = beatRight; this.beatRight = beatRight;
var beatCenter = document.createElement("div"); var beatCenter = document.createElement("div");
beatCenter.className = "hues-m-beatcenter"; beatCenter.className = "hues-m-beatcenter";
this.root.appendChild(beatCenter); this.root.appendChild(beatCenter);
this.beatCenter = beatCenter; this.beatCenter = beatCenter;
this.hideRestore = document.createElement("div"); this.hideRestore = document.createElement("div");
this.hideRestore.className = "hues-m-hiderestore"; this.hideRestore.className = "hues-m-hiderestore";
this.hideRestore.onclick = function() { this.hideRestore.onclick = function() {
that.toggleHide(); that.toggleHide();
}; };
this.root.appendChild(this.hideRestore); this.root.appendChild(this.hideRestore);
this.listContainer.className = "hues-m-listcontainer"; this.listContainer.className = "hues-m-listcontainer";
this.root.appendChild(this.listContainer); this.root.appendChild(this.listContainer);
}; };
@ -666,6 +669,7 @@ ModernUI.prototype.toggleHide = function() {
case 1: case 1:
this.beatBar.className = "hues-m-beatbar hidden"; this.beatBar.className = "hues-m-beatbar hidden";
this.beatCenter.className = "hues-m-beatcenter hidden"; this.beatCenter.className = "hues-m-beatcenter hidden";
/* falls through */
case 0: case 0:
this.controls.className = "hues-m-controls hidden"; this.controls.className = "hues-m-controls hidden";
this.hideRestore.className = "hues-m-hiderestore hidden"; this.hideRestore.className = "hues-m-hiderestore hidden";
@ -736,75 +740,79 @@ ModernUI.prototype.resizeImage = function() {
ModernUI.prototype.setSongText = function() { ModernUI.prototype.setSongText = function() {
HuesUI.prototype.setSongText.call(this); HuesUI.prototype.setSongText.call(this);
if(!this.core.currentSong) if(!this.core.currentSong) {
return; return;
}
this.resizeSong(); this.resizeSong();
}; };
ModernUI.prototype.setImageText = function() { ModernUI.prototype.setImageText = function() {
HuesUI.prototype.setImageText.call(this); HuesUI.prototype.setImageText.call(this);
if(!this.core.currentImage) if(!this.core.currentImage) {
return; return;
}
this.resizeImage(); this.resizeImage();
}; };
function XmasUI() { function XmasUI() {
ModernUI.call(this); ModernUI.call(this);
this.controls.removeChild(this.leftBox); this.controls.removeChild(this.leftBox);
this.controls.removeChild(this.rightBox); this.controls.removeChild(this.rightBox);
this.controls.removeChild(this.rightInfo); this.controls.removeChild(this.rightInfo);
this.controls.removeChild(this.leftInfo); this.controls.removeChild(this.leftInfo);
this.leftBox = this.rightBox = this.hueName = this.xBlur = this.yBlur = this.timer = null; this.leftBox = null;
this.rightBox = null;
this.hueName = null;
this.xBlur = null;
this.yBlur = null;
this.timer = null;
this.controls.className = "hues-x-controls"; this.controls.className = "hues-x-controls";
this.beatBar.className = "hues-x-beatbar"; this.beatBar.className = "hues-x-beatbar";
this.lights = []; this.lights = [];
var wires = document.createElement("div"); var wires = document.createElement("div");
wires.className = "hues-x-wires"; wires.className = "hues-x-wires";
var left = document.createElement("div"); var left = document.createElement("div");
left.className = "hues-x-wiresleft"; left.className = "hues-x-wiresleft";
for(var i = 0; i < xleft.length; i++) { xleft.forEach(function(l, i, a) {
var l = xleft[i];
var light = this.newLight(l, left); var light = this.newLight(l, left);
light.style.transform = "rotate(" + l.angle + "deg)"; light.style.transform = "rotate(" + l.angle + "deg)";
light.style.left = l.x + "px"; light.style.left = l.x + "px";
light.style.top = l.y + "px"; light.style.top = l.y + "px";
this.lights.push(light); this.lights.push(light);
} }, this);
var right = document.createElement("div"); var right = document.createElement("div");
right.className = "hues-x-wiresright"; right.className = "hues-x-wiresright";
for(var i = 0; i < xright.length; i++) { xright.forEach(function(l, i, a) {
var l = xright[i];
var light = this.newLight(l, right); var light = this.newLight(l, right);
light.style.transform = "rotate(" + (-l.angle) + "deg)"; light.style.transform = "rotate(" + (-l.angle) + "deg)";
light.style.right = l.x + "px"; light.style.right = l.x + "px";
light.style.top = l.y + "px"; light.style.top = l.y + "px";
this.lights.push(light); this.lights.push(light);
} }, this);
var bottomHelper = document.createElement("div"); var bottomHelper = document.createElement("div");
bottomHelper.className = "hues-x-wiresbottomhelper"; bottomHelper.className = "hues-x-wiresbottomhelper";
var bottom = document.createElement("div"); var bottom = document.createElement("div");
bottom.className = "hues-x-wiresbottom"; bottom.className = "hues-x-wiresbottom";
for(var i = 0; i < xbottom.length; i++) { xbottom.forEach(function(l, i, a) {
var l = xbottom[i];
var light = this.newLight(l, bottom); var light = this.newLight(l, bottom);
light.style.transform = "rotate(" + l.angle + "deg)"; light.style.transform = "rotate(" + l.angle + "deg)";
light.style.left = l.x + "px"; light.style.left = l.x + "px";
light.style.bottom = l.y + "px"; light.style.bottom = l.y + "px";
this.lights.push(light); this.lights.push(light);
} }, this);
wires.appendChild(left); wires.appendChild(left);
wires.appendChild(right); wires.appendChild(right);
bottomHelper.appendChild(bottom); bottomHelper.appendChild(bottom);
@ -877,20 +885,19 @@ XmasUI.prototype.newLight = function(l, parent) {
XmasUI.prototype.beat = function() { XmasUI.prototype.beat = function() {
ModernUI.prototype.beat.call(this); ModernUI.prototype.beat.call(this);
if(this.currentBeat != ".") { if(this.currentBeat != ".") {
for(var i = 0; i < this.lights.length; i++) { this.lights.forEach(function(light, i, a) {
var l = this.lights[i];
switch(this.currentBeat) { switch(this.currentBeat) {
case ":": case ": ":
this.lightOn(l); this.lightOn(light);
this.lightRecolour(l); this.lightRecolour(light);
break; break;
case "+": case "+":
this.lightFadeOut(l); this.lightFadeOut(light);
break; break;
default: default:
this.randomLight(this.lights[i]); this.randomLight(light);
} }
} }, this);
} }
}; };
@ -902,6 +909,7 @@ XmasUI.prototype.toggleHide = function() {
case 1: case 1:
this.beatBar.className = "hues-x-beatbar hidden"; this.beatBar.className = "hues-x-beatbar hidden";
this.beatCenter.className = "hues-m-beatcenter hidden"; this.beatCenter.className = "hues-m-beatcenter hidden";
/* falls through */
case 0: case 0:
this.controls.className = "hues-x-controls hidden"; this.controls.className = "hues-x-controls hidden";
} }
@ -912,78 +920,79 @@ XmasUI.prototype.setColourText = function(colour) {};
XmasUI.prototype.blurUpdated = function(x, y) {}; XmasUI.prototype.blurUpdated = function(x, y) {};
XmasUI.prototype.updateTime = function(time) {}; XmasUI.prototype.updateTime = function(time) {};
// Positions and angles for the Xmas lights
var xleft = [ var xleft = [
{"angle":122.529582194,"x":19.4,"y":-19.35}, {"angle": 122.529582194, "x": 19.4, "y": -19.35},
{"angle":92.5309436511,"x":25.4,"y":38.7}, {"angle": 92.5309436511, "x": 25.4, "y": 38.7},
{"angle":107.530202659,"x":39.4,"y":107.75}, {"angle": 107.530202659, "x": 39.4, "y": 107.75},
{"angle":77.5309700777,"x":20.75,"y":184.8}, {"angle": 77.5309700777, "x": 20.75, "y": 184.8},
{"angle":77.5309700777,"x":32.3,"y":249.8}, {"angle": 77.5309700777, "x": 32.3, "y": 249.8},
{"angle":107.530202659,"x":40.45,"y":327.9}, {"angle": 107.530202659, "x": 40.45, "y": 327.9},
{"angle":88.3307935055,"x":35,"y":410.9}, {"angle": 88.3307935055, "x": 35, "y": 410.9},
{"angle":107.530202659,"x":54.35,"y":490.95}, {"angle": 107.530202659, "x": 54.35, "y": 490.95},
{"angle":74.9981580491,"x":28.15,"y":573.8}, {"angle": 74.9981580491, "x": 28.15, "y": 573.8},
{"angle":89.9973772074,"x":23.45,"y":675.35}, {"angle": 89.9973772074, "x": 23.45, "y": 675.35},
{"angle":107.530202659,"x":21.65,"y":762.6}, {"angle": 107.530202659, "x": 21.65, "y": 762.6},
{"angle":107.530202659,"x":15.8,"y":842.75}, {"angle": 107.530202659, "x": 15.8, "y": 842.75},
{"angle":92.5309436511,"x":36.55,"y":905.7}, {"angle": 92.5309436511, "x": 36.55, "y": 905.7},
{"angle":88.3307935055,"x":31.1,"y":988.7}, {"angle": 88.3307935055, "x": 31.1, "y": 988.7},
{"angle":107.530202659,"x":50.45,"y":1068.75}, {"angle": 107.530202659, "x": 50.45, "y": 1068.75},
{"angle":74.9981580491,"x":45.75,"y":1158.5}, {"angle": 74.9981580491, "x": 45.75, "y": 1158.5},
{"angle":88.3307935055,"x":35.85,"y":1238.55} {"angle": 88.3307935055, "x": 35.85, "y": 1238.55}
]; ];
var xright = [ var xright = [
{"angle":120.001009518,"x":33.3,"y":-29.75}, {"angle": 120.001009518, "x": 33.3, "y": -29.75},
{"angle":90.0026227926,"x":35.35,"y":53.65}, {"angle": 90.0026227926, "x": 35.35, "y": 53.65},
{"angle":102.469029922,"x":41.5,"y":136.5}, {"angle": 102.469029922, "x": 41.5, "y": 136.5},
{"angle":91.6692064945,"x":22.15,"y":216.55}, {"angle": 91.6692064945, "x": 22.15, "y": 216.55},
{"angle":72.4697973408,"x":34.4,"y":278.25}, {"angle": 72.4697973408, "x": 34.4, "y": 278.25},
{"angle":102.469029922,"x":45.75,"y":361.85}, {"angle": 102.469029922, "x": 45.75, "y": 361.85},
{"angle":87.4699314665,"x":26.65,"y":426.35}, {"angle": 87.4699314665, "x": 26.65, "y": 426.35},
{"angle":72.4697973408,"x":41.6,"y":502.15}, {"angle": 72.4697973408, "x": 41.6, "y": 502.15},
{"angle":102.469029922,"x":27.5,"y":566}, {"angle": 102.469029922, "x": 27.5, "y": 566},
{"angle":72.4697973408,"x":7.65,"y":638.45}, {"angle": 72.4697973408, "x": 7.65, "y": 638.45},
{"angle":102.469029922,"x":11,"y":721.25}, {"angle": 102.469029922, "x": 11, "y": 721.25},
{"angle":76.1887724128,"x":7.65,"y":792.7}, {"angle": 76.1887724128, "x": 7.65, "y": 792.7},
{"angle":87.4690563489,"x":36.15,"y":850.35}, {"angle": 87.4690563489, "x": 36.15, "y": 850.35},
{"angle":102.46813454,"x":16.6,"y":924.3}, {"angle": 102.46813454, "x": 16.6, "y": 924.3},
{"angle":72.4697973408,"x":15.3,"y":990.8}, {"angle": 72.4697973408, "x": 15.3, "y": 990.8},
{"angle":76.1887724128,"x":11.95,"y":1062.25}, {"angle": 76.1887724128, "x": 11.95, "y": 1062.25},
{"angle":87.4690563489,"x":40.45,"y":1119.9}, {"angle": 87.4690563489, "x": 40.45, "y": 1119.9},
{"angle":102.46813454,"x":20.9,"y":1193.85} {"angle": 102.46813454, "x": 20.9, "y": 1193.85}
]; ];
var xbottom = [ var xbottom = [
{"angle":32.5804579323,"x":110.35,"y":-12.1}, {"angle": 32.5804579323, "x": 110.35, "y": -12.1},
{"angle":3.28979777069,"x":168.05,"y":-5.55}, {"angle": 3.28979777069, "x": 168.05, "y": -5.55},
{"angle":17.6989154099,"x":238.35,"y":7.7}, {"angle": 17.6989154099, "x": 238.35, "y": 7.7},
{"angle":-12.6587029361,"x":314.8,"y":-10.4}, {"angle": -12.6587029361, "x": 314.8, "y": -10.4},
{"angle":-12.6587029361,"x":379.4,"y":1.05}, {"angle": -12.6587029361, "x": 379.4, "y": 1.05},
{"angle":17.6989154099,"x":457.75,"y":9.4}, {"angle": 17.6989154099, "x": 457.75, "y": 9.4},
{"angle":2.59102780115,"x":540.6,"y":3.75}, {"angle": 2.59102780115, "x": 540.6, "y": 3.75},
{"angle":17.6989154099,"x":620.35,"y":22.7}, {"angle": 17.6989154099, "x": 620.35, "y": 22.7},
{"angle":-15.134241831,"x":703,"y":-2.9}, {"angle": -15.134241831, "x": 703, "y": -2.9},
{"angle":2.30443717424,"x":804.75,"y":-7.85}, {"angle": 2.30443717424, "x": 804.75, "y": -7.85},
{"angle":17.6989154099,"x":892.45,"y":-9.55}, {"angle": 17.6989154099, "x": 892.45, "y": -9.55},
{"angle":17.6989154099,"x":971.65,"y":-15.5}, {"angle": 17.6989154099, "x": 971.65, "y": -15.5},
{"angle":3.28979777069,"x":1035.2,"y":4.35}, {"angle": 3.28979777069, "x": 1035.2, "y": 4.35},
{"angle":2.59102780115,"x":1118,"y":0.2}, {"angle": 2.59102780115, "x": 1118, "y": 0.2},
{"angle":17.6989154099,"x":1198.05,"y":18.95}, {"angle": 17.6989154099, "x": 1198.05, "y": 18.95},
{"angle":-18.378894807,"x":1288.2,"y":14.2}, {"angle": -18.378894807, "x": 1288.2, "y": 14.2},
{"angle":-4.561224264,"x":1367.9,"y":4.6}, {"angle": -4.561224264, "x": 1367.9, "y": 4.6},
{"angle":32.5804579323,"x":1452.6,"y":-1.7}, {"angle": 32.5804579323, "x": 1452.6, "y": -1.7},
{"angle":3.28979777069,"x":1511.45,"y":4.45}, {"angle": 3.28979777069, "x": 1511.45, "y": 4.45},
{"angle":17.6989154099,"x":1580.6,"y":17.6}, {"angle": 17.6989154099, "x": 1580.6, "y": 17.6},
{"angle":-12.6587029361,"x":1656.6,"y":-0.95}, {"angle": -12.6587029361, "x": 1656.6, "y": -0.95},
{"angle":-12.6587029361,"x":1722.1,"y":11.1}, {"angle": -12.6587029361, "x": 1722.1, "y": 11.1},
{"angle":17.6989154099,"x":1800.5,"y":18.8}, {"angle": 17.6989154099, "x": 1800.5, "y": 18.8},
{"angle":2.59102780115,"x":1883.1,"y":13}, {"angle": 2.59102780115, "x": 1883.1, "y": 13},
{"angle":17.6989154099,"x":1963,"y":32.6}, {"angle": 17.6989154099, "x": 1963, "y": 32.6},
{"angle":-15.134241831,"x":2045.8,"y":7}, {"angle": -15.134241831, "x": 2045.8, "y": 7},
{"angle":2.30443717424,"x":2147.55,"y":1.55}, {"angle": 2.30443717424, "x": 2147.55, "y": 1.55},
{"angle":17.6989154099,"x":2234.1,"y":0.4}, {"angle": 17.6989154099, "x": 2234.1, "y": 0.4},
{"angle":17.6989154099,"x":2315,"y":-5.6}, {"angle": 17.6989154099, "x": 2315, "y": -5.6},
{"angle":3.28979777069,"x":2377.8,"y":14.5}, {"angle": 3.28979777069, "x": 2377.8, "y": 14.5},
{"angle":2.59102780115,"x":2460.65,"y":9.75}, {"angle": 2.59102780115, "x": 2460.65, "y": 9.75},
{"angle":17.6989154099,"x":2540.2,"y":28.5}, {"angle": 17.6989154099, "x": 2540.2, "y": 28.5},
{"angle":-18.378894807,"x":2627.55,"y":24.9}, {"angle": -18.378894807, "x": 2627.55, "y": 24.9},
{"angle":-4.561224264,"x":2710.4,"y":14.4} {"angle": -4.561224264, "x": 2710.4, "y": 14.4}
]; ];
Loading…
Cancel
Save