Drag and normal upload code This is a partial code of my JavaScript app.

The openDoc function's task is:
call newDoc if use uploads a file through fileInput.
Or, when user drag and drop a file in the document.

I want to review my logic and code.

      function stopDefault(event) {
        event.stopPropagation();
        event.preventDefault();
      }

      function openDoc(event) {
        var files = event.target.files || event.dataTransfer.files,
          file = files[0],
          reader = new FileReader();
        if (file) { // prevent TypeError
          stopDefault(event); // prevent default file drop behavior
          reader.readAsText(file);
        }
        reader.addEventListener("load", function(event) {
          newDoc(event.target.result, file.name);
        });
      }

  fileInput.addEventListener("change", openDoc);
  document.addEventListener("dragover", stopDefault);
  document.addEventListener("drop", openDoc);


If you're interested, checkout the full code - https://dl.dropboxusercontent.com/u/92126558/app.js
There is a not a lot to review, from a once over:


Indenting is not good for stopDefault, but I guess that's from copy pasting
There is no sense in calling addEventListener if file is not set, it should be part of your if block
Personally I would first add the listener, then starting reading text
I like your use of stopDefault
JsHint could find nothing wrong
Looks easy to maintain and to grok