This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
A simple new-line delimited JSON protocol with upgrades. | |
Receiving Usage: | |
protocol = require('./frame-protocol'); | |
// parsing data | |
parser = protocol.Parser(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code co-ordinates tabs from the same domain to elect one of them as a | |
// "master", and allow them to broadcast messages to each other. | |
function WindowController () { | |
var now = Date.now(), | |
ping = 0; | |
try { | |
ping = +localStorage.getItem( 'ping' ) || 0; | |
} catch ( error ) {} | |
if ( now - ping > 45000 ) { | |
this.becomeMaster(); |