summaryrefslogtreecommitdiff
path: root/plugins/Meteor/meteorupdater.js
blob: 91d12cde9c2696b546b2eeb37cec21ef09ef6ca6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Update the local timeline from a Meteor server
// XXX: If @a is subscribed to @b, @a should get @b's notices in @a's Personal timeline.
//      Do Replies timeline.

var MeteorUpdater = function()
{
    return {

        init: function(server, port, timeline)
        {
            Meteor.callbacks["process"] = function(data) {
                var d = JSON.parse(data);

                var user_url = $('address .url')[0].href+d['user']['screen_name'];

                var wlh = window.location.href;

                if (wlh.indexOf('?') > 0) {
                   wlh = wlh.slice(0, wlh.indexOf('?'))
                }

                if (timeline == 'public' ||
                    user_url+'/all' == wlh ||
                    user_url == wlh) {

                    RealtimeUpdate.receive(d);
                }
            };

            Meteor.host = server;
            Meteor.port = port;
            Meteor.joinChannel(timeline, 0);
            Meteor.connect();
        }
    }
}();