<commit_before>var SOURCE = Object.freeze({ PC: 'pc', MAC: 'mac', HDMI: 'hdmi', VGA: 'vga', DVD: 'dvd', BLURAY: 'bluray' });
var OUTPUT = Object.freeze({ PROJECTOR: 'projector', TELEVISION: 'television' });

/* DYNAMICALLY CREATE PROJECTORS AND SOURCES */
var sources = [SOURCE.PC, SOURCE.MAC];
var outs = { 1: { name: 'west', type: OUTPUT.PROJECTOR, source: undefined, on: false, vm: false },
             2: { name: 'east', type: OUTPUT.PROJECTOR, source: undefined, on: false, vm: false },
             3: { name: 'north', type: OUTPUT.TELEVISION, source: undefined, on: false, vm: false } };
var state = { active: 1};

var getSourceIcon = function(s) {
  switch(s) {
    case SOURCE.HDMI:
      return 'cf icon-hdmi';
      break;
    case SOURCE.VGA:
      return 'cf icon-vga';
      break;
    case SOURCE.MAC:
      return 'fa fa-apple';
      break;
    case SOURCE.PC:
      return 'fa fa-windows';
      break;
    case SOURCE.DVD:
      return 'cf icon-dvd';
      break;
    default:
      return 'cf icon-cmdr';
  }
}
var getOutputIcon = function(o) {
  switch(o) {
    case OUTPUT.PROJECTOR:
      return 'fa fa-video-camera';
      break;
    case OUTPUT.TELEVISION:
      return 'fa fa-desktop';
      break;
    default:
      return 'fa fa-video-camera';
  }
}
var addSources = function(sources) {
  var html = '';
  for (var s in sources) {
    if (sources.hasOwnProperty(s)) {
      html += '<div class="src" id="src-'+sources[s]+'">'+
                '<input type="radio" name="source">'+
                '<label>'+
                  '<div><i class="'+getSourceIcon(sources[s])+'"></i></div>'+
                  '<div>'+sources[s]+'</div>'+
                '</label>'+
              '</div>';
    }
  }
  $('#src-group').html(html);
}

addSources(sources);

var addOutputs = function(outputs) {
  var navHtml = '';
  var octHtml = '';
  var c = 1;
  for (var o in outputs) {
    if (outputs.hasOwnProperty(o)) {
      navHtml += '<div class="col-xs-4">'+
                '<div class="out-nav-item" data-tab="'+o+'">'+
                  '<i class="'+getOutputIcon(outputs[o].type)+'"></i>'+
                  '<span>'+outputs[o].name+'</span>'+
                '</div>'+
              '</div>';
      octHtml = '<div class="col-xs-6 out-info">'+
                  '<div class="transforms">'+
                    '<div class="cube p-front">'+
                      '<div class="face f-top">'+
                        '<i class="cf icon-cmdr fa-7x"></i>'+
                      '</div>'+
                      '<div class="face f-front">'+
                        '<i class="fa fa-apple fa-7x"></i>'+
                      '</div>'+
                      '<div class="face f-bottom">'+
                        '<i class="fa fa-windows fa-7x"></i>'+
                      '</div>'+
                      '<div class="face f-back">'+
                        '<i class="cf icon-vga fa-7x"></i>'+
                      '</div>'+
                      '<div class="face f-left">'+
                        '<i class="cf icon-hdmi fa-7x"></i>'+
                      '</div>'+
                      '<div class="face f-right">'+
                        '<i class="cf icon-dvd fa-7x"></i>'+
                      '</div>'+
                    '</div>'+
                  '</div>'+
                '</div>'+
                '<div class="col-xs-3">'+
                  '<div class="pwr-btn">'+
                    '<label>'+
                      '<i class="fa fa-power-off fa-3x"></i>'+
                    '</label>'+
                  '</div>'+
                '</div>'+
                '<div class="col-xs-3">'+
                  '<div class="vm-btn">'+
                    '<label>'+
                      '<span class="vm-txt">VIDEO MUTE</span>'+
                    '</label>'+
                  '</div>'+
                '</div>';
      $('#o-'+c).html(octHtml);
      console.log($('#o-'+c));
      c++;
    }
  }
  $('#out-nav').html(navHtml);
}

addOutputs(outs);

/* POWER BUTTON LISTENER */
$(document).on('click', '.pwr-btn > label', function() {
  var current = outs[state.active];
  var that = this;
  if (!$(this).hasClass('pwr-on')) {
    var blink = setInterval(warming, 500);
    window.setTimeout(clearInterval, 5000, blink);
    window.setTimeout(powerOn, 5000, that);
    current.on = true;
  }
  else {
    $(this).removeClass('pwr-on');
    console.log('power off for '+state.active);
    $('#o-'+state.active+' .cube').addClass('c-top');
    current.on = false;
  }
});
var warming = function() {
  var label = $('#o-'+state.active+' .pwr-btn > label');
  console.log();<commit_msg>add icons to cube dynamically. Limited to 6 sources, sources not linked to cube icons<commit_after>var SOURCE = Object.freeze({ PC: 'pc', MAC: 'mac', HDMI: 'hdmi', VGA: 'vga', DVD: 'dvd', BLURAY: 'bluray' });
var OUTPUT = Object.freeze({ PROJECTOR: 'projector', TELEVISION: 'television' });

/* DYNAMICALLY CREATE PROJECTORS AND SOURCES */
var sources = { 1: SOURCE.PC, 2: SOURCE.MAC, 3: SOURCE.HDMI,
                4: SOURCE.VGA, 5: SOURCE.DVD };

var outs = { 1: { name: 'west', type: OUTPUT.PROJECTOR, source: undefined, on: false, vm: false },
             2: { name: 'east', type: OUTPUT.PROJECTOR, source: undefined, on: false, vm: false },
             3: { name: 'north', type: OUTPUT.TELEVISION, source: undefined, on: false, vm: false } };

var state = { active: 1};

var getSourceIcon = function(s) {
  switch(s) {
    case SOURCE.HDMI:
      return 'cf icon-hdmi';
      break;
    case SOURCE.VGA:
      return 'cf icon-vga';
      break;
    case SOURCE.MAC:
      return 'fa fa-apple';
      break;
    case SOURCE.PC:
      return 'fa fa-windows';
      break;
    case SOURCE.DVD:
      return 'cf icon-dvd';
      break;
    default:
      return 'cf icon-cmdr';
  }
}
var getOutputIcon = function(o) {
  switch(o) {
    case OUTPUT.PROJECTOR:
      return 'fa fa-video-camera';
      break;
    case OUTPUT.TELEVISION:
      return 'fa fa-desktop';
      break;
    default:
      return 'fa fa-video-camera';
  }
}

var addOutputs = function(outputs) {
  var navHtml = '';
  var octHtml = '';
  var c = 1;
  for (var o in outputs) {
    if (outputs.hasOwnProperty(o)) {
      navHtml += '<div class="col-xs-4">'+
                '<div class="out-nav-item" data-tab="'+o+'">'+
                  '<i class="'+getOutputIcon(outputs[o].type)+'"></i>'+
                  '<span>'+outputs[o].name+'</span>'+
                '</div>'+
              '</div>';
      octHtml = '<div class="col-xs-6 out-info">'+
                  '<div class="transforms">'+
                    '<div class="cube p-front">'+
                      '<div class="face f-top" id="f-1">'+
                        '<i class="fa-7x"></i>'+
                      '</div>'+
                      '<div class="face f-front" id="f-2">'+
                        '<i class="fa-7x"></i>'+
                      '</div>'+
                      '<div class="face f-bottom" id="f-3">'+
                        '<i class="fa-7x"></i>'+
                      '</div>'+
                      '<div class="face f-back" id="f-4">'+
                        '<i class="fa-7x"></i>'+
                      '</div>'+
                      '<div class="face f-left" id="f-5">'+
                        '<i class="fa-7x"></i>'+
                      '</div>'+
                      '<div class="face f-right" id="f-6">'+
                        '<i class="fa-7x"></i>'+
                      '</div>'+
                    '</div>'+
                  '</div>'+
                '</div>'+
                '<div class="col-xs-3">'+
                  '<div class="pwr-btn">'+
                    '<label>'+
                      '<i class="fa fa-power-off fa-3x"></i>'+
                    '</label>'+
                  '</div>'+
                '</div>'+
                '<div class="col-xs-3">'+
                  '<div class="vm-btn">'+
                    '<label>'+
                      '<span class="vm-txt">VIDEO MUTE</span>'+
                    '</label>'+
                  '</div>'+
                '</div>';
      $('#o-'+c).html(octHtml);
      c++;
    }
  }
  $('#out-nav').html(navHtml);
}

addOutputs(outs);

var addSources = function(sources) {
  var html = '';
  var c = 2;
  $('#f-1 > i').addClass('cf icon-cmdr');
  for (var s in sources) {
    if (sources.hasOwnProperty(s)) {
      html += '<div class="src" id="src-'+sources[s]+'">'+
                '<input type="radio" name="source">'+
                '<label>'+
                  '<div><i class="'+getSourceIcon(sources[s])+'"></i></div>'+
                  '<div>'+sources[s]+'</div>'+
                '</label>'+
              '</div>';
      $('#f-'+c+' > i').addClass(getSourceIcon(sources[s]));
      console.log($('#f-'+c+' > i'));
      c++;
    }
  }
  $('#src-group').html(html);
}

addSources(sources);

/* POWER BUTTON LISTENER */
$(document).on('click', '.pwr-btn > label', function() {
  var current = outs[state.active];
  var that = this;
  if (!$(this).hasClass('pwr-on')) {
    var blink = setInterval(warming, 500);
    window.setTimeout(clearInterval, 5000, blink);
    window.setTimeout(powerOn, 5000, that);
    current.on = true;
  }
  else {
    $(this).removeClass('pwr-on');
    console.log('power off for '+state.active);
    $('#o-'+state.active+' .cube').addClass('c-top');
    current.on = false;
  }
});
var warming = function() {
  var label = $('#o-'+state.active+' .pwr-btn > label');
  console.log();
{'fraction_non_alphanumeric': 0.2007164682330629, 'fraction_numerical': 0.007164682330629017, 'mean_word_length': 1.6491766675969857, 'pattern_counts': {'":': 0, '<': 133, '<?xml version=': 0, '>': 140, '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': '1136363', 'n_tokens_mistral': 3140, 'n_tokens_neox': 3106, 'n_words': 659}