more live update

This commit is contained in:
Mike Macgirvin 2010-07-24 15:21:33 -07:00
parent d6dbcf8581
commit 6368bd1656
6 changed files with 105 additions and 55 deletions

View file

@ -6,7 +6,7 @@ function network_init(&$a) {
}
function network_content(&$a) {
function network_content(&$a, $update = false) {
if(! local_user())
return;
@ -15,10 +15,8 @@ function network_content(&$a) {
$contact_id = $a->cid;
$r = q("UPDATE `item` SET `unseen` = 0
WHERE `unseen` = 1 AND `uid` = %d",
intval($_SESSION['uid'])
);
if(! $update) {
$tpl = file_get_contents('view/jot-header.tpl');
@ -40,6 +38,13 @@ function network_content(&$a) {
$o .= '<div id="live-network"></div>' . "\r\n";
}
$r = q("UPDATE `item` SET `unseen` = 0
WHERE `unseen` = 1 AND `uid` = %d",
intval($_SESSION['uid'])
);
$sql_extra = '';
@ -164,6 +169,9 @@ function network_content(&$a) {
));
}
}
if(! $update)
$o .= paginate($a);
return $o;
}

View file

@ -67,7 +67,7 @@ function profile_init(&$a) {
}
function profile_content(&$a) {
function profile_content(&$a, $update = false) {
require_once("include/bbcode.php");
require_once('include/security.php');
@ -76,14 +76,7 @@ function profile_content(&$a) {
$tab = 'posts';
if(x($_GET,'tab'))
$tab = notags(trim($_GET['tab']));
$tpl = file_get_contents('view/profile_tabs.tpl');
$o .= replace_macros($tpl,array(
'$url' => $a->get_baseurl() . '/' . $a->cmd
));
if(remote_user()) {
@ -94,6 +87,23 @@ function profile_content(&$a) {
$contact_id = $_SESSION['cid'];
}
if($update) {
if(! local_user())
return '';
$a->profile['uid'] = $_SESSION['uid'];
}
else {
if(x($_GET,'tab'))
$tab = notags(trim($_GET['tab']));
$tpl = file_get_contents('view/profile_tabs.tpl');
$o .= replace_macros($tpl,array(
'$url' => $a->get_baseurl() . '/' . $a->cmd
));
if($tab == 'profile') {
require_once('view/profile_advanced.php');
return $o;
@ -119,7 +129,7 @@ function profile_content(&$a) {
if($tab == 'posts' && (! $a->pager['start']))
$o .= '<div id="live-profile"></div>' . "\r\n";
}
// TODO alter registration and settings and profile to update contact table when names and photos change.
@ -129,7 +139,7 @@ function profile_content(&$a) {
// Profile owner - everything is visible
if(local_user() && ($_SESSION['uid'] == $a->profile['profile_uid'])) {
if(local_user() && ($_SESSION['uid'] == $a->profile['uid'])) {
$sql_extra = '';
// Oh - while we're here... reset the Unseen messages
@ -250,6 +260,10 @@ function profile_content(&$a) {
}
}
if($update) {
return $o;
}
$o .= paginate($a);
return $o;

14
mod/update_network.php Normal file
View file

@ -0,0 +1,14 @@
<?php
require_once('mod/network.php');
function update_network_content(&$a) {
echo "<html>\r\n";
echo network_content($a,true);
echo "</html>\r\n";
killme();
}

14
mod/update_profile.php Normal file
View file

@ -0,0 +1,14 @@
<?php
require_once('mod/profile.php');
function update_profile_content(&$a) {
echo "<html>\r\n";
echo profile_content($a,true);
echo "</html>\r\n";
killme();
}

View file

@ -53,8 +53,8 @@ tinyMCE.init({
var src = null;
$(document).ready(function() {
if($('#live-network').length) { src = 'net'; setTimeout(liveUpdate, 30000); }
if($('#live-profile').length) { src = 'wall'; setTimeout(liveUpdate, 30000); }
if($('#live-network').length) { src = 'network'; setTimeout(liveUpdate, 30000); }
if($('#live-profile').length) { src = 'profile'; setTimeout(liveUpdate, 30000); }
});
function liveUpdate() {
@ -64,9 +64,9 @@ tinyMCE.init({
return;
}
// $.get("live_update",function(data)
// $.get('update_' + src,function(data)
// {
// $(data).find('result').each(function() {
// $(data).find('#wall-item-outside-wrapper').each(function() {
// var net = $(this).find('net').text();
// if(net == 0) { net = ''; }
// $('#net-update').html(net);

View file

@ -13,5 +13,5 @@
$comment
</div>
<div class="wall-item-$indentoutside-wrapper-end" ></div>
<div class="wall-item-outside-wrapper-end$indent" ></div>