more work on json notifications, now working except for notify popup
This commit is contained in:
parent
03209d2d0d
commit
f83a504da1
@ -770,7 +770,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
|
||||
'text' => strip_tags(template_escape($body)),
|
||||
'id' => $item['item_id'],
|
||||
'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
|
||||
'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])),
|
||||
'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $owner_name, ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])),
|
||||
'to' => t('to'),
|
||||
'wall' => t('Wall-to-Wall'),
|
||||
'vwall' => t('via Wall-To-Wall:'),
|
||||
|
@ -112,7 +112,7 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
|
||||
}
|
||||
catch(Exception $e) {
|
||||
logger('datetime_convert: exception: ' . $e->getMessage());
|
||||
$d = newDateTime('now', $from_obj);
|
||||
$d = new DateTime('now', $from_obj);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -229,7 +229,7 @@ function count_common_friends_zcid($uid,$zcid) {
|
||||
|
||||
}
|
||||
|
||||
function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle) {
|
||||
function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = false) {
|
||||
|
||||
if($shuffle)
|
||||
$sql_extra = " order by rand() ";
|
||||
|
119
js/main.js
119
js/main.js
@ -116,33 +116,7 @@
|
||||
var notifications_empty = unescape($("#nav-notifications-menu").html());
|
||||
|
||||
/* nav update event */
|
||||
$('nav').bind('nav-update', function(e,data){;
|
||||
var invalid = $(data).find('invalid').text();
|
||||
if(invalid == 1) { window.location.href=window.location.href }
|
||||
|
||||
var net = $(data).find('net').text();
|
||||
if(net == 0) { net = ''; $('#net-update').removeClass('show') } else { $('#net-update').addClass('show') }
|
||||
$('#net-update').html(net);
|
||||
|
||||
var home = $(data).find('home').text();
|
||||
if(home == 0) { home = ''; $('#home-update').removeClass('show') } else { $('#home-update').addClass('show') }
|
||||
$('#home-update').html(home);
|
||||
|
||||
var intro = $(data).find('intro').text();
|
||||
if(intro == 0) { intro = ''; $('#intro-update').removeClass('show') } else { $('#intro-update').addClass('show') }
|
||||
$('#intro-update').html(intro);
|
||||
|
||||
var mail = $(data).find('mail').text();
|
||||
if(mail == 0) { mail = ''; $('#mail-update').removeClass('show') } else { $('#mail-update').addClass('show') }
|
||||
$('#mail-update').html(mail);
|
||||
|
||||
var intro = $(data).find('intro').text();
|
||||
if(intro == 0) { intro = ''; $('#intro-update-li').removeClass('show') } else { $('#intro-update-li').addClass('show') }
|
||||
$('#intro-update-li').html(intro);
|
||||
|
||||
var mail = $(data).find('mail').text();
|
||||
if(mail == 0) { mail = ''; $('#mail-update-li').removeClass('show') } else { $('#mail-update-li').addClass('show') }
|
||||
$('#mail-update-li').html(mail);
|
||||
$('nav').bind('nav-update', function(e,data) {
|
||||
|
||||
var eNotif = $(data).find('notif')
|
||||
|
||||
@ -168,15 +142,6 @@
|
||||
if(notif == 0) { notif = ''; $('#notify-update').removeClass('show') } else { $('#notify-update').addClass('show') }
|
||||
$('#notify-update').html(notif);
|
||||
|
||||
var eSysmsg = $(data).find('sysmsgs');
|
||||
eSysmsg.children("notice").each(function(){
|
||||
text = $(this).text();
|
||||
$.jGrowl(text, { sticky: true, theme: 'notice' });
|
||||
});
|
||||
eSysmsg.children("info").each(function(){
|
||||
text = $(this).text();
|
||||
$.jGrowl(text, { sticky: false, theme: 'info', life: 10000 });
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@ -214,36 +179,68 @@
|
||||
function NavUpdate() {
|
||||
|
||||
if(! stopped) {
|
||||
|
||||
var pingCmd = 'ping' + ((localUser != 0) ? '?f=&uid=' + localUser : '');
|
||||
|
||||
$.get(pingCmd,function(data) {
|
||||
$(data).find('result').each(function() {
|
||||
// send nav-update event
|
||||
$('nav').trigger('nav-update', this);
|
||||
|
||||
|
||||
// start live update
|
||||
|
||||
if($('#live-network').length) { src = 'network'; liveUpdate(); }
|
||||
if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
|
||||
if($('#live-community').length) { src = 'community'; liveUpdate(); }
|
||||
if($('#live-notes').length) { src = 'notes'; liveUpdate(); }
|
||||
if($('#live-display').length) {
|
||||
if(liking) {
|
||||
liking = 0;
|
||||
window.location.href=window.location.href
|
||||
}
|
||||
}
|
||||
if($('#live-photos').length) {
|
||||
if(liking) {
|
||||
liking = 0;
|
||||
window.location.href=window.location.href
|
||||
}
|
||||
}
|
||||
if(data.invalid == 1) {
|
||||
window.location.href=window.location.href
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(data.network == 0) {
|
||||
data.network = '';
|
||||
$('#net-update').removeClass('show')
|
||||
}
|
||||
else {
|
||||
$('#net-update').addClass('show')
|
||||
}
|
||||
$('#net-update').html(data.network);
|
||||
|
||||
if(data.home == 0) { data.home = ''; $('#home-update').removeClass('show') } else { $('#home-update').addClass('show') }
|
||||
$('#home-update').html(data.home);
|
||||
|
||||
|
||||
if(data.intros == 0) { data.intros = ''; $('#intro-update').removeClass('show') } else { $('#intro-update').addClass('show') }
|
||||
$('#intro-update').html(data.intros);
|
||||
|
||||
if(data.mail == 0) { data.mail = ''; $('#mail-update').removeClass('show') } else { $('#mail-update').addClass('show') }
|
||||
$('#mail-update').html(data.mail);
|
||||
|
||||
|
||||
if(data.notify == 0) { data.notify = ''; $('#notify-update').removeClass('show') } else { $('#notify-update').addClass('show') }
|
||||
$('#notify-update').html(data.notify);
|
||||
|
||||
|
||||
|
||||
$(data.notice).each(function() {
|
||||
$.jGrowl(this.message, { sticky: true, theme: 'notice' });
|
||||
});
|
||||
|
||||
$(data.info).each(function(){
|
||||
$.jGrowl(this.message, { sticky: false, theme: 'info', life: 10000 });
|
||||
});
|
||||
|
||||
|
||||
// start live update
|
||||
|
||||
if($('#live-network').length) { src = 'network'; liveUpdate(); }
|
||||
if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
|
||||
if($('#live-community').length) { src = 'community'; liveUpdate(); }
|
||||
if($('#live-notes').length) { src = 'notes'; liveUpdate(); }
|
||||
if($('#live-display').length) {
|
||||
if(liking) {
|
||||
liking = 0;
|
||||
window.location.href=window.location.href
|
||||
}
|
||||
}
|
||||
if($('#live-photos').length) {
|
||||
if(liking) {
|
||||
liking = 0;
|
||||
window.location.href=window.location.href
|
||||
}
|
||||
}
|
||||
|
||||
}) ;
|
||||
}
|
||||
timer = setTimeout(NavUpdate,updateInterval);
|
||||
|
55
mod/ping.php
55
mod/ping.php
@ -8,10 +8,34 @@ function ping_init(&$a) {
|
||||
$result = array();
|
||||
$notifs = array();
|
||||
|
||||
$result['notify'] = 0;
|
||||
$result['home'] = 0;
|
||||
$result['network'] = 0;
|
||||
$result['intros'] = 0;
|
||||
$result['mail'] = 0;
|
||||
$result['register'] = 0;
|
||||
$result['notice'] = array();
|
||||
$result['info'] = array();
|
||||
|
||||
|
||||
header("content-type: application/json");
|
||||
|
||||
if((! local_user()) || ((intval($_GET['uid'])) && (intval($_GET['uid']) != local_user()))) {
|
||||
$result[] = array('success' => false, 'message' => 'Authentication error');
|
||||
$result['invalid'] = ((intval($_GET['uid'])) && (intval($_GET['uid']) != local_user()) ? 1 : 0);
|
||||
|
||||
if(x($_SESSION,'sysmsg')){
|
||||
foreach ($_SESSION['sysmsg'] as $m){
|
||||
$result['notice'][] = array('message' => $m);
|
||||
}
|
||||
unset($_SESSION['sysmsg']);
|
||||
}
|
||||
if(x($_SESSION,'sysmsg_info')){
|
||||
foreach ($_SESSION['sysmsg_info'] as $m){
|
||||
$result['info'][] = array('message' => $m);
|
||||
}
|
||||
unset($_SESSION['sysmsg_info']);
|
||||
}
|
||||
|
||||
if((! local_user()) || ($result['invalid'])) {
|
||||
echo json_encode($result);
|
||||
killme();
|
||||
}
|
||||
@ -58,16 +82,6 @@ function ping_init(&$a) {
|
||||
|
||||
}
|
||||
|
||||
$result['notify'] = 0;
|
||||
$result['home'] = 0;
|
||||
$result['network'] = 0;
|
||||
$result['intros'] = 0;
|
||||
$result['mail'] = 0;
|
||||
$result['register'] = 0;
|
||||
$result['notice'] = array();
|
||||
$result['info'] = array();
|
||||
|
||||
|
||||
|
||||
$t = q("select count(*) as total from notify where uid = %d and seen = 0",
|
||||
intval(local_user())
|
||||
@ -106,8 +120,8 @@ function ping_init(&$a) {
|
||||
WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
|
||||
intval(local_user())
|
||||
);
|
||||
|
||||
$intro = count($intros1) + count($intros2);
|
||||
|
||||
$intros = count($intros1) + count($intros2);
|
||||
$result['intros'] = intval($intros);
|
||||
|
||||
$myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
|
||||
@ -124,19 +138,6 @@ function ping_init(&$a) {
|
||||
if($regs)
|
||||
$result['register'] = intval($regs[0]['total']);
|
||||
}
|
||||
|
||||
if(x($_SESSION,'sysmsg')){
|
||||
foreach ($_SESSION['sysmsg'] as $m){
|
||||
$result['notice'][] = $m;
|
||||
}
|
||||
unset($_SESSION['sysmsg']);
|
||||
}
|
||||
if(x($_SESSION,'sysmsg_info')){
|
||||
foreach ($_SESSION['sysmsg_info'] as $m){
|
||||
$result['info'][] = $m;
|
||||
}
|
||||
unset($_SESSION['sysmsg_info']);
|
||||
}
|
||||
|
||||
echo json_encode($result);
|
||||
killme();
|
||||
|
@ -1 +1 @@
|
||||
2012-07-14.15
|
||||
2012-07-15.16
|
||||
|
Reference in New Issue
Block a user