{"size": 926, "ext": "js", "max_stars_repo_path": "web-common/src/FileEvents.js", "max_stars_repo_name": "jhrcek/plutus", "max_stars_repo_stars_event_min_datetime": "2021-02-18T02:21:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-31T20:20:05.000Z", "max_issues_repo_path": "web-common/src/FileEvents.js", "max_issues_repo_name": "jhrcek/plutus", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "web-common/src/FileEvents.js", "max_forks_repo_name": "jhrcek/plutus", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.5853658537, "max_line_length": 63, "alphanum_fraction": 0.5043196544}
/*global FileReader, exports*/
'use strict';

exports.preventDefault = function(e) {
    return function() {
        e.preventDefault();
    };
};

exports._readFileFromDragEvent = function(onLoad, onError, e) {
    var i, item, files, file, reader;

    files = [];
    if (e.dataTransfer.items) {
        for (i = 0; i < e.dataTransfer.items.length; i++) {
            item = e.dataTransfer.items[i];
            if (item.kind === 'file') {
                files.push(item.getAsFile());
            }
        }
    }

    file = files[0];
    if (file) {
        reader = new FileReader();
        reader.onloadend = function (loadEvent) {
            if (reader.error) {
                onError(reader.error)();
            } else {
                onLoad(loadEvent.target.result)();
            }
        };

        reader.readAsText(file);
    }

    return function canceler (error) {
        reader.abort();
    };
};
