lib/input.js
function visibilityChange(ev) {  // {{{2
  var that = this;

  if (this.visibilityTimeout) {
    clearTimeout(this.visibilityTimeout);
    this.visibilityTimeout = undefined;
  }

  switch (document.visibilityState) {
  case 'hidden':
//    console.log('DOCUMENT HIDE');

    // Wait 10 seconds before peer disconnect.
    this.visibilityTimeout = setTimeout(function() {
      that.visibilityTimeout = undefined;
      O.gw.disconnect();
    }, 10 * 1000);
    return;
  case 'visible':
//    console.log('DOCUMENT SHOW');

    if (! O.gw.isConnected()) {
      O.gw.connect();
    }
    return;
  }
}
function visibilityChange(ev) {  // {{{2
  var that = this;

  if (this.visibilityTimeout) {
    clearTimeout(this.visibilityTimeout);
    this.visibilityTimeout = undefined;
  }

  switch (document.visibilityState) {
  case 'hidden':
//    console.log('DOCUMENT HIDE');

    // Wait 10 seconds before peer disconnect.
    this.visibilityTimeout = setTimeout(function() {
      that.visibilityTimeout = undefined;
      O.gw.disconnect();
    }, 10 * 1000);
    return;
  case 'visible':
//    console.log('DOCUMENT SHOW');

    if (! O.gw.isConnected()) {
      O.gw.connect();
    }
    return;
  }
}
Event handlers {{{1