]> git.mxchange.org Git - friendica.git/blob - view/head.tpl
live updates sort of working
[friendica.git] / view / head.tpl
1 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
2 <base href="$baseurl" />
3 <link rel="stylesheet" type="text/css" href="$baseurl/view/style.css" media="all" />
4
5 <!--[if IE]>
6 <script type="text/javascript" src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
7 <![endif]-->
8 <script type="text/javascript" src="$baseurl/include/jquery.js" ></script>
9 <script type="text/javascript" src="$baseurl/include/main.js" ></script>
10
11 <script type="text/javascript">
12
13         var src = null;
14         var prev = null;
15         var livetime = null;
16         var msie = false;
17
18         $(document).ready(function() {
19                 $.ajaxSetup({cache: false});
20                 msie = $.browser.msie ;
21                 NavUpdate(); 
22         });
23
24         function NavUpdate() {
25
26                 if($('#live-network').length) { src = 'network'; liveUpdate(); }
27                 if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
28
29                 $.get("ping",function(data) {
30                         $(data).find('result').each(function() {
31                                 var net = $(this).find('net').text();
32                                 if(net == 0) { net = ''; }
33                                 $('#net-update').html(net);
34                                 var home = $(this).find('home').text();
35                                 if(home == 0) { home = ''; }
36                                 $('#home-update').html(home);
37                                 var mail = $(this).find('mail').text();
38                                 if(mail == 0) { mail = ''; }
39                                 $('#mail-update').html(mail);
40                                 var intro = $(this).find('intro').text();
41                                 if(intro == 0) { intro = ''; }
42                                 $('#notify-update').html(intro);
43                         });
44                 }) ;
45                 setTimeout(NavUpdate,30000);
46
47         }
48
49         function liveUpdate() {
50                 if(src == null) { return; }
51                 if($('.comment-edit-text-full').length) {
52                         livetime = setTimeout(liveUpdate, 10000);
53                         return;
54                 }
55                 prev = 'live-' + src;
56
57                 $.get('update_' + src + '?msie=' + ((msie) ? 1 : 0),function(data) {
58                         $('.wall-item-outside-wrapper',data).each(function() {
59                                 var ident = $(this).attr('id');
60                                 if($('#' + ident).length == 0) {
61                                         $('#' + prev).after($(this));
62                                 }
63                                 else { $('#' + ident).replaceWith($(this)); }
64                                 prev = ident; 
65                         });
66                 });
67
68         }
69
70 </script>
71