X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FRealtime%2Frealtimeupdate.js;h=52151f9de8dad1dd42df0e95034b020ff98e9e32;hb=9a54745fcd252e27cc664da7cee67b48d0f4f501;hp=a2c4da113e01efe8f9100ab18af3ee13f9d03f2e;hpb=b657e49ec772aec2b60ae193252edd53d85e1df5;p=quix0rs-gnu-social.git diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index a2c4da113e..52151f9de8 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -32,6 +32,7 @@ RealtimeUpdate = { _userid: 0, _replyurl: '', _favorurl: '', + _repeaturl: '', _deleteurl: '', _updatecounter: 0, _maxnotices: 50, @@ -40,11 +41,12 @@ RealtimeUpdate = { _paused:false, _queuedNotices:[], - init: function(userid, replyurl, favorurl, deleteurl) + init: function(userid, replyurl, favorurl, repeaturl, deleteurl) { RealtimeUpdate._userid = userid; RealtimeUpdate._replyurl = replyurl; RealtimeUpdate._favorurl = favorurl; + RealtimeUpdate._repeaturl = repeaturl; RealtimeUpdate._deleteurl = deleteurl; RealtimeUpdate._documenttitle = document.title; @@ -87,19 +89,20 @@ RealtimeUpdate = { } var noticeItem = RealtimeUpdate.makeNoticeItem(data); + var noticeItemID = $(noticeItem).attr('id'); + $("#notices_primary .notices").prepend(noticeItem); $("#notices_primary .notice:first").css({display:"none"}); $("#notices_primary .notice:first").fadeIn(1000); - SN.U.NoticeReply(); - SN.U.NoticeFavor(); + SN.U.FormXHR($('#'+noticeItemID+' .form_favor')); + SN.U.NoticeReplyTo($('#'+noticeItemID)); + SN.U.FormXHR($('#'+noticeItemID+' .form_repeat')); + SN.U.NoticeWithAttachment($('#'+noticeItemID)); }, 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(); } }, @@ -113,11 +116,24 @@ RealtimeUpdate = { makeNoticeItem: function(data) { + if (data.hasOwnProperty('retweeted_status')) { + original = data['retweeted_status']; + repeat = data; + data = original; + unique = repeat['id']; + responsible = repeat['user']; + } else { + original = null; + repeat = null; + unique = data['id']; + responsible = data['user']; + } + 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,'"'); + html = data['html'].replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/&/g,'&'); + source = data['source'].replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/&/g,'&'); - ni = "
  • "+ + ni = "
  • "+ "
    "+ ""+ ""+ @@ -139,20 +155,31 @@ RealtimeUpdate = { ni = ni+" in context"; } - ni = ni+"
    "+ - "
    "; + if (repeat) { + ru = repeat['user']; + ni = ni + "Repeated by " + + "" + + ""+ ru['screen_name'] + ""; + } + + 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 == responsible['id']) { ni = ni+RealtimeUpdate.makeDeleteLink(data['id']); + } else if (RealtimeUpdate._userid != user['id']) { + ni = ni+RealtimeUpdate.makeRepeatForm(data['id'], session_key); } } - ni = ni+"
    "+ + ni = ni+""; + "
  • "; return ni; }, @@ -177,7 +204,22 @@ RealtimeUpdate = { var rl; rl = "Reply "+id+""; return rl; - }, + }, + + makeRepeatForm: function(id, session_key) + { + var rf; + rf = "
    "+ + "
    "+ + "Favor this notice"+ + ""+ + ""+ + ""+ + "
    "+ + "
    "; + + return rf; + }, makeDeleteLink: function(id) { @@ -191,8 +233,7 @@ RealtimeUpdate = { initActions: function(url, timeline, path) { - var NP = $('#notices_primary'); - NP.prepend(''); + $('#notices_primary').prepend(''); RealtimeUpdate._pluginPath = path; @@ -202,19 +243,30 @@ RealtimeUpdate = { initPlayPause: function() { - RealtimeUpdate.showPause(); + if (typeof(localStorage) == 'undefined') { + RealtimeUpdate.showPause(); + } + else { + if (localStorage.getItem('RealtimeUpdate_paused') === 'true') { + RealtimeUpdate.showPlay(); + } + else { + RealtimeUpdate.showPause(); + } + } }, showPause: function() { - RT_PP = $('#realtime_playpause'); - RT_PP.empty(); - RT_PP.append(''); + RealtimeUpdate.setPause(false); + RealtimeUpdate.showQueuedNotices(); + RealtimeUpdate.addNoticesHover(); - RT_P = $('#realtime_pause'); - RT_P.bind('click', function() { - RealtimeUpdate._paused = true; + $('#realtime_playpause').remove(); + $('#realtime_actions').prepend('
  • '); + $('#realtime_pause').bind('click', function() { + RealtimeUpdate.removeNoticesHover(); RealtimeUpdate.showPlay(); return false; }); @@ -222,22 +274,24 @@ RealtimeUpdate = { showPlay: function() { - RT_PP = $('#realtime_playpause'); - RT_PP.empty(); - RT_PP.append(' '); - - RT_P = $('#realtime_play'); - RT_P.bind('click', function() { - RealtimeUpdate._paused = false; + RealtimeUpdate.setPause(true); + $('#realtime_playpause').remove(); + $('#realtime_actions').prepend('
  • '); + $('#realtime_play').bind('click', function() { RealtimeUpdate.showPause(); - - RealtimeUpdate.showQueuedNotices(); - return false; }); }, + setPause: function(state) + { + RealtimeUpdate._paused = state; + if (typeof(localStorage) != 'undefined') { + localStorage.setItem('RealtimeUpdate_paused', RealtimeUpdate._paused); + } + }, + showQueuedNotices: function() { $.each(RealtimeUpdate._queuedNotices, function(i, n) { @@ -259,16 +313,35 @@ RealtimeUpdate = { $('#realtime_playpause #queued_counter').empty(); }, + addNoticesHover: function() + { + $('#notices_primary .notices').hover( + function() { + if (RealtimeUpdate._paused === false) { + RealtimeUpdate.showPlay(); + } + }, + function() { + if (RealtimeUpdate._paused === true) { + RealtimeUpdate.showPause(); + } + } + ); + }, + + removeNoticesHover: function() + { + $('#notices_primary .notices').unbind(); + }, + initAddPopup: function(url, timeline, path) { - var NP = $('#realtime_timeline'); - NP.append(''); + $('#realtime_timeline').append(''); - var PP = $('#realtime_popup'); - PP.bind('click', function() { + $('#realtime_popup').bind('click', function() { window.open(url, '', - 'toolbar=no,resizable=yes,scrollbars=yes,status=yes,width=500,height=550'); + 'toolbar=no,resizable=yes,scrollbars=yes,status=no,menubar=no,personalbar=no,location=no,width=500,height=550'); return false; }); @@ -276,31 +349,13 @@ RealtimeUpdate = { initPopupWindow: function() { - $('address').hide(); - $('#content').css({'width':'93.5%'}); - - $('#form_notice').css({ - 'margin':'18px 0 18px 1.795%', - 'width':'93%', - 'max-width':'451px' - }); - - $('#form_notice label[for=notice_data-text], h1').css({'display': 'none'}); - - $('.notices li:first-child').css({'border-top-color':'transparent'}); - - $('#form_notice label[for="notice_data-attach"], #form_notice #notice_data-attach').css({'top':'0'}); - - $('#form_notice #notice_data-attach').css({ - 'left':'auto', - 'right':'0' - }); - $('.notices .entry-title a, .notices .entry-content a').bind('click', function() { window.open(this.href, ''); - + return false; }); + + $('#showstream .entity_profile').css({'width':'69%'}); } }