Index: /trunk/FACT++/www/viewer/index.php
===================================================================
--- /trunk/FACT++/www/viewer/index.php	(revision 17773)
+++ /trunk/FACT++/www/viewer/index.php	(revision 17774)
@@ -3,4 +3,9 @@
 if (!extension_loaded('v8js'))
     die("V8Js missing");
+
+$path = array(
+              "cal" => "/daq/caltest/",
+              "raw" => "/daq/raw/"
+              );
 
 if (isset($_POST['editor1']) || isset($_POST['editor2']))
@@ -90,5 +95,5 @@
     */
 
-    function getList($path, $sub)
+    function getList($path, $sub, $check)
     {
         $hasdir = false;
@@ -103,5 +108,5 @@
 
            if ($file->isDir())
-               $list = array_merge($list, getList($path, $sub."/".$name));
+               $list = array_merge($list, getList($path, $sub."/".$name, $check));
 
            if ($file->isFile() && $file->isReadable())
@@ -112,5 +117,5 @@
                $rc = substr($name, 0, 4)."/".substr($name, 4, 2)."/".substr($name, 6, 2)."-".substr($name, 9, 3);
 
-               array_push($list, $rc);
+               $list[$rc] = array_key_exists($rc, $check);
            }
         }
@@ -121,6 +126,7 @@
     try
     {
-        $list = getList("/daq/raw", "");
-        sort($list);
+        $cal = getList($path['cal'], "", array());
+        $raw = getList($path['raw'], "", $cal);
+        ksort($raw);
     }
     catch (Exception $e)
@@ -129,5 +135,5 @@
     }
 
-    print(json_encode($list));
+    print(json_encode($raw));
     return;
 }
@@ -172,5 +178,7 @@
 $r = substr($file, 11, 3);
 
-$filename = "/daq/raw/".$y."/".$m."/".$d."/".$y.$m.$d."_".$r.".fits.fz";
+$rootpath = isset($_POST['calibrated']) ? $path['cal'] : $path['raw'];
+
+$filename = $rootpath.$y."/".$m."/".$d."/".$y.$m.$d."_".$r.".fits.fz";
 
 if (!file_exists($filename))
@@ -189,8 +197,9 @@
 $fil['drsFile']       = get($file, "s");
 $fil['numEvents']     = get($file, "L");
+$fil['scale']         = get($file, "s");
 $evt['numRoi']        = get($file, "L");
 $evt['numPix']        = get($file, "L");
 $evt['eventNumber']   = get($file, "L");
-$evt['triggerNumber'] = get($file, "L");
+//$evt['triggerNumber'] = get($file, "L");
 $evt['triggerType']   = get($file, "S");
 $evt['unixTime']      = get($file, "L", 2);
@@ -305,11 +314,12 @@
     $v8->neighbors = $neighbors;
     $v8->clone     = function($data) { return $data; };
+    $v8->scale     = $fil['scale']==0 ? 2000./4096. : 1./$fil['scale'];
     $v8->unpack    = function($i)
     {
-        global $binary, $roi;
+        global $binary, $roi, $v8;
         $u = unpack("s".$roi, $binary[$i]);
         $arr = array();
         for ($i=0; $i<$roi; $i++)
-            $arr[$i] = $u[$i+1]*0.48828125;
+            $arr[$i] = $u[$i+1]*$v8->scale;
         return $arr;
     };
