<commit_before>{% extends "layout.html" %}

{% block head %}
<link rel="stylesheet" href="/static/css/fileinput.min.css">
<script src="/static/js/fileinput.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    $("#filesUpload").fileinput({
      uploadUrl: "http://{{ api_loc }}/api/v1/tasks/create/",
      browseOnZoneClick: true,
      allowedPreviewTypes: [],
      showUpload: false,
      browseLabel: "Select File(s) …",
      removeLabel: "Clear",
      removeClass: "btn btn-danger",
      msgUploadEnd: "Submitted to scanner",
      previewTemplates: {
          other: '<div class="file-preview-frame krajee-default kv-preview-thumb foobar" id="{previewId}" data-fileindex="{fileindex}" data-template="{template}" title="{caption}">\n' +
          '   <div class="file-thumbnail-footer">\n' +
          '    <div class="file-preview-other">' +
          '    <span class="file-other-icon"><i class="glyphicon glyphicon-file"></i></span>' +
          '    </div>' +
          '        {footer}\n' +
          '    </div>\n' +
          '</div>\n' + 
          '<div class="collapse text-center metadata-group" data-target="{previewId}">\n' +
          {% for metadata in metadata_fields %}
          '<div class="form-group-sm">\n' +
          {% set field = metadata|replace(" ", "-")|replace(".", "-")|replace("#", "-")%}
          '    <label for="{previewId}-{{field}}" class="col-md-2 control-label">{{metadata}}</label>\n' +
          '    <div class="input-group col-md-10">\n' +
                  '<input type="text" class="form-control" id="{previewId}-{{field}}" name="{previewId}-{{field}}"></input>\n' +
          '    </div>\n' +
          '    </div>\n' +
          {% endfor %}
          '</div>\n',
      },
      layoutTemplates: {
        main1: '{preview}\n' +
          '<div class="kv-upload-progress hide"></div>\n' +
          '<div class="input-group {class}">\n' +
          '    {caption}\n' +
          '    <div class="input-group-btn">\n' +
          '        {remove}\n' +
          '        {cancel}\n' +
          '        {upload}\n' +
          '        {browse}\n' +
          '    </div>\n' +
          '</div>',
        actions: '<div class="file-actions">\n' +
          '    <div class="file-footer-buttons">\n' +
          '        {upload} {delete} {other}' +
          '        <button type="button" class="add-metadata btn btn-xs btn-default" title="Add metadata">\n' +
          '            <i class="glyphicon glyphicon-th-list"></i>\n' +
          '        </button>\n' + 
          '    </div>\n' +
          '    {drag}\n' +
          '    <div class="file-upload-indicator" title="{indicatorTitle}">{indicator}</div>\n' +
          '    <div class="clearfix"></div>\n' +
          '</div>',
        footer: '<div class="file-footer-caption" title="{caption}">{caption}<br>{size}</div>\n' +
          '        {progress} {actions}',
      },
      previewFileIcon: '',
      fileActionSettings: {
        removeIcon: '<i class="glyphicon glyphicon-trash"></i>',
        removeClass: 'btn btn-xs btn-danger',
        uploadIcon: '<i class="glyphicon glyphicon-upload"></i>',
        uploadClass: 'btn btn-xs btn-primary',
      },
      uploadExtraData: function (previewId, index) {
        var obj = {};
        if ($('#archive-analyze').is(':checked')) {
          obj['archive-analyze'] = 'true';
          if ($('#archive-password').val() !== '') {
            obj['archive-password'] = $('#archive-password').val();
          }
        }
        // Send metadata along with the file
        $('.metadata-group[data-target=' + previewId + '] .form-group-sm').each(function() {
          var key = $(this).children('label').first().html();
          var val = $(this).find('input').first().val();
          obj[key] = val;
        });
        return obj;
      }
    });

    $("#filesUpload").on('fileuploaded', function(event, data, previewId, index) {
      // Hide buttons after upload
      $('#' + previewId + ' .file-footer-buttons').css('visibility', 'hidden');

      // Disable metadata fields after upload
      $('.metadata-group[data-target=' + previewId + '] input').each(function (index, element) {
        $(element).attr('readonly', true);
      })

      // Click on preview box to go straight to the task/report
      // If file was a zip, it will go to the first file
      $('#' + previewId).css('cursor', 'pointer');
      $('#' + previewId).click(function() {
        window.location = "report/" + data.response.Message.task_ids[0];
      })
    });

    $('#filesUpload').on('fileloaded', function(event, file, previewId, index, reader) {
      // Singularize/pluralize submit button text
      if ($("#filesUpload").fileinput('getFilesCount') > 1) {
        $('#btn-scan').html('Scan them!');
      } else {
        $('#btn-scan').html('Scan it!');<commit_msg>Auto scroll to latest added file on Scan page<commit_after>{% extends "layout.html" %}

{% block head %}
<link rel="stylesheet" href="/static/css/fileinput.min.css">
<script src="/static/js/fileinput.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    $("#filesUpload").fileinput({
      uploadUrl: "http://{{ api_loc }}/api/v1/tasks/create/",
      browseOnZoneClick: true,
      allowedPreviewTypes: [],
      showUpload: false,
      browseLabel: "Select File(s) …",
      removeLabel: "Clear",
      removeClass: "btn btn-danger",
      msgUploadEnd: "Submitted to scanner",
      previewTemplates: {
          other: '<div class="file-preview-frame krajee-default kv-preview-thumb foobar" id="{previewId}" data-fileindex="{fileindex}" data-template="{template}" title="{caption}">\n' +
          '   <div class="file-thumbnail-footer">\n' +
          '    <div class="file-preview-other">' +
          '    <span class="file-other-icon"><i class="glyphicon glyphicon-file"></i></span>' +
          '    </div>' +
          '        {footer}\n' +
          '    </div>\n' +
          '</div>\n' + 
          '<div class="collapse text-center metadata-group" data-target="{previewId}">\n' +
          {% for metadata in metadata_fields %}
          '<div class="form-group-sm">\n' +
          {% set field = metadata|replace(" ", "-")|replace(".", "-")|replace("#", "-")%}
          '    <label for="{previewId}-{{field}}" class="col-md-2 control-label">{{metadata}}</label>\n' +
          '    <div class="input-group col-md-10">\n' +
                  '<input type="text" class="form-control" id="{previewId}-{{field}}" name="{previewId}-{{field}}"></input>\n' +
          '    </div>\n' +
          '    </div>\n' +
          {% endfor %}
          '</div>\n',
      },
      layoutTemplates: {
        main1: '{preview}\n' +
          '<div class="kv-upload-progress hide"></div>\n' +
          '<div class="input-group {class}">\n' +
          '    {caption}\n' +
          '    <div class="input-group-btn">\n' +
          '        {remove}\n' +
          '        {cancel}\n' +
          '        {upload}\n' +
          '        {browse}\n' +
          '    </div>\n' +
          '</div>',
        actions: '<div class="file-actions">\n' +
          '    <div class="file-footer-buttons">\n' +
          '        {upload} {delete} {other}' +
          '        <button type="button" class="add-metadata btn btn-xs btn-default" title="Add metadata">\n' +
          '            <i class="glyphicon glyphicon-th-list"></i>\n' +
          '        </button>\n' + 
          '    </div>\n' +
          '    {drag}\n' +
          '    <div class="file-upload-indicator" title="{indicatorTitle}">{indicator}</div>\n' +
          '    <div class="clearfix"></div>\n' +
          '</div>',
        footer: '<div class="file-footer-caption" title="{caption}">{caption}<br>{size}</div>\n' +
          '        {progress} {actions}',
      },
      previewFileIcon: '',
      fileActionSettings: {
        removeIcon: '<i class="glyphicon glyphicon-trash"></i>',
        removeClass: 'btn btn-xs btn-danger',
        uploadIcon: '<i class="glyphicon glyphicon-upload"></i>',
        uploadClass: 'btn btn-xs btn-primary',
      },
      uploadExtraData: function (previewId, index) {
        var obj = {};
        if ($('#archive-analyze').is(':checked')) {
          obj['archive-analyze'] = 'true';
          if ($('#archive-password').val() !== '') {
            obj['archive-password'] = $('#archive-password').val();
          }
        }
        // Send metadata along with the file
        $('.metadata-group[data-target=' + previewId + '] .form-group-sm').each(function() {
          var key = $(this).children('label').first().html();
          var val = $(this).find('input').first().val();
          obj[key] = val;
        });
        return obj;
      }
    });

    $("#filesUpload").on('fileuploaded', function(event, data, previewId, index) {
      // Hide buttons after upload
      $('#' + previewId + ' .file-footer-buttons').css('visibility', 'hidden');

      // Disable metadata fields after upload
      $('.metadata-group[data-target=' + previewId + '] input').each(function (index, element) {
        $(element).attr('readonly', true);
      })

      // Click on preview box to go straight to the task/report
      // If file was a zip, it will go to the first file
      $('#' + previewId).css('cursor', 'pointer');
      $('#' + previewId).click(function() {
        window.location = "report/" + data.response.Message.task_ids[0];
      })
    });

    $('#filesUpload').on('fileloaded', function(event, file, previewId, index, reader) {
      // Scroll to file
	  window.scrollTo(0, $("#" + previewId).offset().top);

      // Singularize/pluralize submit button text
      if ($("#filesUpload").fileinput('getFilesCount') > 1) {
        $('#btn-scan').html('Scan them!');
      } else {
        $('#btn-scan').html('Scan it!');
{'fraction_non_alphanumeric': 0.2064215537324015, 'fraction_numerical': 0.0015192950470981465, 'mean_word_length': 2.1606914212548016, 'pattern_counts': {'":': 0, '<': 101, '<?xml version=': 0, '>': 103, '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': '3186931', 'n_tokens_mistral': 3044, 'n_tokens_neox': 2987, 'n_words': 540}