changeset 132:0436079bcf46

Some preliminary work on the compo system.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 22 Oct 2013 19:02:30 +0300
parents ed05cc69e1c2
children cf53c6c7b797
files show.php
diffstat 1 files changed, 69 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/show.php	Tue Oct 22 19:01:52 2013 +0300
+++ b/show.php	Tue Oct 22 19:02:30 2013 +0300
@@ -22,8 +22,6 @@
 
 <!-- ========================== -->
 
-<div id="contents">
-
 <noscript>
   <div class="notice">
     <h1>Javascript required</h1>
@@ -35,23 +33,85 @@
   </div>
 </noscript>
 
-<div class="showView" id="view1"></div>
-<div class="showView" id="view2"></div>
-<div class="showView" id="view3"></div>
+<div class="showView" id="mainView0">
+  <div class="showHeader">
+    <img src="img/fapsm.png" />
+  </div>
+  <div class="showText">
+    <h1>Next up</h1>
+    <h2>4k intro competition</h2>
+  </div>
+</div>
 
+<div class="showView" id="mainView1">
 </div>
 
 <!-- ========================== -->
 
 <script type="text/javascript">
 
-function tick()
+var failCount = 0;
+var prevView = -1, activeView = 0;
+var errorView = false;
+
+
+function tickAnim()
 {
-  var nitem = document.getElementById("view1");
-  nitem.innerHTML = "<div class=\"notice\">Hello!</div>";
+  if (activeView != prevView)
+  {
+    document.getElementById("mainView0").style.display = (activeView == 0) ? "block" : "none";
+    document.getElementById("mainView1").style.display = (activeView == 1) ? "block" : "none";
+    prevView = activeView;
+  }
+}
+
+
+function displayError()
+{
+  // Increase failure count
+  if (++failCount > 5 && !errorView)
+  {
+    errorView = true;
+    updateView("... error ...");
+  }
 }
 
-//setTimeout("tick();", 100);
+
+//
+// Update view when triggered by main tick
+//
+function viewChanged()
+{
+  var msuccess = function(txt)
+  {
+    // Successfully fetched new data, initiate view update
+    failCount = 0;
+    errorView = false;
+    updateView(txt);
+  }
+
+  sendPOSTRequest("mode=get", msuccess, displayError);
+}
+
+
+//
+// Main tick function, check for updates from server
+//
+function tickMain()
+{
+  var msuccess = function(txt)
+  {
+    failCount = 0;
+    if (txt == "changed")
+      viewChanged();
+  }
+
+  sendPOSTRequest("mode=check", msuccess, displayError);
+}
+
+
+setTimeout("tickMain();", 500);
+setTimeout("tickAnim();", 20);
 
 </script>
 <?