mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-21 09:09:01 +00:00
Convert file manager to object literal
This commit is contained in:
parent
aa3eadc312
commit
5efcbe382d
3 changed files with 12 additions and 12 deletions
|
|
@ -1,18 +1,18 @@
|
|||
// Handle common file interactions
|
||||
function FileManager () {
|
||||
this.reader = new FileReader()
|
||||
FileManager = {
|
||||
reader: new FileReader(),
|
||||
|
||||
// Given an input node, returns a functional URL
|
||||
this.urlFromInput = function(input) {
|
||||
urlFromInput: function(input) {
|
||||
var file = input.files[0];
|
||||
return this.urlFromFileReference(file);
|
||||
}.bind(this)
|
||||
},
|
||||
|
||||
this.urlFromFileReference = function(fileReference) {
|
||||
urlFromFileReference: function(fileReference) {
|
||||
return URL.createObjectURL(fileReference);
|
||||
}
|
||||
},
|
||||
|
||||
this.bufferFromFileReference = function(fileReference, bufferHandler) {
|
||||
bufferFromFileReference: function(fileReference, bufferHandler) {
|
||||
this.reader.onload = function (e) {
|
||||
var arrayBuffer = e.target.result;
|
||||
bufferHandler(arrayBuffer);
|
||||
|
|
@ -22,9 +22,9 @@ function FileManager () {
|
|||
};
|
||||
|
||||
this.reader.readAsArrayBuffer(fileReference);
|
||||
}.bind(this)
|
||||
},
|
||||
|
||||
this.bufferFromUrl = function(url, bufferHandler) {
|
||||
bufferFromUrl: function(url, bufferHandler) {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open("GET", url, true);
|
||||
oReq.responseType = "arraybuffer";
|
||||
|
|
@ -35,5 +35,5 @@ function FileManager () {
|
|||
};
|
||||
|
||||
oReq.send(null);
|
||||
}.bind(this)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
skin.js
2
skin.js
|
|
@ -1,6 +1,6 @@
|
|||
// Dynamically set the css background images for all the sprites
|
||||
SkinManager = {
|
||||
fileManager: new FileManager(),
|
||||
fileManager: FileManager,
|
||||
|
||||
_skinImages: {
|
||||
"#winamp": "MAIN.BMP",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// UI and App logic
|
||||
function Winamp () {
|
||||
self = this;
|
||||
this.fileManager = new FileManager();
|
||||
this.fileManager = FileManager;
|
||||
this.media = Media.init('player');
|
||||
this.skinManager = SkinManager;
|
||||
this.font = Font;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue