diff showajax.php @ 144:c030c3cf0d80

More work on display system.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 23 Oct 2013 01:42:21 +0300
parents 20893a5442b7
children 66b485431cac
line wrap: on
line diff
--- a/showajax.php	Wed Oct 23 01:21:12 2013 +0300
+++ b/showajax.php	Wed Oct 23 01:42:21 2013 +0300
@@ -136,57 +136,67 @@
     break;
 }
 
+$type = stGetRequestItem("type");
 
-$action = stChkRequestItem("action") ? $_REQUEST["action"] : "";
-switch ($action)
+switch (stGetRequestItem("action"))
 {
   case "check":
     // Check if there has been any change
     $changed =
       stGetRequestItem("activeSlide") != stGetDisplayVar("activeSlide") ||
-      stGetRequestItem("activeSlide") != stGetDisplayVar("activeSlide");
+      stGetRequestItem("activeSlideMode") != stGetDisplayVar("activeSlideMode");
       
     echo $changed ? "changed" : "nochange";
     stSetStatus(200, "OK");
     break;
 
   case "get":
-    // Based on the currently active mode ...
-    switch (stGetDisplayVar("activeSlideMode"))
+    switch ($type)
     {
-      case SMODE_ROTATE:
-        // Slide rotation mode, display currently active slide
-        if (stGetDisplayVar("activeSlide") > 0)
-        {
-          $sql = stPrepareSQL("SELECT * FROM displaySlides WHERE id=%d",
-            stGetDisplayVar("activeSlide"));
-
-          if (($slide = stFetchSQL($sql)) !== false)
-            stPrintRotationSlide($slide);
-        }
-        else
-        {
-          echo "<div>ERROR!</div>\n";
-        }
+      case "activeSlideMode":
+      case "activeSlide":
+        echo stGetDisplayVar($type);
         break;
-      
-      case SMODE_COMPO:
-        // Competition mode
-        $compo = stFetchSQL(stPrepareSQL(
-          "SELECT * FROM compos WHERE id=%d",
-          stGetDisplayVar("compoCompo")));
+
+      case "slide":
+      // Based on the currently active mode ...
+      switch (stGetDisplayVar("activeSlideMode"))
+      {
+        case SMODE_ROTATE:
+          // Slide rotation mode, display currently active slide
+          if (stGetDisplayVar("activeSlide") > 0)
+          {
+            $sql = stPrepareSQL("SELECT * FROM displaySlides WHERE id=%d",
+              stGetDisplayVar("activeSlide"));
 
-        $prev = stFetchSQL(stPrepareSQL(
-          "SELECT * FROM entries WHERE id=%d",
-          stGetDisplayVar("compoPrevEntry")));
+            if (($slide = stFetchSQL($sql)) !== false)
+              stPrintRotationSlide($slide);
+          }
+          else
+          {
+            echo "<div>ERROR!</div>\n";
+          }
+          break;
+        
+        case SMODE_COMPO:
+          // Competition mode
+          $compo = stFetchSQL(stPrepareSQL(
+            "SELECT * FROM compos WHERE id=%d",
+            stGetDisplayVar("compoCompo")));
 
-        $entry = stFetchSQL(stPrepareSQL(
-          "SELECT * FROM entries WHERE id=%d",
-          stGetDisplayVar("compoCurrEntry")));
+          $prev = stFetchSQL(stPrepareSQL(
+            "SELECT * FROM entries WHERE id=%d",
+            stGetDisplayVar("compoPrevEntry")));
 
-        if ($compo !== false)
-          stPrintCompoSlide($compo, $entry, $prev);
-        break;
+          $entry = stFetchSQL(stPrepareSQL(
+            "SELECT * FROM entries WHERE id=%d",
+            stGetDisplayVar("compoCurrEntry")));
+
+          if ($compo !== false)
+            stPrintCompoSlide($compo, $entry, $prev);
+          break;
+      }
+      break;
     }
     break;