<commit_before>/* jshint jquery: true */
'use strict';

const IpcRenderer = require('electron').ipcRenderer;
const Shell = require('electron').shell;
var Remote = require('remote');
var Dialog = Remote.require('dialog');
window.$ = window.jQuery = require('jquery');

var foldersToAdd = [];

document.ondragover = document.ondrop = function(e) {
  e.preventDefault();
  return false;
};

function addFolder(path) {
	if(path) {
		foldersToAdd.push(path);

		var folderElementHtml = $('<li/>');

		folderElementHtml
			.attr('class', 'valid-path icon-teal')
			.html(path);

		$('#folders-to-add-list').prepend(folderElementHtml);
	}
}

function makeDoubleClickHandler() {
    return function() {
        console.log('plop');
        Shell.showItemInFolder(this.innerHTML + '/' + '.');
    };
}

IpcRenderer.on('data-folders', function(event, folders) {
	var arrayLength = folders.length;
	var foldersListHtml = $('#folders-list').empty();

	if(arrayLength > 0) {
		for (var i = 0; i < arrayLength; i++) {
			var folderElementHtml = $('<li/>');

			if(folders[i].exists) {
				folderElementHtml
                    .attr('class', 'valid-path icon-teal')
                    .dblclick(makeDoubleClickHandler());
			} else {
				folderElementHtml
                    .attr('class', 'invalid-path icon-red');
			}

			folderElementHtml
				.html(folders[i].path);
				// .prepend(iconHtml);
			$('.loader').hide();
			foldersListHtml.prepend(folderElementHtml);
		}
	} else {
		foldersListHtml.after($('<p/>').html('Error'));
	}
});

$('.choose-folder').on('click', function() {
	var folderPath = Dialog.showOpenDialog({ properties: [ 'openDirectory']});

	if(folderPath.length > 0){
		addFolder(folderPath[0]);
	}
});

$('.folder-input button').on('click', function() {
	IpcRenderer.send('add-folders', foldersToAdd);
	$('.loader').show();
	$('#folders-to-add-list').empty();
	return false;
});

$('#holder').on("drop", function(event) {
    event.preventDefault();
	event.stopPropagation();
    console.log('success');
	var folderPath = event.originalEvent.dataTransfer.files[0].path;

	addFolder(folderPath);
});

$('.refresh-list').on("click", function() {
	IpcRenderer.send('refresh-folders', true);
	$('.loader').show();
});<commit_msg>[DOC] Replace all tabs by spaces in index.js<commit_after>/* jshint jquery: true */
'use strict';

const IpcRenderer = require('electron').ipcRenderer;
const Shell = require('electron').shell;
var Remote = require('remote');
var Dialog = Remote.require('dialog');
window.$ = window.jQuery = require('jquery');

var foldersToAdd = [];

document.ondragover = document.ondrop = function(e) {
    e.preventDefault();
    return false;
};

function addFolder(path) {
    if(path) {
        foldersToAdd.push(path);

        var folderElementHtml = $('<li/>');

        folderElementHtml
            .attr('class', 'valid-path icon-teal')
            .html(path);

        $('#folders-to-add-list').prepend(folderElementHtml);
    }
}

function makeDoubleClickHandler() {
    return function() {
        console.log('plop');
        Shell.showItemInFolder(this.innerHTML + '/' + '.');
    };
}

IpcRenderer.on('data-folders', function(event, folders) {
    var arrayLength = folders.length;
    var foldersListHtml = $('#folders-list').empty();

    if(arrayLength > 0) {
        for (var i = 0; i < arrayLength; i++) {
            var folderElementHtml = $('<li/>');

            if(folders[i].exists) {
                folderElementHtml
                    .attr('class', 'valid-path icon-teal')
                    .dblclick(makeDoubleClickHandler());
            } else {
                folderElementHtml
                    .attr('class', 'invalid-path icon-red');
            }

            folderElementHtml
                .html(folders[i].path);
                // .prepend(iconHtml);
            $('.loader').hide();
            foldersListHtml.prepend(folderElementHtml);
        }
    } else {
        foldersListHtml.after($('<p/>').html('Error'));
    }
});

$('.choose-folder').on('click', function() {
    var folderPath = Dialog.showOpenDialog({ properties: [ 'openDirectory']});

    if(folderPath.length > 0){
        addFolder(folderPath[0]);
    }
});

$('.folder-input button').on('click', function() {
    IpcRenderer.send('add-folders', foldersToAdd);
    $('.loader').show();
    $('#folders-to-add-list').empty();
    return false;
});

$('#holder').on("drop", function(event) {
    event.preventDefault();
    event.stopPropagation();
    console.log('success');
    var folderPath = event.originalEvent.dataTransfer.files[0].path;

    addFolder(folderPath);
});

$('.refresh-list').on("click", function() {
    IpcRenderer.send('refresh-folders', true);
    $('.loader').show();
});
{'fraction_non_alphanumeric': 0.18912080961416824, 'fraction_numerical': 0.002108370229812355, 'mean_word_length': 3.1360069747166524, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '66018', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1460, 'n_words': 247}