From df1ee6867e9774374b01784eb671bd16e6c58984 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 4 Nov 2009 09:12:34 +0000 Subject: Sync Realtime JavaScript with 0.9.x --- plugins/Realtime/realtimeupdate.js | 47 +++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 4cd68a816..9371326fe 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -7,6 +7,7 @@ RealtimeUpdate = { _replyurl: '', _favorurl: '', _deleteurl: '', + _updatecounter: 0, init: function(userid, replyurl, favorurl, deleteurl) { @@ -15,6 +16,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 +28,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 +137,17 @@ RealtimeUpdate = { addPopup: function(url, timeline, iconurl) { - $('#content').prepend(''); + $('#notices_primary').css({'position':'relative'}); + $('#notices_primary').prepend(''); $('#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"), -- cgit v1.2.3-54-g00ecf From cc0a6dce36f2d5b1ffe664c24fef8864b0065602 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 4 Nov 2009 09:19:39 +0000 Subject: Sync RealtimePlugin with 0.9.x --- plugins/Realtime/RealtimePlugin.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 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']); -- cgit v1.2.3-54-g00ecf From 1e7c4f773b229f06bbc096449bf80286cf3eec3e Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 4 Nov 2009 09:20:36 +0000 Subject: Script no longer neeed --- plugins/Realtime/jquery.getUrlParam.js | 72 ---------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 plugins/Realtime/jquery.getUrlParam.js 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 Date: Wed, 4 Nov 2009 09:24:14 +0000 Subject: Added script documentation --- plugins/Realtime/realtimeupdate.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 9371326fe..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 . + * + * @category Plugin + * @package StatusNet + * @author Evan Prodromou + * @author Sarven Capadisli + * @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 = { -- cgit v1.2.3-54-g00ecf