]> git.mxchange.org Git - friendica.git/commitdiff
live updates sort of working
authorMike Macgirvin <mike@macgirvin.com>
Sun, 25 Jul 2010 06:20:20 +0000 (23:20 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Sun, 25 Jul 2010 06:20:20 +0000 (23:20 -0700)
mod/network.php
mod/profile.php
mod/update_network.php
mod/update_profile.php
view/head.tpl
view/jot-header.tpl

index cbd1f445454b004858bb46705cab0290e5288da8..0807f95614c1239342582d613ad11406534b18e7 100644 (file)
@@ -119,9 +119,15 @@ function network_content(&$a, $update = false) {
                                }
                        }
 
+                       if($update)
+                               $return_url = $_SESSION['return_url'];
+                       else
+                               $return_url = $_SESSION['return_url'] = $a->cmd;
+
+
                        if($item['last-child']) {
                                $comment = replace_macros($cmnt_tpl,array(
-                                       '$return_path' => $a->cmd,
+                                       '$return_path' => $_SESSION['return_url'],
                                        '$id' => $item['item_id'],
                                        '$parent' => $item['parent'],
                                        '$profile_uid' =>  $_SESSION['uid'],
index aa13f0a78db462cac908a7a1d48a9374eec17bd8..0cfe2280725b144405c42e35b5363ac04e5cc94b 100644 (file)
@@ -212,13 +212,18 @@ function profile_content(&$a, $update = false) {
                        
                        $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
                        
-                       if(can_write_wall($a,$a->profile['profile_uid'])) {
+                       if($update)
+                               $return_url = $_SESSION['return_url'];
+                       else
+                               $return_url = $_SESSION['return_url'] = $a->cmd;
+
+                       if(can_write_wall($a,$a->profile['uid'])) {
                                if($item['last-child']) {
                                        $comment = replace_macros($cmnt_tpl,array(
-                                               '$return_path' => $a->cmd,
+                                               '$return_path' => $_SESSION['return_url'],
                                                '$id' => $item['item_id'],
                                                '$parent' => $item['parent'],
-                                               '$profile_uid' =>  $a->profile['profile_uid'],
+                                               '$profile_uid' =>  $a->profile['uid'],
                                                '$ww' => ''
                                        ));
                                }
index 655bebb965d38006c50f6e36a2f6dafa4456da1d..18c630fdf08f9fac91ed81df75fe91d5d3e583f5 100644 (file)
@@ -6,9 +6,12 @@ require_once('mod/network.php');
 
 function update_network_content(&$a) {
 
-       echo "<html>\r\n";
-       echo network_content($a,true);
-       echo "</html>\r\n";
+       header("Content-type: text/html");
+       echo "<!DOCTYPE html><html><body>\r\n";
+       echo (($_GET['msie'] == 1) ? '<div>' : '<section>');
+       echo str_replace("\t",'       ',network_content($a,true));
+       echo (($_GET['msie'] == 1) ? '</div>' : '</section>');
+       echo "</body></html>\r\n";
        killme();
 
 }
\ No newline at end of file
index a0cb10f5d3584483182ff652ef9d77ad621a20ea..367a5568d85636403d0bfe40069b03825178cf71 100644 (file)
@@ -6,9 +6,12 @@ require_once('mod/profile.php');
 
 function update_profile_content(&$a) {
 
-       echo "<html>\r\n";
-       echo profile_content($a,true);
-       echo "</html>\r\n";
+       header("Content-type: text/html");
+       echo "<!DOCTYPE html><html><body>\r\n";
+       echo (($_GET['msie'] == 1) ? '<div>' : '<section>');
+       echo str_replace("\t",'       ',profile_content($a,true));
+       echo (($_GET['msie'] == 1) ? '</div>' : '</section>');
+       echo "</body></html>\r\n";
        killme();
 
 }
\ No newline at end of file
index 6be3f7940aa9c7aae9373d2f44a8ff168e2bd703..d02f56c72777aaec8d19575745c6786c77c38261 100644 (file)
@@ -9,12 +9,24 @@
 <script type="text/javascript" src="$baseurl/include/main.js" ></script>
 
 <script type="text/javascript">
-       $(document).ready(function() { NavUpdate(); });
 
-function NavUpdate()
-       {
-               $.get("ping",function(data)
-                       {
+       var src = null;
+       var prev = null;
+       var livetime = null;
+       var msie = false;
+
+       $(document).ready(function() {
+               $.ajaxSetup({cache: false});
+               msie = $.browser.msie ;
+               NavUpdate(); 
+       });
+
+       function NavUpdate() {
+
+               if($('#live-network').length) { src = 'network'; liveUpdate(); }
+               if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
+
+               $.get("ping",function(data) {
                        $(data).find('result').each(function() {
                                var net = $(this).find('net').text();
                                if(net == 0) { net = ''; }
@@ -31,6 +43,29 @@ function NavUpdate()
                        });
                }) ;
                setTimeout(NavUpdate,30000);
+
        }
+
+       function liveUpdate() {
+               if(src == null) { return; }
+               if($('.comment-edit-text-full').length) {
+                       livetime = setTimeout(liveUpdate, 10000);
+                       return;
+               }
+               prev = 'live-' + src;
+
+               $.get('update_' + src + '?msie=' + ((msie) ? 1 : 0),function(data) {
+                       $('.wall-item-outside-wrapper',data).each(function() {
+                               var ident = $(this).attr('id');
+                               if($('#' + ident).length == 0) {
+                                       $('#' + prev).after($(this));
+                               }
+                               else { $('#' + ident).replaceWith($(this)); }
+                               prev = ident; 
+                       });
+               });
+
+       }
+
 </script>
 
index 78e0151d80696c68294b14e93198966fc204e973..3a1d0a2ae4f5e0db0920e9fb1882f0f92213bcb7 100644 (file)
@@ -1,3 +1,4 @@
+
 <script language="javascript" type="text/javascript"
           src="$baseurl/tinymce/jscripts/tiny_mce/tiny_mce_src.js"></script>
           <script language="javascript" type="text/javascript">
@@ -50,41 +51,6 @@ tinyMCE.init({
                }
        }
 
-       var src = null;
-
-       $(document).ready(function() {
-               if($('#live-network').length) { src = 'network';  setTimeout(liveUpdate, 30000); }
-               if($('#live-profile').length) { src = 'profile';  setTimeout(liveUpdate, 30000); }
-       });
-
-       function liveUpdate() {
-               if(src == null) { return; }
-               if($('.comment-edit-text-full').length) {
-                       setTimeout(liveUpdate, 30000);
-                       return;
-               }
-
-//             $.get('update_' + src,function(data)
-//                     {
-//                     $(data).find('#wall-item-outside-wrapper').each(function() {
-//                             var net = $(this).find('net').text();
-//                             if(net == 0) { net = ''; }
-//                             $('#net-update').html(net);
-//                             var home = $(this).find('home').text();
-//                             if(home == 0) { home = ''; }
-//                             $('#home-update').html(home);
-//                             var mail = $(this).find('mail').text();
-//                             if(mail == 0) { mail = ''; }
-//                             $('#mail-update').html(mail);
-//                             var intro = $(this).find('intro').text();
-//                             if(intro == 0) { intro = ''; }
-//                             $('#notify-update').html(intro);
-//                     });
-//             }) ;
-
-               setTimeout(liveUpdate,30000);
-       }
-