summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Realtime/RealtimePlugin.php9
-rw-r--r--plugins/Realtime/jquery.getUrlParam.js72
-rw-r--r--plugins/Realtime/realtimeupdate.js77
3 files changed, 64 insertions, 94 deletions
diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php
index 0f0d0f9f4..0c7c1240c 100644
--- a/plugins/Realtime/RealtimePlugin.php
+++ b/plugins/Realtime/RealtimePlugin.php
@@ -230,6 +230,7 @@ class RealtimePlugin extends Plugin
}
$action->showContentBlock();
+ $action->showScripts();
$action->elementEnd('body');
return false; // No default processing
}
@@ -239,13 +240,13 @@ class RealtimePlugin extends Plugin
// FIXME: this code should be abstracted to a neutral third
// party, like Notice::asJson(). I'm not sure of the ethics
// of refactoring from within a plugin, so I'm just abusing
- // the TwitterApiAction method. Don't do this unless you're me!
+ // the ApiAction method. Don't do this unless you're me!
- require_once(INSTALLDIR.'/lib/twitterapi.php');
+ require_once(INSTALLDIR.'/lib/api.php');
- $act = new TwitterApiAction('/dev/null');
+ $act = new ApiAction('/dev/null');
- $arr = $act->twitter_status_array($notice, true);
+ $arr = $act->twitterStatusArray($notice, true);
$arr['url'] = $notice->bestUrl();
$arr['html'] = htmlspecialchars($notice->rendered);
$arr['source'] = htmlspecialchars($arr['source']);
diff --git a/plugins/Realtime/jquery.getUrlParam.js b/plugins/Realtime/jquery.getUrlParam.js
deleted file mode 100644
index e8f73eb47..000000000
--- a/plugins/Realtime/jquery.getUrlParam.js
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Copyright (c) 2006-2007 Mathias Bank (http://www.mathias-bank.de)
- * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
- * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
- *
- * Version 2.1
- *
- * Thanks to
- * Hinnerk Ruemenapf - http://hinnerk.ruemenapf.de/ for bug reporting and fixing.
- * Tom Leonard for some improvements
- *
- */
-jQuery.fn.extend({
-/**
-* Returns get parameters.
-*
-* If the desired param does not exist, null will be returned
-*
-* To get the document params:
-* @example value = $(document).getUrlParam("paramName");
-*
-* To get the params of a html-attribut (uses src attribute)
-* @example value = $('#imgLink').getUrlParam("paramName");
-*/
- getUrlParam: function(strParamName){
- strParamName = escape(unescape(strParamName));
-
- var returnVal = new Array();
- var qString = null;
-
- if ($(this).attr("nodeName")=="#document") {
- //document-handler
-
- if (window.location.search.search(strParamName) > -1 ){
-
- qString = window.location.search.substr(1,window.location.search.length).split("&");
- }
-
- } else if ($(this).attr("src")!="undefined") {
-
- var strHref = $(this).attr("src")
- if ( strHref.indexOf("?") > -1 ){
- var strQueryString = strHref.substr(strHref.indexOf("?")+1);
- qString = strQueryString.split("&");
- }
- } else if ($(this).attr("href")!="undefined") {
-
- var strHref = $(this).attr("href")
- if ( strHref.indexOf("?") > -1 ){
- var strQueryString = strHref.substr(strHref.indexOf("?")+1);
- qString = strQueryString.split("&");
- }
- } else {
- return null;
- }
-
-
- if (qString==null) return null;
-
-
- for (var i=0;i<qString.length; i++){
- if (escape(unescape(qString[i].split("=")[0])) == strParamName){
- returnVal.push(qString[i].split("=")[1]);
- }
-
- }
-
-
- if (returnVal.length==0) return null;
- else if (returnVal.length==1) return returnVal[0];
- else return returnVal;
- }
-}); \ No newline at end of file
diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js
index 4cd68a816..e82b4dbfb 100644
--- a/plugins/Realtime/realtimeupdate.js
+++ b/plugins/Realtime/realtimeupdate.js
@@ -1,5 +1,31 @@
-// add a notice encoded as JSON into the current timeline
-//
+/*
+ * StatusNet - a distributed open-source microblogging tool
+ * Copyright (C) 2008, StatusNet, Inc.
+ *
+ * Add a notice encoded as JSON into the current timeline
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Plugin
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Sarven Capadisli <csarven@status.net>
+ * @copyright 2009 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
// TODO: i18n
RealtimeUpdate = {
@@ -7,6 +33,7 @@ RealtimeUpdate = {
_replyurl: '',
_favorurl: '',
_deleteurl: '',
+ _updatecounter: 0,
init: function(userid, replyurl, favorurl, deleteurl)
{
@@ -15,6 +42,8 @@ RealtimeUpdate = {
RealtimeUpdate._favorurl = favorurl;
RealtimeUpdate._deleteurl = deleteurl;
+ DT = document.title;
+
$(window).blur(function() {
$('#notices_primary .notice').css({
'border-top-color':$('#notices_primary .notice:last').css('border-top-color'),
@@ -25,24 +54,33 @@ RealtimeUpdate = {
'border-top-color':'#AAAAAA',
'border-top-style':'solid'
});
+
+ RealtimeUpdate._updatecounter = 0;
+ document.title = DT;
+
+ return false;
});
},
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);
- $("#notices_primary .notice:first").css({display:"none"});
- $("#notices_primary .notice:first").fadeIn(1000);
- NoticeReply();
+ setTimeout(function() {
+ 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);
+ $("#notices_primary .notice:first").css({display:"none"});
+ $("#notices_primary .notice:first").fadeIn(1000);
+ NoticeReply();
+
+ RealtimeUpdate._updatecounter += 1;
+ document.title = '('+RealtimeUpdate._updatecounter+') ' + DT;
+ }, 500);
},
makeNoticeItem: function(data)
@@ -125,14 +163,17 @@ RealtimeUpdate = {
addPopup: function(url, timeline, iconurl)
{
- $('#content').prepend('<button id="realtime_timeline" title="Pop up in a window">Pop up</button>');
+ $('#notices_primary').css({'position':'relative'});
+ $('#notices_primary').prepend('<button id="realtime_timeline" title="Pop up in a window">Pop up</button>');
$('#realtime_timeline').css({
- 'margin':'0 0 18px 0',
+ 'margin':'0 0 11px 0',
'background':'transparent url('+ iconurl + ') no-repeat 0% 30%',
'padding':'0 0 0 20px',
'display':'block',
- 'float':'right',
+ 'position':'absolute',
+ 'top':'-20px',
+ 'right':'0',
'border':'none',
'cursor':'pointer',
'color':$("a").css("color"),