DnD


  

  
demo.dndHandler1 = null;
demo.initDnD = function() {
  var opt1 = {
    onloadstart: demo.onFileLoadStart,
    onprogress: demo.onFileLoadProg,
    //onload: demo.onFileLoad,
    onabort: demo.onAbortLoadFile,
    onerror: demo.onFileLoadError,
  };
  demo.dndHandler1 = util.addDndHandler('#dnd-area1', demo.onDnd1, opt1);

  var opt2 = {
    mode: 'bin'
  };
  util.addDndHandler('#dnd-area2', demo.onDnd2, opt2);
};

demo.onDnd1 = function(data) {
  $el('#dnd-area1').innerHTML = data;
};

demo.onFileLoadProg = function(e, loaded, total, pct) {
  log('LOADING... ' + loaded + ' / ' + total + ' bytes (' + pct + '%)');
};

demo.onFileLoadStart = function() {
  log('onFileLoadStart');
};

demo,onFileLoadProg = function(e) {
  log('onFileLoadProg');
};

demo.onFileLoad = function(data, file) {
  log('onFileLoad');
  log(file);
  log(data);
};

demo.onAbortLoadFile = function() {
  log('onAbortLoadFile');
};

demo.onFileLoadError = function() {
  log('onFileLoadError');
};

demo.onDnd2 = function(data) {
  $el('#dnd-area2').innerHTML = data;
};

// Set Mode
demo.dndHandler1.setMode('txt');
demo.dndHandler1.setMode('b64');
demo.dndHandler1.setMode('data');
demo.dndHandler1.setMode('bin');
demo.dndHandler1.setMode('blob');
demo.dndHandler1.setMode('evt');