X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FMeteor%2Fmeteorupdater.js;h=cdd1d63fabb5f31adaea7da8e2af81b848e3d63b;hb=3da5dccce6cd35e58f8ee71251578c23f6839acb;hp=60d2cc37238f84172d39157963f7204886bcc130;hpb=e047ba52c7c3f5953336d46fd22715d880002720;p=quix0rs-gnu-social.git diff --git a/plugins/Meteor/meteorupdater.js b/plugins/Meteor/meteorupdater.js index 60d2cc3723..cdd1d63fab 100644 --- a/plugins/Meteor/meteorupdater.js +++ b/plugins/Meteor/meteorupdater.js @@ -1,26 +1,13 @@ -// update the local timeline from a Meteor server -// +// Update the local timeline from a Meteor server var MeteorUpdater = function() { - var _server; - var _port; - var _timeline; - var _userid; - var _replyurl; - var _favorurl; - var _deleteurl; - return { - init: function(server, port, timeline, userid, replyurl, favorurl, deleteurl) - { - _userid = userid; - _replyurl = replyurl; - _favorurl = favorurl; - _deleteurl = deleteurl; + init: function(server, port, timeline) + { Meteor.callbacks["process"] = function(data) { - receive(JSON.parse(data)); + RealtimeUpdate.receive(JSON.parse(data)); }; Meteor.host = server; @@ -29,123 +16,5 @@ var MeteorUpdater = function() Meteor.connect(); } } - - function receive(data) - { - id = data.id; - - // Don't add it if it already exists - // - if ($("#notice-"+id).length > 0) { - return; - } - - var noticeItem = makeNoticeItem(data); - $("#notices_primary .notices").prepend(noticeItem, true); - $("#notices_primary .notice:first").css({display:"none"}); - $("#notices_primary .notice:first").fadeIn(1000); - NoticeHover(); - NoticeReply(); - } - - function makeNoticeItem(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+"

    "+ - "
    "+ - "
    "+ - "
    "+ - "
    Published
    "+ - "
    "+ - ""+ - "a few seconds ago"+ - " "+ - "
    "+ - "
    "+ - "
    "+ - "
    From
    "+ - "
    "+source+"
    "+ // may have a link, I think - "
    "; - - if (data['in_reply_to_status_id']) { - ni = ni+"
    "+ - "
    To
    "+ - "
    "+ - "in reply to"+ - "
    "+ - "
    "; - } - - ni = ni+"
    "+ - "
    "; - - if (_userid != 0) { - var input = $("form#form_notice fieldset input#token"); - var session_key = input.val(); - ni = ni+makeFavoriteForm(data['id'], session_key); - ni = ni+makeReplyLink(data['id'], data['user']['screen_name']); - if (_userid == data['user']['id']) { - ni = ni+makeDeleteLink(data['id']); - } - } - - ni = ni+"
    "+ - "
  • "; - return ni; - } - - function makeFavoriteForm(id, session_key) - { - var ff; - - ff = "
    "+ - "
    "+ - "Favor this notice"+ // XXX: i18n - ""+ - ""+ - ""+ - "
    "+ - "
    "; - return ff; - } - - function makeReplyLink(id, nickname) - { - var rl; - rl = "
    "+ - "
    Reply to this notice
    "+ - "
    "+ - "Reply "+id+""+ - ""+ - "
    "+ - "
    "; - return rl; - } - - function makeDeleteLink(id) - { - var dl, delurl; - delurl = _deleteurl.replace("0000000000", id); - - dl = "
    "+ - "
    Delete this notice
    "+ - "
    "+ - "Delete"+ - "
    "+ - "
    "; - - return dl; - } }();