Sha256: 6294d892e82ad57da9e8900ab47294dc42c2bc7d0a3b2188e6732aaa2d9fb495

Contents?: true

Size: 1.39 KB

Versions: 32

Compression:

Stored size: 1.39 KB

Contents

var page = require('webpage').create();  
var system = require('system');
var resources = [];

/*
page.onError = function(msg, trace) {

  var msgStack = ['ERROR: ' + msg];

  if (trace && trace.length) {
    msgStack.push('TRACE:');
    trace.forEach(function(t) {
      msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function +'")' : ''));
    });
  }

  console.error(msgStack.join('\n'));

};
*/

page.onResourceReceived = function(response) {
  if (response.stage === 'end') {
    resources.push(response.status);
  }
};

page.open(system.args[1], function(status) {  
  // console.log('Status: ' + status);
  
  if ( status !== 'success' ) {
    console.log('Unable to load the address!');
    phantom.exit();
  } else if ( resources.indexOf(404) != -1 ) {
    console.log('Resources include 404.');
    phantom.exit();
  } else if ( resources.indexOf(500) != -1 ) {
    console.log('Resources include 500.');
    phantom.exit();
  } else {
    window.setTimeout(function () {
      w = 64;
      h = 64;
      
      if ( !!system.args[3] && !!system.args[4] ) {
        w = system.args[3];
        h = system.args[4];
      }
      
      // console.log('Viewport Size: ' + w + 'x' + h);
      
      page.viewportSize = {width: w, height: h};
      page.render(system.args[2]);
      phantom.exit();
    }, 1000); // Change timeout as required to allow sufficient time 
  }
});

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
cosgrove-0.0.4.4 support/js/screencap.js
cosgrove-0.0.4.3 support/js/screencap.js
cosgrove-0.0.4.2 support/js/screencap.js
cosgrove-0.0.4.1 support/js/screencap.js
cosgrove-0.0.4.0 support/js/screencap.js
cosgrove-0.0.4.0pre3 support/js/screencap.js
cosgrove-0.0.4.0pre2 support/js/screencap.js
cosgrove-0.0.4.0pre1 support/js/screencap.js
cosgrove-0.0.3.5 support/js/screencap.js
cosgrove-0.0.3.4 support/js/screencap.js
cosgrove-0.0.3.3 support/js/screencap.js
cosgrove-0.0.3.2 support/js/screencap.js
cosgrove-0.0.3.1 support/js/screencap.js
cosgrove-0.0.3rc1 support/js/screencap.js
cosgrove-0.0.2 support/js/screencap.js
cosgrove-0.0.1 support/js/screencap.js
cosgrove-0.0.1rc16 support/js/screencap.js
cosgrove-0.0.1rc15 support/js/screencap.js
cosgrove-0.0.1rc14 support/js/screencap.js
cosgrove-0.0.1rc13 support/js/screencap.js