<commit_before>/*global $,cyberDojo*/

var cyberDojo = (function(cd, $) {
  "use strict";

  cd.setupTrafficLightOpensHistoryDialogHandlers = function(lights,showRevert) {
	lights.click(function() {
	  var light = $(this);
	  var id = light.data('id');
	  var avatarName = light.data('avatar-name');
	  var wasTag = light.data('was-tag');
	  var nowTag = light.data('now-tag');
	  var maxTag = light.data('max-tag');
	  cd.dialog_history(id,avatarName,wasTag,nowTag,maxTag,light,showRevert);
	});
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - -

  cd.setupTrafficLightCountOpensCurrentCode = function(bulbs,showRevert) {
    $.each(bulbs, function(_,bulb) {
	  var count = $(bulb);
	  var id = count.data('id');
	  var avatarName = count.data('avatar-name');
	  var wasTag = count.data('bulb-count');
	  var nowTag = count.data('bulb-count');
	  var maxTag = count.data('bulb-count');
	  var colour  = count.data('current-colour');
	  // animals don't appear on dashboard until they have 2+ traffic-lights
	  // so pluralization of traffic-lights is ok
	  var toolTip = avatarName + ' has ' + wasTag + ' traffic-lights' +
	    ' and is at ' + colour + '.' +
		' Click to review ' + avatarName + "'s current code.";
	  count.attr('title', toolTip);
	  count.click(function() {
	    cd.dialog_history(id,avatarName,wasTag,nowTag,maxTag,count,showRevert);
	  });
	});
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - -

  cd.dialog_history = function(id, avatarName,
							   wasTag, nowTag, maxTag, // 1-based
							   domNodeSource, showRevert) {
	// Arguably, the history dialog would be better as it own
	// history page. That would help google searchability and
	// analytics etc. I use a dialog because of revert.
	// When revert is clicked it has to be for a specific
	// animal and it has to revert their code! As a dialog,
	// the revert has access to animal's code on the page
	// from which the dialog opened.

	var setWaitCursor = function() {
	  domNodeSource.css('cursor', 'wait');
	};
	var setPointerCursor = function() {
	  domNodeSource.css('cursor', 'pointer');
	};

	var minTag = 1;
	var tagGap = nowTag - wasTag; // currently always 1
	var currentFilename = '';
	var visibleFiles = undefined;

    //- - - - - - - - - - - - - - - - - - - - - - - - - -
	// Was-Now-Tag Controls	(on title-bar)
    //- - - - - - - - - - - - - - - - - - - - - - - - - -

	var makeTagCheckbox = function() {
      return '' +
	    '<input type="checkbox"' +
            ' class="regular-checkbox"' +
            ' id="was-tag-checkbox"/>' +
          '<label for="was-tag-checkbox"></label>';
	};

	var makeNowTagControl = function() {
	  //var light = data.lights[nowTag-1];
	  return '' +
	    '<table class="tag-control">' +
		  '<tr>' +
			cd.td('<input' +
				        ' type="text"' +
				          ' id="now-tag-number"' +
				 //' data-colour="' + light.colour + '"' +
				 //      ' value="' + nowTag + '"' +
				 ' />') +
		  '</tr>' +
		 '</table>';
	};

    var makeDiffTagControl = function() {
	  return '' +
	    '<table id="diff-tag-control">' +
		  '<tr>' +
		    cd.td(makeTagCheckbox()) +
		    cd.td(makeNowTagControl()) +
			cd.td('<div id="traffic-lights"></div>') +
		  '</tr>' +
		'</table>';
    };

  	var makeTrafficLight = function(light) {
      return '' +
		"<img src='/images/" + 'traffic_light_' + light.colour + ".png'" +
		     "width='10'" +
		     "height='32'/>";
	};

	//- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	var titleBar = function() {
	  return $('#ui-dialog-title-history-dialog');
	};

	var wasTagCheckBox = function() {
	  return $('#was-tag-checkbox', titleBar());
	};

	var nowTagNumber = function() {
	  return $('#now-tag-number', titleBar());
	};

	var trafficLights = function() {
	  return $('#traffic-lights', titleBar());
	};

	var resetTagControls = function(data) {

	  var html = '';
	  $.each(data.lights, function(_,light) {
		html += makeTrafficLight(light);
	  });

	  trafficLights().html(x);

	  nowTagNumber().val(nowTag);

	  wasTagCheckBox()
		.attr('checked', wasTag != nowTag)
		.unbind('click')<commit_msg>tag number displayed in red/amber/green again<commit_after>/*global $,cyberDojo*/

var cyberDojo = (function(cd, $) {
  "use strict";

  cd.setupTrafficLightOpensHistoryDialogHandlers = function(lights,showRevert) {
	lights.click(function() {
	  var light = $(this);
	  var id = light.data('id');
	  var avatarName = light.data('avatar-name');
	  var wasTag = light.data('was-tag');
	  var nowTag = light.data('now-tag');
	  var maxTag = light.data('max-tag');
	  cd.dialog_history(id,avatarName,wasTag,nowTag,maxTag,light,showRevert);
	});
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - -

  cd.setupTrafficLightCountOpensCurrentCode = function(bulbs,showRevert) {
    $.each(bulbs, function(_,bulb) {
	  var count = $(bulb);
	  var id = count.data('id');
	  var avatarName = count.data('avatar-name');
	  var wasTag = count.data('bulb-count');
	  var nowTag = count.data('bulb-count');
	  var maxTag = count.data('bulb-count');
	  var colour  = count.data('current-colour');
	  // animals don't appear on dashboard until they have 2+ traffic-lights
	  // so pluralization of traffic-lights is ok
	  var toolTip = avatarName + ' has ' + wasTag + ' traffic-lights' +
	    ' and is at ' + colour + '.' +
		' Click to review ' + avatarName + "'s current code.";
	  count.attr('title', toolTip);
	  count.click(function() {
	    cd.dialog_history(id,avatarName,wasTag,nowTag,maxTag,count,showRevert);
	  });
	});
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - -

  cd.dialog_history = function(id, avatarName,
							   wasTag, nowTag, maxTag, // 1-based
							   domNodeSource, showRevert) {
	// Arguably, the history dialog would be better as it own
	// history page. That would help google searchability and
	// analytics etc. I use a dialog because of revert.
	// When revert is clicked it has to be for a specific
	// animal and it has to revert their code! As a dialog,
	// the revert has access to animal's code on the page
	// from which the dialog opened.

	var setWaitCursor = function() {
	  domNodeSource.css('cursor', 'wait');
	};
	var setPointerCursor = function() {
	  domNodeSource.css('cursor', 'pointer');
	};

	var minTag = 1;
	var tagGap = nowTag - wasTag; // currently always 1
	var currentFilename = '';
	var visibleFiles = undefined;

    //- - - - - - - - - - - - - - - - - - - - - - - - - -
	// Was-Now-Tag Controls	(on title-bar)
    //- - - - - - - - - - - - - - - - - - - - - - - - - -

	var makeTagCheckbox = function() {
      return '' +
	    '<input type="checkbox"' +
            ' class="regular-checkbox"' +
            ' id="was-tag-checkbox"/>' +
          '<label for="was-tag-checkbox"></label>';
	};

	var makeNowTagControl = function() {
	  return '' +
	    '<table class="tag-control">' +
		  '<tr>' +
			cd.td('<input' +
				        ' type="text"' +
				          ' id="now-tag-number"' +
				 ' />') +
		  '</tr>' +
		 '</table>';
	};

    var makeDiffTagControl = function() {
	  return '' +
	    '<table id="diff-tag-control">' +
		  '<tr>' +
		    cd.td(makeTagCheckbox()) +
		    cd.td(makeNowTagControl()) +
			cd.td('<div id="traffic-lights"></div>') +
		  '</tr>' +
		'</table>';
    };

  	var makeTrafficLight = function(light) {
      return '' +
		"<img src='/images/" + 'traffic_light_' + light.colour + ".png'" +
		     "width='10'" +
		     "height='32'/>";
	};

	//- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	var titleBar = function() {
	  return $('#ui-dialog-title-history-dialog');
	};

	var wasTagCheckBox = function() {
	  return $('#was-tag-checkbox', titleBar());
	};

	var nowTagNumber = function() {
	  return $('#now-tag-number', titleBar());
	};

	var trafficLights = function() {
	  return $('#traffic-lights', titleBar());
	};

	var resetTagControls = function(data) {

	  var html = '';
	  $.each(data.lights, function(_,light) {
		html += makeTrafficLight(light);
	  });

	  trafficLights().html(html);

	  nowTagNumber()
		.val(nowTag)
		.attr('data-colour', data.lights[nowTag-1].colour);

	  wasTagCheckBox()
		.attr('checked', wasTag != nowTag)
		.unbind('click')
{'fraction_non_alphanumeric': 0.19660934260275642, 'fraction_numerical': 0.0021953896816684962, 'mean_word_length': 2.3510420923579893, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6641234', 'n_tokens_mistral': 3081, 'n_tokens_neox': 2803, 'n_words': 570}