Permalink
Browse files

Make it easier to add other RemoteResource types

  • Loading branch information...
1 parent 06cf7b6 commit 458a2fec58b322d24779bc21785c2c466aa949dd @ryanwilliams committed Apr 25, 2012
Showing with 16 additions and 10 deletions.
  1. +16 −10 src/remote_resources.js
View
@@ -105,6 +105,21 @@ remote_resources.RemoteScript.prototype.load = function () {
return script
}
+remote_resources.getRemoteResourceConstructor = function (mime) {
+ mime = mime.split('/')
+
+ var RemoteObj
+ if (mime[0] == 'image') {
+ RemoteObj = RemoteImage
+ } else if(mime[1] == 'javascript') {
+ RemoteObj = RemoteScript
+ } else {
+ RemoteObj = RemoteResource
+ }
+
+ return RemoteObj
+}
+
remote_resources.getRemoteResource = function (resourcePath) {
var resource = __jah__.resources[resourcePath]
@@ -116,16 +131,7 @@ remote_resources.getRemoteResource = function (resourcePath) {
return resource.remoteResource
}
- var RemoteObj
- , mime = resource.mimetype.split('/')
-
- if (mime[0] == 'image') {
- RemoteObj = RemoteImage
- } else if(mime[1] == 'javascript') {
- RemoteObj = RemoteScript
- } else {
- RemoteObj = RemoteResource
- }
+ var RemoteObj = remote_resources.getRemoteResourceConstructor(resource.mimetype)
resource.remoteResource = new RemoteObj(resource.data, resourcePath)

0 comments on commit 458a2fe

Please sign in to comment.