mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 09:37:17 +00:00
Line break after every CSS rule
This commit is contained in:
parent
8f78fd73c5
commit
3c0774fde3
5 changed files with 64 additions and 26 deletions
|
|
@ -2,12 +2,14 @@
|
|||
// `File` is already a builtin, so we use `MyFile`
|
||||
MyFile = function(){
|
||||
this.reader = new FileReader();
|
||||
this.name = '';
|
||||
this.url = null;
|
||||
this.fileReference = null;
|
||||
this.setUrl = function(url){
|
||||
this.url = url;
|
||||
};
|
||||
this.setFileReference = function(fileReference){
|
||||
this.name = fileReference.name;
|
||||
this.fileReference = fileReference;
|
||||
};
|
||||
this.processBuffer = function(bufferHandler) {
|
||||
|
|
|
|||
|
|
@ -390,9 +390,14 @@ MainWindow = {
|
|||
drop: function(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var dt = e.dataTransfer;
|
||||
var file = dt.files[0];
|
||||
this.winamp.loadFromFileReference(file);
|
||||
this.winamp.emptyPlaylist();
|
||||
var files = e.dataTransfer.files;
|
||||
for(var i = 0; i < files.length; i++) {
|
||||
var file = new MyFile();
|
||||
file.setFileReference(files[i]);
|
||||
this.winamp.enqueue(file);
|
||||
}
|
||||
this.winamp.play();
|
||||
},
|
||||
|
||||
_timeString: function(time) {
|
||||
|
|
|
|||
|
|
@ -156,6 +156,10 @@ Media = {
|
|||
this._position = 0;
|
||||
},
|
||||
|
||||
isEmpty: function() {
|
||||
return !!this._buffer;
|
||||
},
|
||||
|
||||
_silence: function() {
|
||||
if(this._source) {
|
||||
this._source.stop(0);
|
||||
|
|
|
|||
|
|
@ -68,9 +68,13 @@ PlaylistWindow = {
|
|||
tracks.removeChild(tracks.firstChild);
|
||||
}
|
||||
|
||||
for(i = 0; i < this.winamp.playlist.length; i++) {
|
||||
var self = this;
|
||||
for(var i = 0; i < this.winamp.playlist.length; i++) {
|
||||
var li = document.createElement('li');
|
||||
li.innerHTML = (i+1) + ". " + this.winamp.playlist[i].name;
|
||||
li.onclick = (function(trackNumber) {
|
||||
return function() { self.winamp.playTrack(trackNumber); };
|
||||
})(i);
|
||||
tracks.appendChild(li);
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +83,7 @@ PlaylistWindow = {
|
|||
|
||||
updateCurrentTrack: function() {
|
||||
var tracks = this.nodes.tracks.children;
|
||||
for(i = 0; i < tracks.length; i++) {
|
||||
for(var i = 0; i < tracks.length; i++) {
|
||||
if(i == this.winamp.currentTrack) {
|
||||
tracks[i].classList.add('current');
|
||||
} else {
|
||||
|
|
@ -101,9 +105,12 @@ PlaylistWindow = {
|
|||
drop: function(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var dt = e.dataTransfer;
|
||||
var file = dt.files[0];
|
||||
this.winamp.enqueueFromFileReference(file, 0);
|
||||
var files = e.dataTransfer.files;
|
||||
for(var i = 0; i < files.length; i++) {
|
||||
var file = new MyFile();
|
||||
file.setFileReference(files[i]);
|
||||
this.winamp.enqueue(file);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
56
js/winamp.js
56
js/winamp.js
|
|
@ -39,7 +39,7 @@ Winamp = {
|
|||
|
||||
this.setVolume(options.volume);
|
||||
this.setBalance(options.balance);
|
||||
this.loadFromUrl(options.mediaFile.url, options.mediaFile.name);
|
||||
this.enqueueFromUrl(options.mediaFile.url, options.mediaFile.name);
|
||||
var skinFile = new MyFile();
|
||||
skinFile.setUrl(options.skinUrl);
|
||||
this.setSkin(skinFile);
|
||||
|
|
@ -81,7 +81,14 @@ Winamp = {
|
|||
});
|
||||
|
||||
this.fileInput.onchange = function(e){
|
||||
self.loadFromFileReference(e.target.files[0]);
|
||||
self.emptyPlaylist();
|
||||
var files = e.dataTransfer.files;
|
||||
for(var i = 0; i < files.length; i++) {
|
||||
var file = new MyFile();
|
||||
file.setFileReference(files[i]);
|
||||
this.enqueue(file);
|
||||
}
|
||||
this.next();
|
||||
};
|
||||
},
|
||||
|
||||
|
|
@ -131,7 +138,7 @@ Winamp = {
|
|||
if(this.currentTrack > 0) {
|
||||
this.currentTrack = this.currentTrack - 1;
|
||||
window.dispatchEvent(this.events.currentTrackChanged);
|
||||
this.playFromFileReference(this.playlist[this.currentTrack]);
|
||||
this.playTrack(this.currentTrack);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -165,7 +172,7 @@ Winamp = {
|
|||
this.currentTrack = 0;
|
||||
}
|
||||
window.dispatchEvent(this.events.currentTrackChanged);
|
||||
this.playFromFileReference(this.playlist[this.currentTrack]);
|
||||
this.playTrack(this.currentTrack);
|
||||
},
|
||||
|
||||
// From 0-100
|
||||
|
|
@ -242,36 +249,49 @@ Winamp = {
|
|||
this.fileInput.click();
|
||||
},
|
||||
|
||||
loadFromFileReference: function(fileReference) {
|
||||
enqueueFromFileReference: function(fileReference) {
|
||||
var file = new MyFile();
|
||||
file.setFileReference(fileReference);
|
||||
if(new RegExp("(wsz|zip)$", 'i').test(fileReference.name)) {
|
||||
this.skin.setSkinByFile(file);
|
||||
} else {
|
||||
this.playlist = [];
|
||||
this.enqueueFromFileReference(fileReference);
|
||||
this.currentTrack = 0;
|
||||
this.playFromFileReference(this.playlist[0]);
|
||||
this.enqueue(file);
|
||||
}
|
||||
},
|
||||
|
||||
playFromFileReference: function(fileReference) {
|
||||
this.media.autoPlay = true;
|
||||
this.fileName = fileReference.name;
|
||||
this.fileManager.bufferFromFileReference(fileReference, this._loadBuffer.bind(this));
|
||||
loadFile: function(file) {
|
||||
this.fileName = file.name;
|
||||
file.processBuffer(this._loadBuffer.bind(this));
|
||||
},
|
||||
|
||||
enqueueFromFileReference: function(fileReference, position) {
|
||||
this.playlist.push(fileReference);
|
||||
playTrack: function(track) {
|
||||
this.currentTrack = track;
|
||||
window.dispatchEvent(this.events.currentTrackChanged);
|
||||
var file = this.playlist[this.currentTrack];
|
||||
this.media.autoPlay = true;
|
||||
this.loadFile(file);
|
||||
},
|
||||
|
||||
enqueue: function(file) {
|
||||
this.playlist.push(file);
|
||||
if(this.playlist.length === 1) {
|
||||
this.loadFile(file);
|
||||
}
|
||||
window.dispatchEvent(this.events.tracksUpdated);
|
||||
},
|
||||
|
||||
emptyPlaylist: function() {
|
||||
this.playlist = [];
|
||||
this.currentTrack = 0;
|
||||
window.dispatchEvent(this.events.tracksUpdated);
|
||||
},
|
||||
|
||||
// Used only for the initial load, since it must have a CORS header
|
||||
loadFromUrl: function(url, fileName) {
|
||||
this.fileName = fileName;
|
||||
enqueueFromUrl: function(url, fileName) {
|
||||
var file = new MyFile();
|
||||
file.setUrl(url);
|
||||
file.processBuffer(this._loadBuffer.bind(this));
|
||||
file.name = fileName;
|
||||
this.enqueue(file);
|
||||
},
|
||||
|
||||
setSkin: function(file) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue