Notice: Undefined offset: 1 in /home/plusensd/steelhammer.com.ua/route.php on line 89
$(function() { var totalFileSize = 0; var dropboxSelector = ".dropbox"; $("body").on("dragenter", dropboxSelector, function(e) { e = e.originalEvent; e.stopPropagation(); e.preventDefault(); }).on("dragover", dropboxSelector, function(e) { e = e.originalEvent; e.stopPropagation(); e.preventDefault(); $(this).addClass("drag"); }).on("dragleave", dropboxSelector, function(e) { e = e.originalEvent; e.stopPropagation(); e.preventDefault(); $(this).removeClass("drag"); }).on("drop", dropboxSelector, function(e) { console.log(e); e = e.originalEvent; e.stopPropagation(); e.preventDefault(); $(this).removeClass("drag"); var dropbox = this; var files = e.dataTransfer.files; var count = e.dataTransfer.files.length; var fileContents = []; for (var i = 0, file; file = files[i]; i++) { var filetype = $(this).attr("filetype"); if (!filetype && !file.type.match(/image.*/) || filetype == "csv" && ["text/comma-separated-values", "text/csv", "application/csv", "application/excel", "application/vnd.ms-excel", "application/vnd.msexcel"].indexOf(file.type) == -1) { return undefined; // continue } var reader = new FileReader(); reader.onerror = function(e) { alert('Error code: ' + e.target.error.code); }; reader.onload = (function(aFile) { return function(evt) { fileContents.push(evt.target.result); count--; }; })(file); if (filetype == "csv") { reader.readAsText(file, $(dropbox).attr("encoding") || "UTF-8"); } else { reader.readAsDataURL(file); } } (function() { if (count > 0) { setTimeout(arguments.callee, 100); return; } $(dropbox).data("dropbox", fileContents).trigger("dropbox"); })(); return false; }); });