From: <ar...@us...> - 2014-08-18 17:03:38
|
Revision: 52369 http://sourceforge.net/p/tikiwiki/code/52369 Author: arildb Date: 2014-08-18 17:03:35 +0000 (Mon, 18 Aug 2014) Log Message: ----------- [FIX] Make Live support system semi-workable again. Please check. A revamp should be done. Modified Paths: -------------- branches/13.x/lib/live_support/live-support.js branches/13.x/lib/live_support/lslib.php branches/13.x/templates/tiki-live_support_chat_window.tpl branches/13.x/templates/tiki-live_support_console.tpl branches/13.x/tiki-live_support_console.php branches/13.x/tiki-live_support_server.php Modified: branches/13.x/lib/live_support/live-support.js =================================================================== --- branches/13.x/lib/live_support/live-support.js 2014-08-18 16:35:18 UTC (rev 52368) +++ branches/13.x/lib/live_support/live-support.js 2014-08-18 17:03:35 UTC (rev 52369) @@ -56,21 +56,26 @@ } function event_poll() { - evpollInterval = setInterval("pollForEvents()", 10000); + evpollInterval = setInterval("pollForEvents()", 5000); } + function pollForEvents() { var ret = msg('tiki-live_support_server.php?get_last_event=' + document.getElementById('reqId').value + '&senderId=' + document.getElementById('senderId').value); + if (ret.length > 0) { + ret = parseInt(ret); + } else { + ret = 0; + } /* alert(ret); - alert(last_event); */ - var last_event; - if (ret > last_event) { - while (last_event < ret) { - last_event = last_event + 1; + alert(last_support_event); */ + if (ret > last_support_event) { + while (last_support_event < ret) { + last_support_event = last_support_event + 1; var txt = msg('tiki-live_support_server.php?get_event=' + document.getElementById('reqId').value - + '&last=' + last_event + '&senderId=' + document.getElementById('senderId').value); + + '&last=' + last_support_event + '&senderId=' + document.getElementById('senderId').value); if (txt) { window.chat_data.document.write(txt); @@ -117,12 +122,17 @@ /*** Operator console functions ***/ function pollForRequests() { - var last = msg('tiki-live_support_server.php?poll_requests=1'), last_req; + var last = msg('tiki-live_support_server.php?poll_requests=1'); + if (last.length > 0) { + last = parseInt(last); + } else { + last = 0; + } - if (last > last_req) { + if (last > last_support_req) { window.location.reload(); - last_req = last; + last_support_req = last; } } Modified: branches/13.x/lib/live_support/lslib.php =================================================================== --- branches/13.x/lib/live_support/lslib.php 2014-08-18 16:35:18 UTC (rev 52368) +++ branches/13.x/lib/live_support/lslib.php 2014-08-18 17:03:35 UTC (rev 52369) @@ -175,7 +175,7 @@ ); } - function get_event($reqId, $event, $senderId) + function get_support_event($reqId, $event, $senderId) { return $this->getOne( 'select `data` from `tiki_live_support_events` where `senderId`<>? and `reqId`=? and `seqId`=?', Modified: branches/13.x/templates/tiki-live_support_chat_window.tpl =================================================================== --- branches/13.x/templates/tiki-live_support_chat_window.tpl 2014-08-18 16:35:18 UTC (rev 52368) +++ branches/13.x/templates/tiki-live_support_chat_window.tpl 2014-08-18 17:03:35 UTC (rev 52369) @@ -92,7 +92,7 @@ {/literal} <script type='text/javascript'> /* Activate polling of requests */ - var last_event=0; + var last_support_event=0; event_poll(); </script> </body> Modified: branches/13.x/templates/tiki-live_support_console.tpl =================================================================== --- branches/13.x/templates/tiki-live_support_console.tpl 2014-08-18 16:35:18 UTC (rev 52368) +++ branches/13.x/templates/tiki-live_support_console.tpl 2014-08-18 17:03:35 UTC (rev 52369) @@ -71,7 +71,7 @@ <h3>{tr}No support requests{/tr}</h3> {/if} <script type='text/javascript'> - var last_req={$last}; + var last_support_req={$last}; console_poll(); </script> Modified: branches/13.x/tiki-live_support_console.php =================================================================== --- branches/13.x/tiki-live_support_console.php 2014-08-18 16:35:18 UTC (rev 52368) +++ branches/13.x/tiki-live_support_console.php 2014-08-18 17:03:35 UTC (rev 52369) @@ -26,13 +26,15 @@ $max_active_request = $lslib->get_max_active_request(); $smarty->assign('new_requests', 'n'); -if (!isset($_SESSION['max_request'])) { - $_SESSION['max_request'] = $max_active_request; - $smarty->assign('new_requests', 'y'); -} else { - if ($max_active_request > $_SESSION['max_request']) { +if (isset($max_active_request)) { + if (!isset($_SESSION['max_request'])) { $_SESSION['max_request'] = $max_active_request; $smarty->assign('new_requests', 'y'); + } else { + if ($max_active_request != $_SESSION['max_request']) { + $_SESSION['max_request'] = $max_active_request; + $smarty->assign('new_requests', 'y'); + } } } $requests = $lslib->get_requests('active'); Modified: branches/13.x/tiki-live_support_server.php =================================================================== --- branches/13.x/tiki-live_support_server.php 2014-08-18 16:35:18 UTC (rev 52368) +++ branches/13.x/tiki-live_support_server.php 2014-08-18 17:03:35 UTC (rev 52369) @@ -75,7 +75,7 @@ } if (isset($_REQUEST['get_event'])) { header("Content-type: text/plain"); - echo $lslib->get_event($_REQUEST['get_event'], $_REQUEST['last'], $_REQUEST['senderId']); + echo $lslib->get_support_event($_REQUEST['get_event'], $_REQUEST['last'], $_REQUEST['senderId']); } // A client closes its window if (isset($_REQUEST['client_close'])) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |