<commit_before>/**
 * Created by pupboss on 4/11/16.
 */
'use strict';

var agent = require('../agent/dom_agent');
var cheerio = require('cheerio');

var analyse_room = function(user_id, password, buildingid, whichweek, week, target, callback) {

  target = target + '?aid=3&buildingid=' + buildingid + '&room=-1&whichweek=' + whichweek + '&week=' + week + '&Submit=%C8%B7+%B6%A8';
  agent.normal_agent(user_id, password, target, function (err, html) {
    if (err) {
      return callback(err, null);
    }
    var $ = cheerio.load(html);
    var room_arr = [];
    var total_status_arr = [];
    var info_temp = $('table[class="infolist_tab"]', html).eq(0);
    var class_temp = info_temp.children('tr');
    for (var h = 1; h < class_temp.length; h++) {
      room_arr.push(class_temp.eq(h).children('td').eq(0).text().trim());
    }

    var room_temp = $('table[cellspacing="1"]', html);
    for (var i = 0; i < room_temp.length; i++) {
      var room_status = room_temp.eq(i).children('tr').eq(1).children('td');
      var status_arr = [];
      for (var j = 0; j < room_status.length; j+=2) {
        status_arr.push(room_status.eq(j).text().trim() != '' ? '1' : '0');
      }
      total_status_arr.push(status_arr);
    }
    var dict_arr = [];
    for (var k = 0; k < room_arr.length; k++) {
      dict_arr.push({name: room_arr[k], status: total_status_arr[k]});
    }
    return callback(null, dict_arr);
  });
};

module.exports = analyse_room;<commit_msg>Improved message format.<commit_after>/**
 * Created by pupboss on 4/11/16.
 */
'use strict';

var agent = require('../agent/dom_agent');
var cheerio = require('cheerio');
var config = require('../config');

var analyse_room = function(user_id, password, buildingid, whichweek, week, target, callback) {

  target = target + '?aid=3&buildingid=' + buildingid + '&room=-1&whichweek=' + whichweek + '&week=' + week + '&Submit=%C8%B7+%B6%A8';
  agent.normal_agent(user_id, password, target, function (err, html) {
    if (err) {
      return callback(err, null);
    }
    var $ = cheerio.load(html);
    var room_arr = [];
    var total_status_arr = [];
    var info_temp = $('table[class="infolist_tab"]', html).eq(0);
    var class_temp = info_temp.children('tr');
    for (var h = 1; h < class_temp.length; h++) {
      room_arr.push(class_temp.eq(h).children('td').eq(0).text().trim());
    }

    var room_temp = $('table[cellspacing="1"]', html);
    for (var i = 0; i < room_temp.length; i++) {
      var room_status = room_temp.eq(i).children('tr').eq(1).children('td');
      var status_arr = [];
      for (var j = 0; j < room_status.length; j+=2) {
        status_arr.push(room_status.eq(j).text().trim() != '' ? '1' : '0');
      }
      total_status_arr.push(status_arr);
    }
    var dict_arr = [];
    for (var k = 0; k < room_arr.length; k++) {
      dict_arr.push({name: room_arr[k], status: total_status_arr[k]});
    }
    var dict = {};
    dict.firstWeekMondayAt = config.first_week_monday;
    dict.results = dict_arr;
    return callback(null, dict);
  });
};

module.exports = analyse_room;
{'fraction_non_alphanumeric': 0.19246997728010387, 'fraction_numerical': 0.014281077572216814, 'mean_word_length': 3.42816091954023, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, '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': '2096555', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1105, 'n_words': 228}