<commit_before>function lg(s) { console.log(s); }

var
	elBody = document.body,
	elVideo = document.querySelector( "video" )
;

elBody.ondragover = function() {
	lg("body:ondragover");
	return false;
};

elBody.ondrop = function( e ) {
	lg("body:ondrop");
	elVideo.src = URL.createObjectURL( e.dataTransfer.files[ 0 ] );
	elVideo.play();
	return false;
};<commit_msg>Add WebVTT subtitles drop on each browsers<commit_after>function lg(s) { console.log(s); }

var
	elBody = document.body,
	elVideo = document.querySelector( "video" )
;

elBody.ondragover = function() {
	lg( "body:ondragover" );
	return false;
};

elBody.ondrop = function( e ) {
	lg( "body:ondrop" );

	var
		// Save file's informations
		dropFile = e.dataTransfer.files[ 0 ],
		// Create a temporary fake absolute path to the dropped file
		dropFileUrl = URL.createObjectURL( dropFile )
	;

	// Check type file, eg : "video/mp4" -> "video"
	switch ( dropFile.type.substr( 0, dropFile.type.indexOf( "/" ) ) ) {

		case "video" :
			elVideo.src = dropFileUrl;
			elVideo.play();
		break;

		default :
			switch ( dropFile.name.substr( dropFile.name.lastIndexOf( "." ) + 1 ) ) {

				case "vtt" :
					var elTrack = document.createElement( "track" );
					elTrack.kind = "subtitles";
					elTrack.src = dropFileUrl;
					elTrack.label = "Subtitles " + ( elVideo.textTracks ? elVideo.textTracks.length + 1 : 1 );
					elTrack.srclang = "en"; // TODO: We must find a way to made it generically
					elVideo.appendChild( elTrack );
					elTrack.addEventListener( "load", function() {
						// Set this track to be the active one
						this.mode =
						elVideo.textTracks[ 0 ].mode = "showing";
					}); 
				break;
			}
	}
	
	return false;
};
{'fraction_non_alphanumeric': 0.1472140762463343, 'fraction_numerical': 0.00469208211143695, 'mean_word_length': 3.265, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7494662', 'n_tokens_mistral': 681, 'n_tokens_neox': 597, 'n_words': 141}