Index: /trunk/FACT++/scripts/Observation_class.js
===================================================================
--- /trunk/FACT++/scripts/Observation_class.js	(revision 15083)
+++ /trunk/FACT++/scripts/Observation_class.js	(revision 15084)
@@ -14,4 +14,6 @@
         throw new Error("Observation object must have a 'date' parameter");
 
+    var ret = [];
+
     // FIXME: Check transisiton from summer- and winter-time!!
     var utc = new Date(obj.date);
@@ -19,47 +21,69 @@
         throw new Error(obj.date+' is not a valid Date String.'+
                         ' Try something like "2013-01-08 23:05 UTC" .');
+    ret.start = utc;
 
-    this.start  = utc;
-    this.task   = obj.task ? obj.task.toUpperCase() : "DATA";
-    this.source = obj.source;
-    this.ra     = obj.ra;
-    this.dec    = obj.dec;
+    // If the given data is not an array, make it the first entry of an array
+    // so that we can simply loop over all entries
+    if (obj.measurements.length===undefined)
+    {
+        var cpy = obj.measurements;
+        obj.measurements = [];
+        obj.measurements[0] = cpy;
+    }
+
+    for (var i=0; i<obj.measurements.length; i++)
+    {
+        var obs = obj.measurements[i];
+
+        ret[i] = { };
+        ret[i].task   = obs.task ? obs.task.toUpperCase() : "DATA";
+        ret[i].source = obs.source;
+        ret[i].ra     = obs.ra;
+        ret[i].dec    = obs.dec;
+        ret[i].sub    = i;
+        ret[i].start  = utc;
+
+        ret[i].toString = function()
+        {
+            var rc = this.task;
+            rc += "["+this.sub+"]";
+            if (this.source)
+                rc += ": " + this.source;
+            //rc += " ["+this.start.toUTCString()+"]";
+            return rc;
+        }
     
-    switch (this.task)
-    {
-    case 'DATA':
-        if (this.source == undefined)
-            throw new Error("Observation must have either 'source' or 'task' " +
-                            "if 'task' == 'data' it must have also have 'source' ");
-        break;
+        switch (ret[i].task)
+        {
+        case 'DATA':
+            if (i!=obj.measurements.length-1)
+                throw new Error("DATA must be the last in the list of measurements");
+            if (ret[i].source == undefined)
+                throw new Error("Observation must have either 'source' or 'task' " +
+                                "if 'task' == 'data' it must have also have 'source' ");
+            break;
 
-    case 'STARTUP':
-        if (this.source != undefined)
-            console.out("warning. Observation with task='startup' also has source defined");
-        break;
+        case 'STARTUP':
+            if (ret[i].source != undefined)
+                console.out("warning. Observation with task='startup' also has source defined");
+            break;
 
-    case 'SHUTDOWN':
-        if (this.source != undefined)
-            console.out("warning. Observation with task='shutdown' also has source defined");
-        break;
+        case 'SHUTDOWN':
+            if (ret[i].source != undefined)
+                console.out("warning. Observation with task='shutdown' also has source defined");
+            break;
 
-    case 'RATESCAN':
-        if (this.source == undefined && (this.ra == undefined || this.dec == undefined))
-            throw new Error("Observation must have either 'source' or 'ra' & 'dec' " +
-                            "if 'task' == 'ratescan'");
-        break;
+        case 'RATESCAN':
+            if (ret[i].source == undefined && (ret[i].ra == undefined || ret[i].dec == undefined))
+                throw new Error("Observation must have either 'source' or 'ra' & 'dec' " +
+                                "if 'task' == 'ratescan'");
+            break;
 
-    default:
-        throw new Error(" the task of this observation:"+this.task+
-                        "is not implemented. use one of: DATA, STARTUP, SHUTDOWN, RATESCAN.");
+        default:
+            throw new Error(" the task of this observation:"+this.task+
+                            "is not implemented. use one of: DATA, STARTUP, SHUTDOWN, RATESCAN.");
+        }
     }
+
+    return ret;
 }
-
-// method toString()
-Observation.prototype.toString = function() 
-{
-    if (this.source)
-        return this.task + "  " + this.source+" ["+this.start+"]" ;
-    else
-        return this.task + " ["+this.start+"]" ;
-}
