elainewlin / MusicParsed

A better site for song chords with no scrolling and no ads.
https://www.musicparsed.com/
61 stars 16 forks source link

Frontend: Allow songs to be dragged in #126

Open earboxer opened 5 years ago

earboxer commented 5 years ago

I really love the interface, great for filling a screen so that multiple musicians can see it. It would be nice if we could "drop" in our own text files, (not upload, just locally view it).

earboxer commented 5 years ago

This can be (slightly) implemented by defining ondrop and ondragover on #songContainer

<div id="songContainer" ondrop="event.preventDefault();
  var file = event.dataTransfer.files[0];
  var reader = new FileReader();
  reader.onload = function(e){
    var text = e.target.result;
    document.getElementById('song').innerHTML = 
        '<div class=chordLyricLine>'+text+'</div>';
  }
  reader.readAsText(file);"
  ondragover="event.preventDefault();">

(of course, we wouldn't want to define it as inline javascript), and would probably want transposing to work...