<commit_before>/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
 * Use of this source code is governed by a AGPL3 license that
 * can be found in the LICENSE file. */
/* global define, Handlebars, isWin, _  */
define(function(require, exports, module) {
  "use strict";

  console.log("Loading UI for perspectiveDefault");

  var TSCORE = require("tscore");
  var TMB_SIZES = ["200px", "300px", "100px"];

  var MONTH = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

  /*var supportedFileTypeThumnailing = [
    "jpg", "jpeg", "png", "gif", "pdf", "svg", "webp", "bmp", 
    "zip", "epub", "docx", "pptx", "pptm", "potx", "potm", 
    "ppxs", "ppsm", "sldx", "sldm", "dotx",  "dotm", "xlsx", 
    "xlsm", "xlst", "odp", "odg", "ods", "odt" 
  ];*/

  function ExtUI(extID) {
    this.extensionID = extID;
    this.viewContainer = $("#" + this.extensionID + "Container").empty();

    this.currentGrouping = ""; // tagchain, day, month, year
    this.thumbEnabled = false;
    this.currentTmbSize = 0;
    this.searchResults = undefined;
    this.supportedGroupings = [];

    this.supportedGroupings.push({
      "title": "Day",
      "key": "day"
    });
    this.supportedGroupings.push({
      "title": "Month",
      "key": "month"
    });
    this.supportedGroupings.push({
      "title": "Year",
      "key": "year"
    });

    for (var i = 0; i < TSCORE.Config.Settings.tagGroups.length; i++) {
      // Exclude smart tags and calculated tags 
      if (TSCORE.Config.Settings.tagGroups[i].key !== "SMR" &&
        TSCORE.Config.Settings.tagGroups[i].key !== "CTG") {
        this.supportedGroupings.push({
          "title": TSCORE.Config.Settings.tagGroups[i].title,
          "key": TSCORE.Config.Settings.tagGroups[i].key
        });
      }
    }
  }

  var fileTileTmpl = Handlebars.compile(
    '<div title="{{filepath}}" filepath="{{filepath}}" class="fileTile" style="background-image: url(\'{{thumbPath}}\')">' +
      '<button class="btn btn-link fileTileSelector" filepath="{{filepath}}"><i class="fa {{selected}} fa-lg"></i> <span class="fileExtTile">{{fileext}}</span></button>' +
      '<div class="tagsInFileTile">' +
      '{{#each tags}}' +
        '<button class="btn btn-sm tagButton fileTagsTile" tag="{{tag}}" filepath="{{filepath}}" style="{{style}}">{{tag}}<!-- <span class="fa fa-ellipsis-v"></span--></button>' +
      '{{/each}}' +
      '</div>' +
      '<div class="titleInFileTile">{{title}}</div>' +
    '</div>'
    );

  var mainLayoutTemplate = Handlebars.compile(
    '<div class="extMainContent accordion">' +
      '{{#each groups}}' +
      '<div class="accordion-group disableTextSelection" style="width: 100%; border: 0px #aaa solid;">' +
        '{{#if ../moreThanOneGroup}}' +
        '<div class="accordion-heading btn-group" style="width:100%; margin: 0px; border-bottom: solid 1px #eee; background-color: #f0f0f0;">' +
          '<button class="btn btn-link groupTitle" data-toggle="collapse" data-target="#{{../../id}}SortingButtons{{@index}}">' +
            '<i class="fa fa-minus-square">&nbsp;</i>' +
          '</button>' +
          '<span class="btn btn-link groupTitle" id="{{../../id}}HeaderTitle{{@index}}" style="margin-left: 0px; padding-left: 0px;"></span>' +
        '</div>' +
        '{{/if}}' +
        '<div class="accordion-body collapse in" id="{{../id}}SortingButtons{{@index}}" style="margin: 0px 0px 0px 3px; border: 0px;">' +
          '<div class="accordion-inner tileContainer" id="{{../id}}GroupContent{{@index}}"></div>' +
        '</div>' +
      '</div>' +
      '{{else}}' +
      '<p style="margin: 5px;">No files found</p>' +
      '{{/each}}' +
    '</div>'
  );

  ExtUI.prototype.createFileTile = function(title, filePath, fileExt, fileTags, isSelected, metaObj) {
    var tmbPath;
    if (isCordova || isWeb) {
      tmbPath = filePath;
    } else {
      tmbPath = "file:///" + filePath;
    }
    var metaObj = metaObj || {thumbnailPath : ""};
    var context = {
      filepath: filePath,
      tmbpath: tmbPath,
      fileext: fileExt,
      title: title,
      tags: [],
      selected: isSelected ? "fa-check-square" : "fa-square-o",
      thumbPath: metaObj.thumbnailPath
    };
    
    if (fileTags.length > 0) {
      var tagString = "" + fileTags;
      var tags = tagString.split(",");<commit_msg>encode path<commit_after>/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
 * Use of this source code is governed by a AGPL3 license that
 * can be found in the LICENSE file. */
/* global define, Handlebars, isWin, _  */
define(function(require, exports, module) {
  "use strict";

  console.log("Loading UI for perspectiveDefault");

  var TSCORE = require("tscore");
  var TMB_SIZES = ["200px", "300px", "100px"];

  var MONTH = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

  /*var supportedFileTypeThumnailing = [
    "jpg", "jpeg", "png", "gif", "pdf", "svg", "webp", "bmp", 
    "zip", "epub", "docx", "pptx", "pptm", "potx", "potm", 
    "ppxs", "ppsm", "sldx", "sldm", "dotx",  "dotm", "xlsx", 
    "xlsm", "xlst", "odp", "odg", "ods", "odt" 
  ];*/

  function ExtUI(extID) {
    this.extensionID = extID;
    this.viewContainer = $("#" + this.extensionID + "Container").empty();

    this.currentGrouping = ""; // tagchain, day, month, year
    this.thumbEnabled = false;
    this.currentTmbSize = 0;
    this.searchResults = undefined;
    this.supportedGroupings = [];

    this.supportedGroupings.push({
      "title": "Day",
      "key": "day"
    });
    this.supportedGroupings.push({
      "title": "Month",
      "key": "month"
    });
    this.supportedGroupings.push({
      "title": "Year",
      "key": "year"
    });

    for (var i = 0; i < TSCORE.Config.Settings.tagGroups.length; i++) {
      // Exclude smart tags and calculated tags 
      if (TSCORE.Config.Settings.tagGroups[i].key !== "SMR" &&
        TSCORE.Config.Settings.tagGroups[i].key !== "CTG") {
        this.supportedGroupings.push({
          "title": TSCORE.Config.Settings.tagGroups[i].title,
          "key": TSCORE.Config.Settings.tagGroups[i].key
        });
      }
    }
  }

  var fileTileTmpl = Handlebars.compile(
    '<div title="{{filepath}}" filepath="{{filepath}}" class="fileTile" style="background-image: url(\'{{thumbPath}}\')">' +
      '<button class="btn btn-link fileTileSelector" filepath="{{filepath}}"><i class="fa {{selected}} fa-lg"></i> <span class="fileExtTile">{{fileext}}</span></button>' +
      '<div class="tagsInFileTile">' +
      '{{#each tags}}' +
        '<button class="btn btn-sm tagButton fileTagsTile" tag="{{tag}}" filepath="{{filepath}}" style="{{style}}">{{tag}}<!-- <span class="fa fa-ellipsis-v"></span--></button>' +
      '{{/each}}' +
      '</div>' +
      '<div class="titleInFileTile">{{title}}</div>' +
    '</div>'
    );

  var mainLayoutTemplate = Handlebars.compile(
    '<div class="extMainContent accordion">' +
      '{{#each groups}}' +
      '<div class="accordion-group disableTextSelection" style="width: 100%; border: 0px #aaa solid;">' +
        '{{#if ../moreThanOneGroup}}' +
        '<div class="accordion-heading btn-group" style="width:100%; margin: 0px; border-bottom: solid 1px #eee; background-color: #f0f0f0;">' +
          '<button class="btn btn-link groupTitle" data-toggle="collapse" data-target="#{{../../id}}SortingButtons{{@index}}">' +
            '<i class="fa fa-minus-square">&nbsp;</i>' +
          '</button>' +
          '<span class="btn btn-link groupTitle" id="{{../../id}}HeaderTitle{{@index}}" style="margin-left: 0px; padding-left: 0px;"></span>' +
        '</div>' +
        '{{/if}}' +
        '<div class="accordion-body collapse in" id="{{../id}}SortingButtons{{@index}}" style="margin: 0px 0px 0px 3px; border: 0px;">' +
          '<div class="accordion-inner tileContainer" id="{{../id}}GroupContent{{@index}}"></div>' +
        '</div>' +
      '</div>' +
      '{{else}}' +
      '<p style="margin: 5px;">No files found</p>' +
      '{{/each}}' +
    '</div>'
  );

  ExtUI.prototype.createFileTile = function(title, filePath, fileExt, fileTags, isSelected, metaObj) {
    var tmbPath;
    if (isCordova || isWeb) {
      tmbPath = filePath;
    } else {
      tmbPath = "file:///" + filePath;
    }
    var metaObj = metaObj || {thumbnailPath : ""};
    var context = {
      filepath: filePath,
      tmbpath: tmbPath,
      fileext: fileExt,
      title: title,
      tags: [],
      selected: isSelected ? "fa-check-square" : "fa-square-o",
      thumbPath: encodeURI(metaObj.thumbnailPath)
    };
    
    if (fileTags.length > 0) {
      var tagString = "" + fileTags;
      var tags = tagString.split(",");
{'fraction_non_alphanumeric': 0.20910432512203428, 'fraction_numerical': 0.009308661596094904, 'mean_word_length': 3.1129785247432307, 'pattern_counts': {'":': 16, '<': 75, '<?xml version=': 0, '>': 73, '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': '5616566', 'n_tokens_mistral': 3052, 'n_tokens_neox': 2931, 'n_words': 632}