diff options
author | Sarven Capadisli <csarven@status.net> | 2009-11-18 13:34:06 +0000 |
---|---|---|
committer | Sarven Capadisli <csarven@status.net> | 2009-11-18 13:34:06 +0000 |
commit | 43b6da8afc223d1eefa74d390b09b7a4381ee734 (patch) | |
tree | 3afb075108713c1089f9c217418bc8242907dc1c /plugins | |
parent | 007418fdab8f9f0c718a18568bfbf4377bb85364 (diff) |
Created separate objects for receive actions
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Realtime/realtimeupdate.js | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index d1cf1d507..6404cf896 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -36,6 +36,7 @@ RealtimeUpdate = { _updatecounter: 0, _maxnotices: 50, _windowhasfocus: true, + _documenttitle: '', init: function(userid, replyurl, favorurl, deleteurl) { @@ -44,7 +45,7 @@ RealtimeUpdate = { RealtimeUpdate._favorurl = favorurl; RealtimeUpdate._deleteurl = deleteurl; - DT = document.title; + RealtimeUpdate._documenttitle = document.title; $(window).bind('focus', function(){ RealtimeUpdate._windowhasfocus = true; }); @@ -54,7 +55,7 @@ RealtimeUpdate = { $('#notices_primary .notice:first').addClass('mark-top'); RealtimeUpdate._updatecounter = 0; - document.title = DT; + document.title = RealtimeUpdate._documenttitle; RealtimeUpdate._windowhasfocus = false; return false; @@ -70,24 +71,37 @@ RealtimeUpdate = { return; } - var noticeItem = RealtimeUpdate.makeNoticeItem(data); - $("#notices_primary .notices").prepend(noticeItem); - $("#notices_primary .notice:first").css({display:"none"}); - $("#notices_primary .notice:first").fadeIn(1000); + RealtimeUpdate.purgeLastNoticeItem(); - if ($('#notices_primary .notice').length > RealtimeUpdate._maxnotices) { - $("#notices_primary .notice:last .form_disfavor").unbind('submit'); - $("#notices_primary .notice:last .form_favor").unbind('submit'); - $("#notices_primary .notice:last .notice_reply").unbind('click'); - $("#notices_primary .notice:last").remove(); - } + RealtimeUpdate.insertNoticeItem(data); + + RealtimeUpdate.updateWindowCounter(); + + }, - SN.U.NoticeReply(); - SN.U.NoticeFavor(); + insertNoticeItem: function(data) { + var noticeItem = RealtimeUpdate.makeNoticeItem(data); + $("#notices_primary .notices").prepend(noticeItem); + $("#notices_primary .notice:first").css({display:"none"}); + $("#notices_primary .notice:first").fadeIn(1000); + + SN.U.NoticeReply(); + SN.U.NoticeFavor(); + }, + + purgeLastNoticeItem: function() { + if ($('#notices_primary .notice').length > RealtimeUpdate._maxnotices) { + $("#notices_primary .notice:last .form_disfavor").unbind('submit'); + $("#notices_primary .notice:last .form_favor").unbind('submit'); + $("#notices_primary .notice:last .notice_reply").unbind('click'); + $("#notices_primary .notice:last").remove(); + } + }, + updateWindowCounter: function() { if (RealtimeUpdate._windowhasfocus === false) { RealtimeUpdate._updatecounter += 1; - document.title = '('+RealtimeUpdate._updatecounter+') ' + DT; + document.title = '('+RealtimeUpdate._updatecounter+') ' + RealtimeUpdate._documenttitle; } }, |