--- a/src/js/data.js Wed Oct 12 14:00:14 2011 +0200
+++ b/src/js/data.js Thu Oct 13 17:08:20 2011 +0200
@@ -9,12 +9,15 @@
callback(this._cache[url]);
} else {
/* we need a closure because this gets lost when it's called back */
+ IriSP.jQuery.get(url, callback);
+ /*
IriSP.jQuery.get(url, (function(obj) {
return function(data) {
obj._cache[url] = data;
callback(obj._cache[url]);
};
})(this));
+ */
}
}
@@ -28,6 +31,14 @@
IriSP.Serializer.prototype.serialize = function(data) { };
IriSP.Serializer.prototype.deserialize = function(data) {};
+IriSP.Serializer.prototype.currentMedia = function() {
+ return {"meta" : {"dc:duration" : 10000000}}; /* dummy object for unit testing */
+};
+
+IriSP.Serializer.prototype.sync = function(callback) {
+ callback.apply(this, []);
+};
+
IriSP.JSONSerializer = function(DataLoader, url) {
IriSP.Serializer.call(this, DataLoader, url);
}
@@ -44,9 +55,11 @@
IriSP.JSONSerializer.prototype.sync = function(callback) {
/* we don't have to do much because jQuery handles json for us */
+
+ /* a wrapper to get a closure because we lose this in callbacks */
var wrapper = function(obj) {
return function(data) {
- obj._data = data;
+ obj._data = data;
callback(data);
}
};
@@ -54,6 +67,10 @@
this._DataLoader.get(this._url, wrapper(this));
};
+IriSP.JSONSerializer.prototype.currentMedia = function() {
+ return this._data.medias[0]; /* FIXME: don't hardcode it */
+};
+
IriSP.SerializerFactory = function(DataLoader) {
this._dataloader = DataLoader;
};