<commit_before>/* global $ appOptions dashboard options */

/**
 * Pixelation widget for visualizing image encoding.
 *
 * Original code written by <NAME>.
 */

var MAX_SIZE = 400;

var pixel_format, pixel_data, canvas, main_ctx, widthText, widthRange, heightText, heightRange, bitsPerPixelText, bitsPerPixelRange, image_w, image_h, sqSize;

function pixelationInit() {
  pixel_format = document.querySelector('#pixel_format');
  pixel_data = document.querySelector("#pixel_data");
  canvas = document.querySelector("#canvas");
  main_ctx = canvas.getContext("2d");

  widthText = document.getElementById("width");
  widthRange = document.getElementById("widthRange");
  heightText = document.getElementById("height");
  heightRange = document.getElementById("heightRange");
  bitsPerPixelText = document.getElementById("bitsPerPixel");
  bitsPerPixelRange = document.getElementById("bitsPerPixelSlider");
  startOver = document.getElementById("start_over");

  if (appOptions.readonlyWorkspace) {
    // Disable the parts of the UI that would modify the pixelation data.

    pixel_data.setAttribute("readonly", "true");

    widthText.setAttribute("disabled", "true");
    widthRange.setAttribute("disabled", "true");
    heightText.setAttribute("disabled", "true");
    heightRange.setAttribute("disabled", "true");
    bitsPerPixelText.setAttribute("disabled", "true");
    bitsPerPixelRange.setAttribute("disabled", "true");
    startOver.setAttribute("disabled", "true");
  }

  customizeStyles();
  initProjects();
}

function customizeStyles() {
  if (!window.options) {
    // Default is version 3 (all features enabled).
    window.options = {version: '3'};
  }
  if (options.version === '1') {
    $('.hide_on_v1').hide();

    // The layout is fundamentally different in version 1 than it is in other versions.
    // Rearrange the DOM so that the visualization column sits at the top left.
    var visualizationColumn = document.getElementById('visualizationColumn');
    var visualizationEditorHeader = document.getElementById('visualizationEditorHeader');
    visualizationColumn.parentNode.insertBefore(visualizationColumn, visualizationEditorHeader);
  } else if (options.version === '2') {
    $('.hide_on_v2').hide();
    $('#height, #width').prop('readonly', true);
  }
  if (options.hex) {<commit_msg>Temporary CSP pixelation fix for hex mode<commit_after>/* global $ appOptions dashboard options */

/**
 * Pixelation widget for visualizing image encoding.
 *
 * Original code written by <NAME>.
 */

var MAX_SIZE = 400;

var pixel_format, pixel_data, canvas, main_ctx, widthText, widthRange, heightText, heightRange, bitsPerPixelText, bitsPerPixelRange, image_w, image_h, sqSize;

function pixelationInit() {
  pixel_format = document.querySelector('#pixel_format');
  pixel_data = document.querySelector("#pixel_data");
  canvas = document.querySelector("#canvas");
  main_ctx = canvas.getContext("2d");

  widthText = document.getElementById("width");
  widthRange = document.getElementById("widthRange");
  heightText = document.getElementById("height");
  heightRange = document.getElementById("heightRange");
  bitsPerPixelText = document.getElementById("bitsPerPixel");
  bitsPerPixelRange = document.getElementById("bitsPerPixelSlider");
  startOver = document.getElementById("start_over");

  if (appOptions.readonlyWorkspace) {
    // Disable the parts of the UI that would modify the pixelation data.

    pixel_data.setAttribute("readonly", "true");

    widthText.setAttribute("disabled", "true");
    widthRange.setAttribute("disabled", "true");
    heightText.setAttribute("disabled", "true");
    heightRange.setAttribute("disabled", "true");
    bitsPerPixelText.setAttribute("disabled", "true");
    bitsPerPixelRange.setAttribute("disabled", "true");
    startOver.setAttribute("disabled", "true");
  }

  customizeStyles();
  initProjects();
}

function customizeStyles() {
  if (!window.options) {
    // Default is version 3 (all features enabled).
    window.options = {version: '3'};
  }
  if (options.version === '1') {
    $('.hide_on_v1').hide();

    // The layout is fundamentally different in version 1 than it is in other versions.
    // Rearrange the DOM so that the visualization column sits at the top left.
    var visualizationColumn = document.getElementById('visualizationColumn');
    var visualizationEditorHeader = document.getElementById('visualizationEditorHeader');
    visualizationColumn.parentNode.insertBefore(visualizationColumn, visualizationEditorHeader);
  } else if (options.version === '2') {
    $('.hide_on_v2').hide();
    $('#height, #width').prop('readonly', true);
  }
  if (options.hex === "true" || options.hex === true) {
{'fraction_non_alphanumeric': 0.13490545995326111, 'fraction_numerical': 0.004673889951136605, 'mean_word_length': 5.14621409921671, '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': '4879830', 'n_tokens_mistral': 1282, 'n_tokens_neox': 1267, 'n_words': 313}