<commit_before>
'use strict';

// Area sequence visualization
var areavis;
// Facility sequence visualization
var facivis;

// Message volume chart (x2)
var volchart = [];

// Speed chart and distance chart (speed chart x2)
var spdchart = [];

// Table for showing facility percentage
var facitable;

// River chart for facility people flow and message flow
var pplflow, msgflow, msgperppl;

var vastcha15 = {
  /** @enum {number} */
  FilterTypes: {
    ALL: 0,
    SELECTS: 1,
    TARGETS: 2
  },
  /** @const */
  filterNames: [
    'All',
    'Selects',
    'Targets'
  ],

  MAX_QUERY_PER_SEC: 40,
  MIN_QUERY_GAP: 40, // FPS <= 25
  VOLUME_DELTA: 300, // +/- 5 min send/receive volume range

  serverAddr: 'http://localhost:3000/vastcha15',
  dayTimeRange: {
    Fri: [1402066816, 1402122395],
    Sat: [1402153208, 1402209324],
    Sun: [1402239611, 1402295113]
  },
  numPeople: {
    Fri: 3557,
    Sat: 6411,
    Sun: 7569
  },
  PLAY_TMSTEP: 0.1,
  PLAY_INTERVAL: 100,
  TIME_FORMAT: 'hh:mm:ss A',
  DATE_FORMAT: 'MMM D, YYYY',
  LABEL_LIST_HEIGHT_FULL: 300,


  blockUpdates_: false,

  /** stores the state */
  day: 'Fri',
  timePoint: 0, //1402067816,
  timeRange: [], //[1402066816, 1402069816],
  timeRangeD: [], //[1402067316, 1402069316],
  /** Global settings */
  // TODO(bowen): Some of them can be moved to view controller
  settings: {
    playSpd: 1,
    volumeSize: 1,
    filter: 0,
    seltarFull: false,
  },
  /** State of key press */
  keys: {
    ctrl: false,
    shift: false
  },
  lastTick: 0,
  // The queue only keeps the last query for each type
  queryQueue: {
    timerange_move: null,
    timeexact: null,
    timerange_comm: null,
    areaseq: null,
    faciseq: null,
    rangevol: null,
    volseq: null,
    faciperc: null,
    facisimilar: null,
    speedseq: null,
    distseq: null,
    msgflow: null,
    pplflow: null
  },
  /** For query frequency estimation */
  queryDuration: 0, // time since the last estimation point
  queryCount: 0, // queries sent since the last estimation point

  /** Whether timeline is playing */
  playing: false,

  /** @enum {string} */
  AreaColors: {
    0: '#fff3ca', // Kiddle Land
    1: '#edeaf1', // Entry Corridor
    2: '#dbeef4', // Tundra Land
    3: '#c4d59f', // Wet Land
    4: '#d99591'  // Coaster Alley
  },
  /**
   * Map an area code to its color.
   * @param  {string} areaId
   * @return {string} Color hex
   */
  getAreaColor: function(areaId) {
    return vastcha15.AreaColors[areaId];
  },
  getAreaName: function(areaId) {
    var name = meta.mapArea[areaId % meta.AREA_OFFSET];
    if (areaId >= meta.AREA_OFFSET) name += ' (Check-in)';
    return name;
  },

  /** @enum {string} */
  FacilityTypeColors: {
    'None': '#dddddd',
    'Thrill Rides': '#d62728',
    'Kiddie Rides': '#ff9896',
    'Rides for Everyone': '#ff7f0e',
    'Food': '#8ca252',
    'Restrooms': '#1f77b4',
    'Beer Gardens': '#e7ba52',
    'Shopping': '#c5b0d5',
    'Shows & Entertainment': '#9467bd',
    'Information & Assistance': '#7f7f7f'
  },
  /**
   * Map a facility id to its color.
   * @param   {string}   faciId
   * @return  {string}   Color hex
   */
  getFacilityColor: function(faciId) {
    var type = meta.facilitiesList[faciId].type;
    return vastcha15.FacilityTypeColors[type];
  },
  getFacilityTypeColor: function(type) {
    return vastcha15.FacilityTypeColors[type];
  },
  /**
   * Map a facility id to its name.
   * @param {string} faciId
   * @return {string} Facility name
   */
  getFacilityName: function(faciId) {
    var faci = meta.facilitiesList[faciId];
    if (faciId == 0) return 'None';
    return faci.id + ': ' + faci.name + ' (' + faci.type + ')';
  },

  /**
   * Compute time gap in milliseconds.
   * @param {boolean} set
   * @return {number}
   *   Return the gap between current time and last tick.
   *   If set is true, set last tick to current time.
   */
  tick: function(set) {
    var t = +(new Date());
    var lastt = this.lastTick;
    if (set) this.lastTick = t;
    return t - lastt;
  },

  /**
   * Set or get the block update state
   * @param   {boolean|undefined} state
   *   State to be set. If not given, returns the current state
   * @returns {boolean}
   *   Current state
   */
  blockUpdates: function(state) {
    if (state == undefined) return this.blockUpdates_;
    this.blockUpdates_ = state;
    return state;
  },

  /**
   * Vastcha15 entry function.
   * Called when the DOMs are ready
   * @this {vastcha15}
   */
  main: function() {
    meta.getData();
    mapvis.context();
    tracker.context();
    msgvis.context();

    facitable = new Table();
    facitable.context('Facility Percentage', '#table-panel');
    facitable.setColors(this.getFacilityTypeColor);

    areavis = new SequenceVisualizer();
    areavis.context('Area Sequence', '#area-panel');
    areavis.setColors(this.getAreaColor);
    areavis.setInfo(this.getAreaName);
    areavis.setUpdate(
      this.getAndRenderAreaSequences.bind(this)
    );
    // Disabled by default, not as useful as facivis.
    areavis.setShow(false);

    facivis = new SequenceVisualizer();
    facivis.context('Facility Sequence', '#facility-panel');
    facivis.setColors(this.getFacilityColor);
    facivis.setInfo(this.getFacilityName);
    facivis.setUpdate(
      this.getAndRenderFaciSequences.bind(this)
    );

    pplflow = new Chart();
    pplflow.setUpdate(
      this.getAndRenderPeopleFlow
    );
    pplflow.setGetColor(this.getFacilityColor);
    pplflow.setGetInfo(this.getFacilityName);
    pplflow.context('Facility People Flow', '#pplflow-panel');
    pplflow.setSize(1, true);
    pplflow.setFacility(true);

    msgflow = new Chart();
    msgflow.setUpdate(
      this.getAndRenderMessageFlow
    );
    msgflow.setGetColor(this.getFacilityColor);
    msgflow.setGetInfo(this.getFacilityName);
    // setTypeNames goes before context
    msgflow.setTypeNames(['send', 'receive', 'both']);
    msgflow.context('Facility Message Flow', '#msgflow-panel');
    msgflow.setSize(1, true);
    msgflow.setFacility(true);

    msgperppl = new Chart();
    msgperppl.setUpdate(
      this.getAndRenderMessagePerPeople
    );
    msgperppl.setGetColor(this.getFacilityColor);
    msgperppl.setGetInfo(this.getFacilityName);
    // setTypeNames goes before context
    msgperppl.setTypeNames(['send', 'receive', 'both']);
    msgperppl.context('Facility Message / Person Ratio', '#msgperppl-panel');
    msgperppl.setSize(1, true);
    msgperppl.setFacility(true);


    var volchartTypes = [
      'send Segment', 'receive Segment', 'both Segment',
      'send Sequence', 'receive Sequence', 'both Sequence'
    ];
    volchart[0] = new Chart();
    // setTypeNames, Goes before context
    volchart[0].setTypeNames(volchartTypes);
    volchart[0].setUpdate(
      this.getAndRenderVolumeChart
    );
    volchart[0].context('Message Volume 0', '#volchart-panel-0');


    volchart[1] = new Chart();
    // setTypeNames, Goes before context
    volchart[1].setTypeNames(volchartTypes);
    volchart[1].setUpdate(
      this.getAndRenderVolumeChart
    );
    volchart[1].context('Message Volume 1', '#volchart-panel-1');

    var spdchartTypes = [ 'speed', 'distance' ];
    spdchart[0] = new Chart();
    spdchart[0].setTypeNames(spdchartTypes);
    spdchart[0].setUpdate(
      this.getAndRenderSpeedChart
    );
    spdchart[0].context('Speed Chart 0', '#spdchart-panel-0');
    spdchart[0].setUpdateOnZoom(false);

    spdchart[1] = new Chart();
    spdchart[1].setTypeNames(spdchartTypes);
    spdchart[1].setUpdate(
      this.getAndRenderSpeedChart
    );
    spdchart[1].context('Speed Chart 1', '#spdchart-panel-1');
    spdchart[1].setUpdateOnZoom(false);


    //volchart[0].disableRiver();
    volchart[1].disableRiver();
    spdchart[0].disableRiver();
    spdchart[1].disableRiver();


    this.ui();

    // set initial range
    this.setDay(this.day);<commit_msg>disable msgflow river<commit_after>
'use strict';

// Area sequence visualization
var areavis;
// Facility sequence visualization
var facivis;

// Message volume chart (x2)
var volchart = [];

// Speed chart and distance chart (speed chart x2)
var spdchart = [];

// Table for showing facility percentage
var facitable;

// River chart for facility people flow and message flow
var pplflow, msgflow, msgperppl;

var vastcha15 = {
  /** @enum {number} */
  FilterTypes: {
    ALL: 0,
    SELECTS: 1,
    TARGETS: 2
  },
  /** @const */
  filterNames: [
    'All',
    'Selects',
    'Targets'
  ],

  MAX_QUERY_PER_SEC: 40,
  MIN_QUERY_GAP: 40, // FPS <= 25
  VOLUME_DELTA: 300, // +/- 5 min send/receive volume range

  serverAddr: 'http://localhost:3000/vastcha15',
  dayTimeRange: {
    Fri: [1402066816, 1402122395],
    Sat: [1402153208, 1402209324],
    Sun: [1402239611, 1402295113]
  },
  numPeople: {
    Fri: 3557,
    Sat: 6411,
    Sun: 7569
  },
  PLAY_TMSTEP: 0.1,
  PLAY_INTERVAL: 100,
  TIME_FORMAT: 'hh:mm:ss A',
  DATE_FORMAT: 'MMM D, YYYY',
  LABEL_LIST_HEIGHT_FULL: 300,


  blockUpdates_: false,

  /** stores the state */
  day: 'Fri',
  timePoint: 0, //1402067816,
  timeRange: [], //[1402066816, 1402069816],
  timeRangeD: [], //[1402067316, 1402069316],
  /** Global settings */
  // TODO(bowen): Some of them can be moved to view controller
  settings: {
    playSpd: 1,
    volumeSize: 1,
    filter: 0,
    seltarFull: false,
  },
  /** State of key press */
  keys: {
    ctrl: false,
    shift: false
  },
  lastTick: 0,
  // The queue only keeps the last query for each type
  queryQueue: {
    timerange_move: null,
    timeexact: null,
    timerange_comm: null,
    areaseq: null,
    faciseq: null,
    rangevol: null,
    volseq: null,
    faciperc: null,
    facisimilar: null,
    speedseq: null,
    distseq: null,
    msgflow: null,
    pplflow: null
  },
  /** For query frequency estimation */
  queryDuration: 0, // time since the last estimation point
  queryCount: 0, // queries sent since the last estimation point

  /** Whether timeline is playing */
  playing: false,

  /** @enum {string} */
  AreaColors: {
    0: '#fff3ca', // Kiddle Land
    1: '#edeaf1', // Entry Corridor
    2: '#dbeef4', // Tundra Land
    3: '#c4d59f', // Wet Land
    4: '#d99591'  // Coaster Alley
  },
  /**
   * Map an area code to its color.
   * @param  {string} areaId
   * @return {string} Color hex
   */
  getAreaColor: function(areaId) {
    return vastcha15.AreaColors[areaId];
  },
  getAreaName: function(areaId) {
    var name = meta.mapArea[areaId % meta.AREA_OFFSET];
    if (areaId >= meta.AREA_OFFSET) name += ' (Check-in)';
    return name;
  },

  /** @enum {string} */
  FacilityTypeColors: {
    'None': '#dddddd',
    'Thrill Rides': '#d62728',
    'Kiddie Rides': '#ff9896',
    'Rides for Everyone': '#ff7f0e',
    'Food': '#8ca252',
    'Restrooms': '#1f77b4',
    'Beer Gardens': '#e7ba52',
    'Shopping': '#c5b0d5',
    'Shows & Entertainment': '#9467bd',
    'Information & Assistance': '#7f7f7f'
  },
  /**
   * Map a facility id to its color.
   * @param   {string}   faciId
   * @return  {string}   Color hex
   */
  getFacilityColor: function(faciId) {
    var type = meta.facilitiesList[faciId].type;
    return vastcha15.FacilityTypeColors[type];
  },
  getFacilityTypeColor: function(type) {
    return vastcha15.FacilityTypeColors[type];
  },
  /**
   * Map a facility id to its name.
   * @param {string} faciId
   * @return {string} Facility name
   */
  getFacilityName: function(faciId) {
    var faci = meta.facilitiesList[faciId];
    if (faciId == 0) return 'None';
    return faci.id + ': ' + faci.name + ' (' + faci.type + ')';
  },

  /**
   * Compute time gap in milliseconds.
   * @param {boolean} set
   * @return {number}
   *   Return the gap between current time and last tick.
   *   If set is true, set last tick to current time.
   */
  tick: function(set) {
    var t = +(new Date());
    var lastt = this.lastTick;
    if (set) this.lastTick = t;
    return t - lastt;
  },

  /**
   * Set or get the block update state
   * @param   {boolean|undefined} state
   *   State to be set. If not given, returns the current state
   * @returns {boolean}
   *   Current state
   */
  blockUpdates: function(state) {
    if (state == undefined) return this.blockUpdates_;
    this.blockUpdates_ = state;
    return state;
  },

  /**
   * Vastcha15 entry function.
   * Called when the DOMs are ready
   * @this {vastcha15}
   */
  main: function() {
    meta.getData();
    mapvis.context();
    tracker.context();
    msgvis.context();

    facitable = new Table();
    facitable.context('Facility Percentage', '#table-panel');
    facitable.setColors(this.getFacilityTypeColor);

    areavis = new SequenceVisualizer();
    areavis.context('Area Sequence', '#area-panel');
    areavis.setColors(this.getAreaColor);
    areavis.setInfo(this.getAreaName);
    areavis.setUpdate(
      this.getAndRenderAreaSequences.bind(this)
    );
    // Disabled by default, not as useful as facivis.
    areavis.setShow(false);

    facivis = new SequenceVisualizer();
    facivis.context('Facility Sequence', '#facility-panel');
    facivis.setColors(this.getFacilityColor);
    facivis.setInfo(this.getFacilityName);
    facivis.setUpdate(
      this.getAndRenderFaciSequences.bind(this)
    );

    pplflow = new Chart();
    pplflow.setUpdate(
      this.getAndRenderPeopleFlow
    );
    pplflow.setGetColor(this.getFacilityColor);
    pplflow.setGetInfo(this.getFacilityName);
    pplflow.context('Facility People Flow', '#pplflow-panel');
    pplflow.setSize(1, true);
    pplflow.setFacility(true);

    msgflow = new Chart();
    msgflow.setUpdate(
      this.getAndRenderMessageFlow
    );
    msgflow.setGetColor(this.getFacilityColor);
    msgflow.setGetInfo(this.getFacilityName);
    // setTypeNames goes before context
    msgflow.setTypeNames(['send', 'receive', 'both']);
    msgflow.context('Facility Message Flow', '#msgflow-panel');
    msgflow.setSize(1, true);
    msgflow.setFacility(true);

    msgperppl = new Chart();
    msgperppl.setUpdate(
      this.getAndRenderMessagePerPeople
    );
    msgperppl.setGetColor(this.getFacilityColor);
    msgperppl.setGetInfo(this.getFacilityName);
    // setTypeNames goes before context
    msgperppl.setTypeNames(['send', 'receive', 'both']);
    msgperppl.context('Facility Message / Person Ratio', '#msgperppl-panel');
    msgperppl.setSize(1, true);
    msgperppl.setFacility(true);


    var volchartTypes = [
      'send Segment', 'receive Segment', 'both Segment',
      'send Sequence', 'receive Sequence', 'both Sequence'
    ];
    volchart[0] = new Chart();
    // setTypeNames, Goes before context
    volchart[0].setTypeNames(volchartTypes);
    volchart[0].setUpdate(
      this.getAndRenderVolumeChart
    );
    volchart[0].context('Message Volume 0', '#volchart-panel-0');


    volchart[1] = new Chart();
    // setTypeNames, Goes before context
    volchart[1].setTypeNames(volchartTypes);
    volchart[1].setUpdate(
      this.getAndRenderVolumeChart
    );
    volchart[1].context('Message Volume 1', '#volchart-panel-1');

    var spdchartTypes = [ 'speed', 'distance' ];
    spdchart[0] = new Chart();
    spdchart[0].setTypeNames(spdchartTypes);
    spdchart[0].setUpdate(
      this.getAndRenderSpeedChart
    );
    spdchart[0].context('Speed Chart 0', '#spdchart-panel-0');
    spdchart[0].setUpdateOnZoom(false);

    spdchart[1] = new Chart();
    spdchart[1].setTypeNames(spdchartTypes);
    spdchart[1].setUpdate(
      this.getAndRenderSpeedChart
    );
    spdchart[1].context('Speed Chart 1', '#spdchart-panel-1');
    spdchart[1].setUpdateOnZoom(false);


    volchart[0].disableRiver();
    volchart[1].disableRiver();
    spdchart[0].disableRiver();
    spdchart[1].disableRiver();


    this.ui();

    // set initial range
    this.setDay(this.day);
{'fraction_non_alphanumeric': 0.14009600808489137, 'fraction_numerical': 0.03183425972713492, 'mean_word_length': 3.1007511007511006, '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': '7603025', 'n_tokens_mistral': 5839, 'n_tokens_neox': 5452, 'n_words': 1255}