<commit_before>
(function() {
  'use strict';

  var initialBoothList = initial_booth_data;  // From jsonp!
  var public_key = null;

  var app = {
    hasRequestPending: false,
    isLoading: true,
    booths: [],
    spinner: document.querySelector('.loader'),
    cardTemplate: document.querySelector('.cardTemplate'),
    container: document.querySelector('.main'),
    unlockDialog: document.querySelector('.unlock-dialog'),
    checkDialog: document.querySelector('.check-dialog'),
    videoSelect: document.querySelector('select#videoSource'),
    unlockNote: document.getElementById('unlockNote'),
    gotVideoSourcesDone: false,
    videoWidth: 640,
    videoHeight: 480,
    videoSizeSaved: false,
    publicKey: {
      n: "C4E3F7212602E1E396C0B6623CF11D26204ACE3E7D26685E037AD2507DCE82FC\n28F2D5F8A67FC3AFAB89A6D818D1F4C28CFA548418BD9F8E7426789A67E73E41",
      e: "10001",
    }
  };


  /*****************************************************************************
   *
   * Event listeners for UI elements
   *
   ****************************************************************************/

  document.getElementById('butRefresh').addEventListener('click', function() {
    // Refresh all of the booths
    app.updateBooths(true);
  });

  navigator.getUserMedia  = navigator.getUserMedia ||
                            navigator.webkitGetUserMedia ||
                            navigator.mozGetUserMedia ||
                            navigator.msGetUserMedia;
  var dialogBody = document.getElementById('qrDialogBody');
  var cRect = dialogBody.getClientRects()[0];
  var videoElement = document.getElementById('qrVideo');
  videoElement.style.maxWidth = cRect.width + 'px';
  videoElement.style.maxHeight = cRect.height + 'px';

  app.startVideoStream = function() {
    if (window.stream && window.stream.getVideoTracks)
        window.stream.getVideoTracks()[0].stop();
    app.videoSizeSaved = false;
    // Initiate a QR Code snapshot process
    if (navigator.getUserMedia) {
      var selectedVideoSource = app.videoSelect.value;
      var videoOption = {video: true, audio: false};
      if (!!selectedVideoSource) {
        videoOption.video = {
          optional: [{
            sourceId: selectedVideoSource
          }]
        };
      }
      navigator.getUserMedia(videoOption,
        function(stream) {  // Success
          document.getElementById('qrVideo').addEventListener('playing', app.saveVideoSize, false);
          window.stream = stream;  // Making available to console
          videoElement.src = window.URL.createObjectURL(stream);
        },
        function(e) {   // Error
          app.unlockNote.textContent = 'Video Rejected.';
          document.getElementById('qrVideo').setAttribute('hidden', true);
          document.getElementById('uploadContainer').removeAttribute('hidden');
        }
      );
    } else {
      app.unlockNote.textContent = 'Cannot access video with this browser. Try Chrome or use your native camera app and upload the photo of the QR code.';
      document.getElementById('qrVideo').setAttribute('hidden', true);
      document.getElementById('uploadContainer').removeAttribute('hidden');
    }
  }

  function handleFileSelect(evt) {
    var files = evt.target.files;
    for (var i = 0, f; f = files[i]; i++) {
      if (!f.type.match('image.*')) {
        continue;
      }
      var reader = new FileReader();
      reader.onload = (function(theFile) {
        return function(e) {
          var img = new Image();
          img.src = e.target.result;
          // img.complete?

          // var canvasContainer = document.getElementById('canvasContainer');<commit_msg>Even simpler user advice<commit_after>
(function() {
  'use strict';

  var initialBoothList = initial_booth_data;  // From jsonp!
  var public_key = null;

  var app = {
    hasRequestPending: false,
    isLoading: true,
    booths: [],
    spinner: document.querySelector('.loader'),
    cardTemplate: document.querySelector('.cardTemplate'),
    container: document.querySelector('.main'),
    unlockDialog: document.querySelector('.unlock-dialog'),
    checkDialog: document.querySelector('.check-dialog'),
    videoSelect: document.querySelector('select#videoSource'),
    unlockNote: document.getElementById('unlockNote'),
    gotVideoSourcesDone: false,
    videoWidth: 640,
    videoHeight: 480,
    videoSizeSaved: false,
    publicKey: {
      n: "C4E3F7212602E1E396C0B6623CF11D26204ACE3E7D26685E037AD2507DCE82FC\n28F2D5F8A67FC3AFAB89A6D818D1F4C28CFA548418BD9F8E7426789A67E73E41",
      e: "10001",
    }
  };


  /*****************************************************************************
   *
   * Event listeners for UI elements
   *
   ****************************************************************************/

  document.getElementById('butRefresh').addEventListener('click', function() {
    // Refresh all of the booths
    app.updateBooths(true);
  });

  navigator.getUserMedia  = navigator.getUserMedia ||
                            navigator.webkitGetUserMedia ||
                            navigator.mozGetUserMedia ||
                            navigator.msGetUserMedia;
  var dialogBody = document.getElementById('qrDialogBody');
  var cRect = dialogBody.getClientRects()[0];
  var videoElement = document.getElementById('qrVideo');
  videoElement.style.maxWidth = cRect.width + 'px';
  videoElement.style.maxHeight = cRect.height + 'px';

  app.startVideoStream = function() {
    if (window.stream && window.stream.getVideoTracks)
        window.stream.getVideoTracks()[0].stop();
    app.videoSizeSaved = false;
    // Initiate a QR Code snapshot process
    if (navigator.getUserMedia) {
      var selectedVideoSource = app.videoSelect.value;
      var videoOption = {video: true, audio: false};
      if (!!selectedVideoSource) {
        videoOption.video = {
          optional: [{
            sourceId: selectedVideoSource
          }]
        };
      }
      navigator.getUserMedia(videoOption,
        function(stream) {  // Success
          document.getElementById('qrVideo').addEventListener('playing', app.saveVideoSize, false);
          window.stream = stream;  // Making available to console
          videoElement.src = window.URL.createObjectURL(stream);
        },
        function(e) {   // Error
          app.unlockNote.textContent = 'Video Rejected.';
          document.getElementById('qrVideo').setAttribute('hidden', true);
          document.getElementById('uploadContainer').removeAttribute('hidden');
        }
      );
    } else {
      app.unlockNote.textContent = 'Try Chrome or use your native camera app, then upload the QR code photo here.';
      document.getElementById('qrVideo').setAttribute('hidden', true);
      document.getElementById('uploadContainer').removeAttribute('hidden');
    }
  }

  function handleFileSelect(evt) {
    var files = evt.target.files;
    for (var i = 0, f; f = files[i]; i++) {
      if (!f.type.match('image.*')) {
        continue;
      }
      var reader = new FileReader();
      reader.onload = (function(theFile) {
        return function(e) {
          var img = new Image();
          img.src = e.target.result;
          // img.complete?

          // var canvasContainer = document.getElementById('canvasContainer');
{'fraction_non_alphanumeric': 0.15684123937482863, 'fraction_numerical': 0.025774609267891418, 'mean_word_length': 3.0303867403314917, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1249805', 'n_tokens_mistral': 2119, 'n_tokens_neox': 1992, 'n_words': 382}