webamp/js/context.js
Jordan Eldredge c864300b00 Store files as instanace objects
With files encapsulated as objects, we can store them, sort them, and pass them
around. This is laying a foundation for handling playlists. (#10)

Also, we move the modification of the loading state outside of the skin
manager. This creates a better separation of concerns.
2015-01-25 13:31:27 -08:00

39 lines
1.3 KiB
JavaScript

Context = {
// The Option button
option: document.getElementById('option'),
init: function(winamp) {
this.winamp = winamp;
var self = this;
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++) {
skinSelectNodes[i].onclick = function() {
var skinFile = new MyFile();
skinFile.setUrl(this.dataset.skinUrl);
self.winamp.setSkin(skinFile);
}
}
document.getElementById('context-play-file').onclick = function(event) {
self.option.classList.remove('selected');
self.winamp.openFileDialog();
};
document.getElementById('context-load-skin').onclick = function(event) {
self.option.classList.remove('selected');
self.winamp.openFileDialog();
};
document.getElementById('context-exit').onclick = function() {
self.winamp.close();
};
}
}