Sha256: 492910c5394f2c2e41f1d8d677891d061c97132ce60be3db0f552650195b490d

Contents?: true

Size: 720 Bytes

Versions: 2

Compression:

Stored size: 720 Bytes

Contents

var page   = new WebPage(),
    width  = phantom.args[0],
    height = phantom.args[1],
    host   = phantom.args[2],
    port   = phantom.args[3],
    socket = phantom.args[4];

var Commands = {
  save_screenshot: function(path, options, callback) {
    page.render(path);
    callback(true);
  }
};

var ws = new WebSocket('ws://' + host + ':' + socket + '/');
ws.onmessage = function(message) {
  var args   = JSON.parse(message.data),
      method = args.shift();

  args.push(function(result) {
    ws.send(JSON.stringify([result]));
  });
  Commands[method].apply(Commands, args);
};

page.viewportSize = {width: parseInt(width, 10), height: parseInt(height, 10)};
page.open('http://' + host + ':' + port + '/');

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
terminus-0.6.0 lib/terminus/client/phantom.js
terminus-0.5.0 lib/terminus/client/phantom.js