Mercurial > hg > fapweb
changeset 145:66b485431cac
Change how slides are updated.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 23 Oct 2013 02:01:07 +0300 |
parents | c030c3cf0d80 |
children | 672c7f28fb97 |
files | createdb.php show.php showajax.php |
diffstat | 3 files changed, 26 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/createdb.php Wed Oct 23 01:42:21 2013 +0300 +++ b/createdb.php Wed Oct 23 02:01:07 2013 +0300 @@ -155,6 +155,7 @@ $siteDisplayVars = array( "tempDuration" => array(VT_INT, 120, "Temporary slide display time (seconds)"), "tempSlide" => array(VT_INT, 0, "Temporary slide ID"), + "tempSlideSet" => array(VT_BOOL, false, "Temporary slide set"), "showMode" => array(VT_INT, 0, "Currently active display mode"), @@ -165,6 +166,8 @@ "rotateDuration" => array(VT_INT, 15, "Slide rotation time per slide (seconds)"), "rotateList" => array(VT_INT, 0, "Current rotation list ID"), "rotateListIndex" => array(VT_INT, 0, "Current index in rotation list"), + + "lastUpdate" => array(VT_INT, 0, "Timestamp of last slide update"), ); $siteTestData = array(
--- a/show.php Wed Oct 23 01:42:21 2013 +0300 +++ b/show.php Wed Oct 23 02:01:07 2013 +0300 @@ -36,8 +36,7 @@ <script type="text/javascript"> var failCount = 0; -var prevView = -1, activeView = 0; -var activeSlide = -1, activeSlideMode = -1; +var prevView = -1, activeView = 0, lastUpdate = 0; var errorView = false; @@ -78,25 +77,19 @@ // function viewChanged() { - var msuccess3 = function(txt) + var msuccess2 = function(txt) { // Successfully fetched new data, initiate view update updateView(txt); } - var msuccess2 = function(txt) + var msuccess1 = function(txt) { - activeSlide = txt; - sendPOSTRequest("action=get&type=slide", msuccess3, displayError); + lastUpdate = txt; + sendPOSTRequest("action=get&type=slide", msuccess2, displayError); } - var msuccess1 = function(txt) - { - activeSlideMode = txt; - sendPOSTRequest("action=get&type=activeSlide", msuccess2, displayError); - } - - sendPOSTRequest("action=get&type=activeSlideMode", msuccess1, displayError); + sendPOSTRequest("action=get&type=update", msuccess1, displayError); } @@ -141,7 +134,7 @@ } } - sendPOSTRequest("action=check&activeSlide="+activeSlide+"&activeSlideMode="+activeSlideMode, msuccess, mfail); + sendPOSTRequest("action=check&lastUpdate="+lastUpdate, msuccess, mfail); } setTimeout("tickMain();", 1000);
--- a/showajax.php Wed Oct 23 01:42:21 2013 +0300 +++ b/showajax.php Wed Oct 23 02:01:07 2013 +0300 @@ -70,17 +70,22 @@ // // Check if the slide needs updating? // -if (stGetDisplayVar("tempDuration") > 0 && stGetDisplayVar("tempSlide") > 0) +$updated = FALSE; + +if (stGetDisplayVar("tempDuration") > 0 && + stGetDisplayVar("tempSlide") > 0 && + stGetDisplayVar("tempSlideSet")) { $sql = stPrepareSQL("SELECT * FROM displaySlides WHERE id=%d", stGetDisplayVar("tempSlide")); if (($res = stFetchSQL($sql)) !== false) { - stSetDisplayVar("tempDuration", 0); + stSetDisplayVar("tempSlideSet", FALSE); stSetDisplayVar("activeSlideMode", SMODE_ROTATE); stSetDisplayVar("activeSlide", stGetDisplayVar("tempSlide")); stSetDisplayVar("activeSlideExpire", time() + stGetDisplayVar("tempDuration")); + $updated = TRUE; } } else @@ -94,6 +99,7 @@ { stSetDisplayVar("rotateList", 1); stSetDisplayVar("activeSlideExpire", 0); + $updated = TRUE; } if (time() >= stGetDisplayVar("activeSlideExpire") && @@ -120,6 +126,7 @@ { stSetDisplayVar("activeSlide", $slide_id); stSetDisplayVar("activeSlideExpire", time() + stGetDisplayVar("rotateDuration")); + $updated = TRUE; } } @@ -136,16 +143,16 @@ break; } +if ($updated) + stSetDisplayVar("lastUpdate", time()); + + $type = stGetRequestItem("type"); - switch (stGetRequestItem("action")) { case "check": // Check if there has been any change - $changed = - stGetRequestItem("activeSlide") != stGetDisplayVar("activeSlide") || - stGetRequestItem("activeSlideMode") != stGetDisplayVar("activeSlideMode"); - + $changed = stGetRequestItem("lastUpdate") != stGetDisplayVar("lastUpdate"); echo $changed ? "changed" : "nochange"; stSetStatus(200, "OK"); break; @@ -153,9 +160,8 @@ case "get": switch ($type) { - case "activeSlideMode": - case "activeSlide": - echo stGetDisplayVar($type); + case "update": + echo stGetDisplayVar("lastUpdate"); break; case "slide":