/* jshint browser:true, jquery:true */ $(function() { var uploadInput = $('#upload-input'), uploadBtn = $('#upload-btn'), uploadFiles = $('#upload-filelist') var btnContent = "" if (!$.hasFileAPI()) { $('#no-file-api').show() uploadBtn.hide() } uploadBtn.cabinet(uploadInput) uploadBtn.on('dragenter', function(e) { if (this === e.target) { $(this).addClass('drop') btnContent = $(this).html() $(this).html('Drop it here~') } }) uploadBtn.on('drop', function(e) { $(this).trigger('dragleave') }) uploadBtn.on('dragleave', function(e) { node = e.target do { if (node === this) { $(this).removeClass('drop') $(this).html(btnContent) break } } while (node = node.parentNode) }) var MAX_SIZE = (function(node) { var max = node.attr('data-max-size') || '120MiB' var num = parseInt(/([0-9,]+).*/.exec(max)[1].replace(',', '')) var unit = /(?:([KMGTPEZY])(i)?B|([BKMGTPEZY]))/.exec(max) || ["B", "", ""] var oneUnit = Math.pow( (unit[2] === "i" ? 1024 : 1000), 'BKMGTPEZY'.indexOf(unit[1]) ) return num * oneUnit })(uploadInput) var createRow = function(filename, size, extra) { var rowItem = $('