Sha256: 0869338241f290c4a9c99ddef423d54a3bab3eb0b53a882a64638950d750e05e

Contents?: true

Size: 910 Bytes

Versions: 9

Compression:

Stored size: 910 Bytes

Contents

var page   = require('webpage').create();
var fs     = require('fs');
var system = require('system');

page.onConsoleMessage = function(msg) {
  system.stdout.write(msg);
};

var opal_code = fs.read('/dev/stdin');

page.onCallback = function(data) {
  switch (data[0]) {
  case 'exit':
    var status = data[1] || 0;
    phantom.exit(status);
  case 'stdout':
    system.stdout.write(data[1] || '');
    break;
  case 'stderr':
    system.stderr.write(data[1] || '');
    break;
  default:
    console.error('Unknown callback data: ', data);
  }
};

page.content =  '<!doctype html>'+
                '<html>'+
                '  <head><meta charset="utf-8"/></head>'+
                "  <body><script>//<![CDATA[\n"+
                opal_code+
                "  //]]></script>"+
                '  <script>callPhantom(["exit", 0]);</script></body>\n'+
                '  </body>'+
                '</html>';

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
opal-0.7.2 lib/opal/cli_runners/phantom.js
opal-0.7.1 lib/opal/cli_runners/phantom.js
opal-0.7.0 lib/opal/cli_runners/phantom.js
opal-0.7.0.rc1 lib/opal/cli_runners/phantom.js
opal-0.7.0.beta3 lib/opal/cli_runners/phantom.js
opal-0.7.0.beta2 lib/opal/cli_runners/phantom.js
opal-cj-0.7.0.beta2 lib/opal/cli_runners/phantom.js
opal-cj-0.7.0.beta1 lib/opal/cli_runners/phantom.js
opal-0.7.0.beta1 lib/opal/cli_runners/phantom.js