<commit_before>exports.name = "checkline";

exports.run = function(options, sink){
	var phantom = require('phantom'),
  util = require("util"),
		checklist = {},
		_page,
    time,
    content;

var report = {
  time: 0,
  htmlContent: ""
};

("speed-checker").split(" ").forEach(function (p) {
             checklist[p] = require("./checks/" + p);
  });

/* have to find an other way to do that (less callback) : sink (event.Emitter) ? async Q promise*/

  var getPage = function(){
    phantom.create(
      function(ph){
        return ph.createPage(
          function(page){
           page.set('viewportSize', {width:options.widthView,height:options.heightView});
           page.set('clipRect', {top:0,left:0,width:options.widthView,height:options.heightView});
            return page.open(options.url,
              function(status){
                console.log("opening " +options.url, status);
                page.render('public/screenshots/screenshot' + '.png');
                page.get('content', function(result){
                  report.htmlContent = result;
                });
                sink.emit("stepdone");
                return page.evaluate(
                  function(){
                    return document;
                  }, 
                  function(result){
                    _page = result;
                    if(options.url === 1){
                      console.log('Usage: loadspeed.js <some URL>');
                      phantom.exit();
                    }
                    report.time = Date.now();
                    page.open(options.url, 
                      function(status){
                        if (status !== 'success') {
                          console.log('FAIL to load the address');
                          sink.emit("stepdone");

                        } 
                        else{
                          report.time = Date.now() - report.time;
                          console.log('Loading time ' + report.time + ' msec');
                          sink.emit("stepdone");
                          sink.emit("getPage end");
                        }
                        return ph.exit();
                      }
                    );
                  }
                );
              }
            );
          }
        );
      }
    );
  }

  var makeReport = function () {

  }

  getPage();

  //make report here
  sink.on("getPage end", function(){
    sink.emit("getReport end", report);<commit_msg>added getting http header in console<commit_after>exports.name = "checkline";

exports.run = function(options, sink){
	var phantom = require('phantom'),
  util = require("util"),
		checklist = {},
		_page,
    time,
    content;

var report = {
  time: 0,
  htmlContent: ""
};

("speed-checker").split(" ").forEach(function (p) {
             checklist[p] = require("./checks/" + p);
  });

/* have to find an other way to do that (less callback) : sink (event.Emitter) ? async Q promise*/

  var getPage = function(){
    phantom.create(
      function(ph){
        return ph.createPage(
          function(page){
           page.set('viewportSize', {width:options.widthView,height:options.heightView});
           page.set('clipRect', {top:0,left:0,width:options.widthView,height:options.heightView});
           page.set('onResourceReceived', function(response) {
  console.log('Response (#' + response.id + ', stage "' + response.stage + '"): ' + JSON.stringify(response));
});
            return page.open(options.url,
              function(status){
                console.log("opening " +options.url, status);
                page.render('public/screenshots/screenshot' + '.png');
                page.get('content', function(result){
                  report.htmlContent = result;
                });
                sink.emit("stepdone");
                return page.evaluate(
                  function(){

                    return document;
                  }, 
                  function(result){
                    _page = result;
                    if(options.url === 1){
                      console.log('Usage: loadspeed.js <some URL>');
                      phantom.exit();
                    }
                    report.time = Date.now();
                    page.open(options.url, 
                      function(status){
                        if (status !== 'success') {
                          console.log('FAIL to load the address');
                          sink.emit("stepdone");

                        } 
                        else{
                          report.time = Date.now() - report.time;
                          console.log('Loading time ' + report.time + ' msec');
                          sink.emit("stepdone");
                          sink.emit("getPage end");
                        }
                        return ph.exit();
                      }
                    );
                  }
                );
              }
            );
          }
        );
      }
    );
  }


  var makeReport = function () {

  }

  getPage();

  //make report here
  sink.on("getPage end", function(){
    sink.emit("getReport end", report);
{'fraction_non_alphanumeric': 0.13184701133961177, 'fraction_numerical': 0.001537574476263694, 'mean_word_length': 1.2655637788419678, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1950723', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1280, 'n_words': 251}