<commit_before>//Future: FileReader Not Supported! Show classic upload form.
//if (typeof window.FileReader === 'undefined') {
//    
//} else {

var docuElement = $(document.documentElement);

docuElement.on('dragover', function (event) {
    event.preventDefault();
    event.stopPropagation();
});

docuElement.on('dragenter', function (event) {
    event.preventDefault();
    event.stopPropagation();

    $('#drop-overlay').addClass('state-over');
});

docuElement.on('dragleave', function (event) {
    event.preventDefault();
    event.stopPropagation();

    $('#drop-overlay').removeClass('state-over');
});

docuElement.on('dragend', function (event) {
    event.preventDefault();
    event.stopPropagation();

    $('#drop-overlay').removeClass('state-over');
});


function createHyperIcon(fileName, image, id) {
    var shortName = fileName.substring(0, 30);

    var imageElement = $('<div>', {
        class: 'hyperIcon',
        style: 'background-image: url("' + createHyperThumb(image) + '");',
        title: 'Click to view, Alt+Click to view the image only.',
        click: function (event) {
            event.preventDefault();
            var location = "/" + id;

            if (!event.altKey) {
                location = "/view" + location;
            }

            if (event.ctrlKey) {               
                window.open(window.location.origin + location);
            } else {
                window.location.href = location;
            }
        }
    });

    for (var i = 0, len = shortName.length; i < len; i++) {
        $('<p>', {
            text: shortName[i],
            style: 'transform: rotate(' + (-60 + i * 12) + 'deg);'
        }).appendTo(imageElement);
    }


    imageElement.appendTo($('#dropzone'));
}

function createHyperThumb(b64) {
    var image = new Image();
    image.src = b64;

    var ratio = 200 / Math.min(image.width, image.height);

    if (ratio > 1) {
        return b64; //Small image, don't resize.
    }

    var canvas = document.createElement('canvas');
    var ctx = canvas.getContext('2d');

    canvas.width = image.width * ratio;
    canvas.height = image.height * ratio;<commit_msg>Middle button opens up a new window as well, prevent right button.<commit_after>//Future: FileReader Not Supported! Show classic upload form.
//if (typeof window.FileReader === 'undefined') {
//    
//} else {

var docuElement = $(document.documentElement);

docuElement.on('dragover', function (event) {
    event.preventDefault();
    event.stopPropagation();
});

docuElement.on('dragenter', function (event) {
    event.preventDefault();
    event.stopPropagation();

    $('#drop-overlay').addClass('state-over');
});

docuElement.on('dragleave', function (event) {
    event.preventDefault();
    event.stopPropagation();

    $('#drop-overlay').removeClass('state-over');
});

docuElement.on('dragend', function (event) {
    event.preventDefault();
    event.stopPropagation();

    $('#drop-overlay').removeClass('state-over');
});


function createHyperIcon(fileName, image, id) {
    var shortName = fileName.substring(0, 30);

    var imageElement = $('<div>', {
        class: 'hyperIcon',
        style: 'background-image: url("' + createHyperThumb(image) + '");',
        title: 'Click to view, Alt+Click to view the image only.',
        click: function (event) {
            event.preventDefault();

            //0: left
            //1: middle            
            if (event.button !== 0 && event.button !== 1)
                return;

            var location = "/" + id;

            if (!event.altKey) {
                location = "/view" + location;
            }

            if (event.ctrlKey || event.button === 1) {
                window.open(window.location.origin + location);
            } else {
                window.location.href = location;
            }
        },
        contextmenu: function () {
            return false;
        }
    });

    for (var i = 0, len = shortName.length; i < len; i++) {
        $('<p>', {
            text: shortName[i],
            style: 'transform: rotate(' + (-60 + i * 12) + 'deg);'
        }).appendTo(imageElement);
    }

    imageElement.appendTo($('#dropzone'));
}

function createHyperThumb(b64) {
    var image = new Image();
    image.src = b64;

    var ratio = 200 / Math.min(image.width, image.height);

    if (ratio > 1) {
        return b64; //Small image, don't resize.
    }

    var canvas = document.createElement('canvas');
    var ctx = canvas.getContext('2d');

    canvas.width = image.width * ratio;
    canvas.height = image.height * ratio;
{'fraction_non_alphanumeric': 0.162080173347779, 'fraction_numerical': 0.009317443120260022, 'mean_word_length': 2.3497822931785195, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7021231', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1341, 'n_words': 306}