From 5efcbe382d7ce33400fb55078ca2896aecd78ab2 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sun, 16 Nov 2014 18:18:53 -0800 Subject: [PATCH] Convert file manager to object literal --- file-manager.js | 20 ++++++++++---------- skin.js | 2 +- winamp.js | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/file-manager.js b/file-manager.js index 09ec264c..43ef5a62 100644 --- a/file-manager.js +++ b/file-manager.js @@ -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) + } } diff --git a/skin.js b/skin.js index 9fb7eaf7..f3b0754a 100644 --- a/skin.js +++ b/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", diff --git a/winamp.js b/winamp.js index e8702a33..2ecd2924 100755 --- a/winamp.js +++ b/winamp.js @@ -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;