1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 15:22:41 +01:00
phorge-phorge/webroot/rsrc/externals/javelin/lib
epriestley e0087a9f7a Add JX.Leader: synchronization over localStorage
Summary:
Ref T6559. Adds a "JX.Leader" primitive to replace the synchronization over Flash. This does a couple of things:

  - Offers an "onBecomeLeader" event, which we can use to open the WebSocket.
  - Offers an "onReceiveMessage" event, which we can use to dispatch notifications and handle requests to play sounds and send desktop notifications.
  - Offers a "broadcast()" method, which we can use to send desktop notification and sound requests.

Test Plan:
Added some code like this:

```
  if (!statics.leader) {
    statics.leader = true;

    JX.Leader.listen('onBecomeLeader', function() {
      JX.log("This tab is now the leader.");
    });

    JX.Leader.listen('onReceiveBroadcast', function(message, is_leader) {
      JX.log('[' + (is_leader ? 'As Leader' : 'Not Leader') + '] ' + message);
    });

    JX.Leader.start();
  }
```

Then:

  - Saw first tab open become leader reliably in Safari, Chrome, Firefox.
  - Saw new tab become leader reliably when the first tab was closed.
  - Saw broadcast() work as documented and deliver messages with correct leadership-flag and uniqueness.

Reviewers: joshuaspence, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6559

Differential Revision: https://secure.phabricator.com/D11235
2015-01-06 17:50:40 -08:00
..
__tests__ Various linter fixes. 2014-02-26 12:44:58 -08:00
control Resize tokenizer text input after pasting 2014-09-08 10:17:09 -07:00
behavior.js Remove @group annotations 2014-07-10 08:12:48 +10:00
Cookie.js Move all external JS into webroot/rsrc/externals 2013-04-11 10:06:05 -07:00
DOM.js Remove @group annotations 2014-07-10 08:12:48 +10:00
History.js Remove spurious "+x" from files that shouldn't have it 2013-10-05 05:18:17 -07:00
JSON.js Remove @group annotations 2014-07-10 08:12:48 +10:00
Leader.js Add JX.Leader: synchronization over localStorage 2015-01-06 17:50:40 -08:00
Mask.js Remove @group annotations 2014-07-10 08:12:48 +10:00
Request.js Remove @group annotations 2014-07-10 08:12:48 +10:00
Resource.js Fix countdown embeds and endless loops on resource loads in Javelin 2014-06-05 17:16:36 -07:00
Routable.js Provide a global router for Ajax requests 2014-05-05 10:57:42 -07:00
Router.js Provide a global router for Ajax requests 2014-05-05 10:57:42 -07:00
URI.js Remove @group annotations 2014-07-10 08:12:48 +10:00
Vector.js When dragging stuff around, compensate for changes in scroll position 2014-08-09 08:49:01 -07:00
WebSocket.js Implement JX.WebSocket 2015-01-06 17:48:05 -08:00
Workflow.js Remove @group annotations 2014-07-10 08:12:48 +10:00