diff options
author | Mike Macgirvin <mike@macgirvin.com> | 2010-07-24 23:20:20 -0700 |
---|---|---|
committer | Mike Macgirvin <mike@macgirvin.com> | 2010-07-24 23:20:20 -0700 |
commit | fc8379b1080823bb69664aa4119ba190e1f5b1ca (patch) | |
tree | 80179ca329106a59247a54106e34716eee19dfff /view/head.tpl | |
parent | 6368bd165612dfa1e95e8d4c99b922797bf429af (diff) | |
download | volse-hubzilla-fc8379b1080823bb69664aa4119ba190e1f5b1ca.tar.gz volse-hubzilla-fc8379b1080823bb69664aa4119ba190e1f5b1ca.tar.bz2 volse-hubzilla-fc8379b1080823bb69664aa4119ba190e1f5b1ca.zip |
live updates sort of working
Diffstat (limited to 'view/head.tpl')
-rw-r--r-- | view/head.tpl | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/view/head.tpl b/view/head.tpl index 6be3f7940..d02f56c72 100644 --- a/view/head.tpl +++ b/view/head.tpl @@ -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> |