From a9cf185e692fdc9dea2a9b127826ea8e0f9f1021 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 15 Sep 2009 13:53:16 +0000 Subject: Updated XHR return markup for Realtime plugin --- plugins/Realtime/realtimeupdate.js | 42 +++++++++----------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) (limited to 'plugins/Realtime/realtimeupdate.js') diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index d55db5859..eba8ac1d9 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -1,8 +1,8 @@ // add a notice encoded as JSON into the current timeline // +// TODO: i18n RealtimeUpdate = { - _userid: 0, _replyurl: '', _favorurl: '', @@ -50,26 +50,15 @@ RealtimeUpdate = { "

"+html+"

"+ ""+ "
"+ - "
"+ - "
Published
"+ - "
"+ - ""+ + ""+ "a few seconds ago"+ " "+ - "
"+ - "
"+ - "
"+ - "
From
"+ - "
"+source+"
"+ // may have a link, I think - "
"; - + ""+ + "from "+ + "+source+"++ // may have a link + ""; if (data['in_reply_to_status_id']) { - ni = ni+"
"+ - "
To
"+ - "
"+ - "in reply to"+ - "
"+ - "
"; + ni = ni+" in context"; } ni = ni+"
"+ @@ -96,7 +85,7 @@ RealtimeUpdate = { ff = "
"+ "
"+ - "Favor this notice"+ // XXX: i18n + "Favor this notice"+ ""+ ""+ ""+ @@ -108,13 +97,7 @@ RealtimeUpdate = { makeReplyLink: function(id, nickname) { var rl; - rl = "
"+ - "
Reply to this notice
"+ - "
"+ - "Reply "+id+""+ - ""+ - "
"+ - "
"; + rl = "Reply "+id+""; return rl; }, @@ -123,12 +106,7 @@ RealtimeUpdate = { var dl, delurl; delurl = RealtimeUpdate._deleteurl.replace("0000000000", id); - dl = "
"+ - "
Delete this notice
"+ - "
"+ - "Delete"+ - "
"+ - "
"; + dl = "Delete"; return dl; }, -- cgit v1.2.3-54-g00ecf From 6568a3202d3acfde694b359e2524d52d93dc83dd Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 16 Sep 2009 13:29:46 +0000 Subject: Fixed typo --- plugins/Realtime/realtimeupdate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/Realtime/realtimeupdate.js') diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index eba8ac1d9..b2c8bb56d 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -55,7 +55,7 @@ RealtimeUpdate = { " "+ ""+ "from "+ - "+source+"++ // may have a link + "+source+"+ // may have a link ""; if (data['in_reply_to_status_id']) { ni = ni+" in context"; -- cgit v1.2.3-54-g00ecf From d9953e015b593965150bb528536f1f90674620ae Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 16 Sep 2009 16:04:19 +0000 Subject: Fixed missing quotes --- plugins/Realtime/realtimeupdate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/Realtime/realtimeupdate.js') diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index b2c8bb56d..faec8d89c 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -55,7 +55,7 @@ RealtimeUpdate = { " "+ ""+ "from "+ - "+source+"+ // may have a link + ""+source+""+ // may have a link ""; if (data['in_reply_to_status_id']) { ni = ni+" in context"; -- cgit v1.2.3-54-g00ecf From acd5a53257f6d0677d1630e4f6cae80706cdbdba Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 21 Sep 2009 19:17:37 +0000 Subject: Initial UI to allow certain timelines to be viewed in a new window in realtime --- plugins/Realtime/RealtimePlugin.php | 2 + plugins/Realtime/icon_external.gif | Bin 0 -> 90 bytes plugins/Realtime/jquery.getUrlParam.js | 72 +++++++++ plugins/Realtime/realtimeupdate.js | 263 +++++++++++++++++++-------------- 4 files changed, 225 insertions(+), 112 deletions(-) create mode 100644 plugins/Realtime/icon_external.gif create mode 100644 plugins/Realtime/jquery.getUrlParam.js (limited to 'plugins/Realtime/realtimeupdate.js') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 7a612a406..611b1d86c 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -97,6 +97,8 @@ class RealtimePlugin extends Plugin $user_id = 0; } + $action->script('plugins/Realtime/jquery.getUrlParam.js'); + $action->elementStart('script', array('type' => 'text/javascript')); $action->raw(' - '); + + $script = ' $(document).ready(function() { '. + $this->_updateInitialize($timeline, $user_id). + '}); '; + + $action->raw($script); + $action->elementEnd('script'); return true; @@ -146,6 +139,47 @@ class RealtimePlugin extends Plugin return true; } + function onStartShowPageNotice($action) + { + $timeline = $this->_getTimeline($action); + if (!empty($timeline)) { + $base = $action->selfUrl(); + if (mb_strstr($url, '?')) { + $url = $base . '&realtime=1'; + } else { + $url = $base . '?realtime=1'; + } + $title = $action->title(); + $code = "window.open('$url', '$title', 'toolbar=no,resizable=yes,scrollbars=yes,status=yes,height=640,width=575');"; + $action->element('a', array('href' => $base, + 'onclick' => $code, + 'id' => 'realtime_timeline', + 'title' => _('Pop up')), + 'Pop up'); + + } + return true; + } + + function onStartShowBody($action) + { + $realtime = $action->boolean('realtime'); + if (!$realtime) { + return true; + } + + $action->elementStart('body', + (common_current_user()) ? array('id' => $action->trimmed('action'), + 'class' => 'user_in') + : array('id' => $action->trimmed('action'))); + if (common_logged_in()) { + $action->showNoticeForm(); + } + $action->showContent(); + $action->elementEnd('body'); + return false; // No default processing + } + function noticeAsJson($notice) { // FIXME: this code should be abstracted to a neutral third @@ -230,4 +264,30 @@ class RealtimePlugin extends Plugin { return ''; } + + function _getTimeline($action) + { + $path = null; + $timeline = null; + + switch ($action->trimmed('action')) { + case 'public': + $path = array('public'); + break; + case 'tag': + $tag = $action->trimmed('tag'); + if (!empty($tag)) { + $path = array('tag', $tag); + } + break; + default: + break; + } + + if (!is_null($path)) { + $timeline = $this->_pathToChannel($path); + } + + return $timeline; + } } diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index da2f9ed3a..3293ef6e9 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -1,152 +1,114 @@ -$(document).ready(function() { - if (!$(document).getUrlParam('realtime')) { - $('#site_nav_local_views .current a').append(''); - - $('#realtime_timeline').css({ - 'margin':'2px 0 0 11px', - 'background':'transparent url('+$('address .url')[0].href+'/plugins/Realtime/icon_external.gif) no-repeat 45% 45%', - 'text-indent':'-9999px', - 'width':'16px', - 'height':'16px', - 'padding':'0', - 'display':'block', - 'float':'right', - 'border':'none', - 'cursor':'pointer' - }); - - $('#realtime_timeline').click(function() { - window.open($(this).parent('a').attr('href')+'?realtime=1', - $(this).parent('a').attr('title'), - 'toolbar=no,resizable=yes,scrollbars=yes,status=yes'); - - return false; - }); - } - else { - window.resizeTo(575, 640); - address = $('address'); - content = $('#content'); - $('body').html(address); - $('address').hide(); - $('body').append(content); - $('#content').css({'width':'92%'}); - } - - - // add a notice encoded as JSON into the current timeline - // - // TODO: i18n - - RealtimeUpdate = { - _userid: 0, - _replyurl: '', - _favorurl: '', - _deleteurl: '', - - init: function(userid, replyurl, favorurl, deleteurl) - { - RealtimeUpdate._userid = userid; - RealtimeUpdate._replyurl = replyurl; - RealtimeUpdate._favorurl = favorurl; - RealtimeUpdate._deleteurl = deleteurl; - }, - - receive: function(data) - { - id = data.id; - - // Don't add it if it already exists - - if ($("#notice-"+id).length > 0) { - return; - } - - var noticeItem = RealtimeUpdate.makeNoticeItem(data); - $("#notices_primary .notices").prepend(noticeItem, true); - $("#notices_primary .notice:first").css({display:"none"}); - $("#notices_primary .notice:first").fadeIn(1000); - NoticeReply(); - }, - - makeNoticeItem: function(data) - { - user = data['user']; - html = data['html'].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"'); - source = data['source'].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"'); - - ni = "
  • "+ - "
    "+ - ""+ - ""+ - "\""+user['screen_name']+"\"/"+ - ""+user['screen_name']+""+ - ""+ - ""+ - "

    "+html+"

    "+ - "
    "+ - "
    "+ - ""+ - "a few seconds ago"+ - " "+ - ""+ - "from "+ +// add a notice encoded as JSON into the current timeline +// +// TODO: i18n + +RealtimeUpdate = { + _userid: 0, + _replyurl: '', + _favorurl: '', + _deleteurl: '', + + init: function(userid, replyurl, favorurl, deleteurl) + { + RealtimeUpdate._userid = userid; + RealtimeUpdate._replyurl = replyurl; + RealtimeUpdate._favorurl = favorurl; + RealtimeUpdate._deleteurl = deleteurl; + }, + + receive: function(data) + { + id = data.id; + + // Don't add it if it already exists + // + if ($("#notice-"+id).length > 0) { + return; + } + + var noticeItem = RealtimeUpdate.makeNoticeItem(data); + $("#notices_primary .notices").prepend(noticeItem, true); + $("#notices_primary .notice:first").css({display:"none"}); + $("#notices_primary .notice:first").fadeIn(1000); + NoticeReply(); + }, + + makeNoticeItem: function(data) + { + user = data['user']; + html = data['html'].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"'); + source = data['source'].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"'); + + ni = "
  • "+ + "
    "+ + ""+ + ""+ + "\""+user['screen_name']+"\"/"+ + ""+user['screen_name']+""+ + ""+ + ""+ + "

    "+html+"

    "+ + "
    "+ + "
    "+ + ""+ + "a few seconds ago"+ + " "+ + ""+ + "from "+ ""+source+""+ // may have a link - ""; - if (data['in_reply_to_status_id']) { - ni = ni+" in context"; - } + ""; + if (data['in_reply_to_status_id']) { + ni = ni+" in context"; + } - ni = ni+"
    "+ + ni = ni+""+ "
    "; - if (RealtimeUpdate._userid != 0) { - var input = $("form#form_notice fieldset input#token"); - var session_key = input.val(); - ni = ni+RealtimeUpdate.makeFavoriteForm(data['id'], session_key); - ni = ni+RealtimeUpdate.makeReplyLink(data['id'], data['user']['screen_name']); - if (RealtimeUpdate._userid == data['user']['id']) { + if (RealtimeUpdate._userid != 0) { + var input = $("form#form_notice fieldset input#token"); + var session_key = input.val(); + ni = ni+RealtimeUpdate.makeFavoriteForm(data['id'], session_key); + ni = ni+RealtimeUpdate.makeReplyLink(data['id'], data['user']['screen_name']); + if (RealtimeUpdate._userid == data['user']['id']) { ni = ni+RealtimeUpdate.makeDeleteLink(data['id']); - } - } + } + } - ni = ni+"
    "+ - "
  • "; - return ni; - }, + ni = ni+""+ + ""; + return ni; + }, - makeFavoriteForm: function(id, session_key) - { - var ff; + makeFavoriteForm: function(id, session_key) + { + var ff; - ff = ""+ + ff = ""+ "
    "+ - "Favor this notice"+ - ""+ - ""+ - ""+ + "Favor this notice"+ + ""+ + ""+ + ""+ "
    "+ - ""; - return ff; + ""; + return ff; + }, + + makeReplyLink: function(id, nickname) + { + var rl; + rl = "Reply "+id+""; + return rl; }, - makeReplyLink: function(id, nickname) - { - var rl; - rl = "Reply "+id+""; - return rl; - }, - - makeDeleteLink: function(id) - { - var dl, delurl; - delurl = RealtimeUpdate._deleteurl.replace("0000000000", id); - - dl = "Delete"; + makeDeleteLink: function(id) + { + var dl, delurl; + delurl = RealtimeUpdate._deleteurl.replace("0000000000", id); - return dl; - } - } + dl = "Delete"; -}); + return dl; + } +} -- cgit v1.2.3-54-g00ecf From bdbc2cb8de370eef6d5d06412746f52797ea0458 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 23 Sep 2009 15:24:12 -0400 Subject: move some stuff around for realtime --- plugins/Realtime/RealtimePlugin.php | 32 ++++++++++---------------------- plugins/Realtime/realtimeupdate.js | 5 +++++ 2 files changed, 15 insertions(+), 22 deletions(-) (limited to 'plugins/Realtime/realtimeupdate.js') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index c41c9ce4a..fde306021 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -76,6 +76,15 @@ class RealtimePlugin extends Plugin return true; } + $base = $action->selfUrl(); + if (mb_strstr($url, '?')) { + $url = $base . '&realtime=1'; + } else { + $url = $base . '?realtime=1'; + } + + $title = $action->title(); + $scripts = $this->_getScripts(); foreach ($scripts as $script) { @@ -94,6 +103,7 @@ class RealtimePlugin extends Plugin $script = ' $(document).ready(function() { '. $this->_updateInitialize($timeline, $user_id). + ' RealtimeUpdate.addPopup("'.$url.'", "'.$title.'"); '. '}); '; $action->raw($script); @@ -189,28 +199,6 @@ class RealtimePlugin extends Plugin return true; } - function onStartShowPageNotice($action) - { - $timeline = $this->_getTimeline($action); - if (!empty($timeline)) { - $base = $action->selfUrl(); - if (mb_strstr($url, '?')) { - $url = $base . '&realtime=1'; - } else { - $url = $base . '?realtime=1'; - } - $title = $action->title(); - $code = "window.open('$url', '$title', 'toolbar=no,resizable=yes,scrollbars=yes,status=yes,height=640,width=575');"; - $action->element('a', array('href' => $base, - 'onclick' => $code, - 'id' => 'realtime_timeline', - 'title' => _('Pop up')), - 'Pop up'); - - } - return true; - } - function onStartShowBody($action) { $realtime = $action->boolean('realtime'); diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 3293ef6e9..04e07956d 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -109,6 +109,11 @@ RealtimeUpdate = { dl = "Delete"; return dl; + }, + + addPopup: function(url, title) + { + // FIXME: need to add the realtime popup button here } } -- cgit v1.2.3-54-g00ecf From 4d4bb089a5e3addfd4be2f82e5e4e257070f4058 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 23 Sep 2009 21:58:35 +0000 Subject: Created addPop() for Realtime plugin and added param to include iconurl --- plugins/Realtime/RealtimePlugin.php | 4 +++- plugins/Realtime/realtimeupdate.js | 25 +++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) (limited to 'plugins/Realtime/realtimeupdate.js') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index fde306021..157c800d9 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -99,11 +99,13 @@ class RealtimePlugin extends Plugin $user_id = 0; } + $iconurl = $base.'plugins/Realtime/icon_external.gif'; + $action->elementStart('script', array('type' => 'text/javascript')); $script = ' $(document).ready(function() { '. $this->_updateInitialize($timeline, $user_id). - ' RealtimeUpdate.addPopup("'.$url.'", "'.$title.'"); '. + ' RealtimeUpdate.addPopup("'.$url.'", "'.$title.'", "'. $iconurl .'");' '}); '; $action->raw($script); diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 04e07956d..2910e4a80 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -111,9 +111,30 @@ RealtimeUpdate = { return dl; }, - addPopup: function(url, title) + addPopup: function(url, title, iconurl) { - // FIXME: need to add the realtime popup button here + $('#site_nav_local_views .current a').append(''); + + $('#realtime_timeline').css({ + 'margin':'2px 0 0 11px', + 'background':'transparent url('+ iconurl + ') no-repeat 45% 45%', + 'text-indent':'-9999px', + 'width':'16px', + 'height':'16px', + 'padding':'0', + 'display':'block', + 'float':'right', + 'border':'none', + 'cursor':'pointer' + }); + + $('#realtime_timeline').click(function() { + window.open(url, + title, + 'toolbar=no,resizable=yes,scrollbars=yes,status=yes'); + + return false; + }); } } -- cgit v1.2.3-54-g00ecf From 1f12993a4ddad8eba29c604c55f6b82d08dc0127 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 23 Sep 2009 22:02:42 +0000 Subject: Added JavaScript to initialize the poped Window --- plugins/Realtime/RealtimePlugin.php | 13 ++++++++++--- plugins/Realtime/realtimeupdate.js | 7 +++++++ 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'plugins/Realtime/realtimeupdate.js') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index f211c01f9..4fb8bf84e 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -99,15 +99,22 @@ class RealtimePlugin extends Plugin $user_id = 0; } - $iconurl = $base.'plugins/Realtime/icon_external.gif'; + // FIXME: Need to check if the current URL is a poped realtime window + if (1==2) { + $realtimeUI = ' RealtimeUpdate.initPopupWindow();'; + } + else { + // FIXME: This icon URL is no good if fancy URLs are off. + $iconurl = $base.'plugins/Realtime/icon_external.gif'; + $realtimeUI = ' RealtimeUpdate.addPopup("'.$url.'", "'.$title.'", "'. $iconurl .'");'; + } $action->elementStart('script', array('type' => 'text/javascript')); $script = ' $(document).ready(function() { '. $this->_updateInitialize($timeline, $user_id). - ' RealtimeUpdate.addPopup("'.$url.'", "'.$title.'", "'. $iconurl .'");' + $realtimeUI. '}); '; - $action->raw($script); $action->elementEnd('script'); diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 2910e4a80..4fda5079d 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -135,6 +135,13 @@ RealtimeUpdate = { return false; }); + }, + + initPopupWindow: function() + { + window.resizeTo(575, 640); + $('address').hide(); + $('#content').css({'width':'92%'}); } } -- cgit v1.2.3-54-g00ecf From d86155ad943032918c2fab070ca49f0a3586f25d Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 23 Sep 2009 22:04:39 +0000 Subject: Using timeline string instead of title for WindowName because IE doesn't like names with whitespace. --- plugins/Realtime/RealtimePlugin.php | 4 +--- plugins/Realtime/realtimeupdate.js | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'plugins/Realtime/realtimeupdate.js') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 4fb8bf84e..7334f5657 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -83,8 +83,6 @@ class RealtimePlugin extends Plugin $url = $base . '?realtime=1'; } - $title = $action->title(); - $scripts = $this->_getScripts(); foreach ($scripts as $script) { @@ -106,7 +104,7 @@ class RealtimePlugin extends Plugin else { // FIXME: This icon URL is no good if fancy URLs are off. $iconurl = $base.'plugins/Realtime/icon_external.gif'; - $realtimeUI = ' RealtimeUpdate.addPopup("'.$url.'", "'.$title.'", "'. $iconurl .'");'; + $realtimeUI = ' RealtimeUpdate.addPopup("'.$url.'", "'.$timeline.'", "'. $iconurl .'");'; } $action->elementStart('script', array('type' => 'text/javascript')); diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 4fda5079d..57fe0a843 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -111,7 +111,7 @@ RealtimeUpdate = { return dl; }, - addPopup: function(url, title, iconurl) + addPopup: function(url, timeline, iconurl) { $('#site_nav_local_views .current a').append(''); @@ -130,7 +130,7 @@ RealtimeUpdate = { $('#realtime_timeline').click(function() { window.open(url, - title, + timeline, 'toolbar=no,resizable=yes,scrollbars=yes,status=yes'); return false; -- cgit v1.2.3-54-g00ecf