viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]

Attempt to get groupfeed to update more smoothly, a=chris

Chris Pollett [2019-11-28 06:Nov:th]
Attempt to get groupfeed to update more smoothly, a=chris
Filename
src/scripts/basic.js
src/views/elements/GroupfeedElement.php
diff --git a/src/scripts/basic.js b/src/scripts/basic.js
index 47a03b02c..b32866b6a 100755
--- a/src/scripts/basic.js
+++ b/src/scripts/basic.js
@@ -76,15 +76,18 @@ function makeRequest()
  *
  * @param Object tag  a DOM element to put the results of the AJAX request
  * @param String url  web page to fetch using AJAX
- * @param Function callback function to call on sucecss
+ * @param Function success_callback function to call on success
+ * @param Function fail_callback function to call on failure
  */
 function getPage(tag, url)
 {
     var request = makeRequest();
     if (request) {
         var self = this;
-        var callback = (typeof arguments[2] == 'undefined') ?
+        var success_callback = (typeof arguments[2] == 'undefined') ?
             null : arguments[2];
+        var fail_callback = (typeof arguments[3] == 'undefined') ?
+            null : arguments[3];
         request.onreadystatechange = function()
         {
             if (self.request.readyState == 4) {
@@ -92,12 +95,13 @@ function getPage(tag, url)
                     if (tag != null) {
                         tag.innerHTML = self.request.responseText;
                     }
-                    if (callback) {
-                        callback(self.request.responseText);
+                    if (success_callback) {
+                        success_callback(self.request.responseText);
                     }
-                    return true;
                 } else {
-                    return false;
+                    if (fail_callback) {
+                        fail_callback(self.request.responseText);
+                    }
                 }
             }
         }
diff --git a/src/views/elements/GroupfeedElement.php b/src/views/elements/GroupfeedElement.php
index 4ba39ee4a..785e5e080 100644
--- a/src/views/elements/GroupfeedElement.php
+++ b/src/views/elements/GroupfeedElement.php
@@ -60,15 +60,14 @@ class GroupfeedElement extends Element implements CrawlConstants
         $paging_query = $data['PAGING_QUERY'] . $token_string;
         if (!$is_status) {
             ?>
-            <div id="feedstatus" <?php
-                e(' class="small-margin-current-activity" ');
-            ?> >
+            <div id="feedstatus" class="small-margin-current-activity" >
+            <span id="feedtime" data-time="<?=time() ?>" class='none'></span>
             <?php
             if ($logged_in) {
                 if (isset($data['SUBSCRIBE_LINK'])) {
                     ?><div class="float-same group-request-add"><?php
                     if ($data['SUBSCRIBE_LINK'] == C\PUBLIC_JOIN) {
-                        e('[<a href="'.$paging_query.'&amp;arg=addgroup">'.
+                        e('[<a href="' . $paging_query . '&amp;arg=addgroup">'.
                         tl('groupfeed_element_add_group').
                         '</a>]');
                     } else if ($data['SUBSCRIBE_LINK'] != C\NO_JOIN) {
@@ -742,10 +741,12 @@ class GroupfeedElement extends Element implements CrawlConstants
         {
             var start_url = "<?=html_entity_decode($paging_query) .
                 $delim . $token_string . '&arg=status&feed_time=' ?>";
-            getPage(elt('feedstatus'), start_url + feed_time);
-            feed_time += feed_update_time;
-            elt('feedstatus').style.backgroundColor = "#EEE";
-            setTimeout("resetBackground()", 0.5 * sec);
+            var feed_time_obj = elt('feedtime');
+            var feed_time = parseInt(feed_time_obj.getAttribute('data-time'));
+            getPage(elt('feedstatus'), start_url + feed_time, function(x) {
+                elt('feedstatus').style.backgroundColor = "#EEE";
+                setTimeout("resetBackground()", 0.5 * sec);
+            });
         }
        function clearUpdate()
         {
@@ -761,7 +762,6 @@ class GroupfeedElement extends Element implements CrawlConstants
         {
             var sec = 1000;
             var minute = 60 * sec;
-            feed_time = <?= time(); ?>;
             feed_update_time = 15;
             feed_update_id = setInterval("feedStatusUpdate()",
                 feed_update_time * sec);
ViewGit