{"size": 1454, "ext": "js", "max_stars_repo_path": "testweb.js", "max_stars_repo_name": "hoppang/drophere", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "testweb.js", "max_issues_repo_name": "hoppang/drophere", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "testweb.js", "max_forks_repo_name": "hoppang/drophere", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.5087719298, "max_line_length": 65, "alphanum_fraction": 0.704264099}
"use strict";

var manualUpload = document.querySelector('#manualUpload');
var progressBar = document.querySelector('#progressBar');
var dropzone = document.querySelector('#dropzone');
var result = document.querySelector('#result');

dropzone.addEventListener("dragover", dragOverHandler, false);
dropzone.addEventListener("dragleave", dragLeaveHandler, false);
dropzone.addEventListener("drop", dropHandler, false);

manualUpload.onchange = function () {
	uploadFile(manualUpload.files[0]);
};

function dropHandler(evt) {
	evt.stopPropagation();
	evt.preventDefault();
	result.innerText = "";
	uploadFile(evt.dataTransfer.files[0]);
}

function dragOverHandler(evt) {
	evt.stopPropagation();
	evt.preventDefault();
}

function dragLeaveHandler(evt) {
	console.log('drag leave');
	evt.stopPropagation();
	evt.preventDefault();
}

function uploadFile(file) {
	var formData = new FormData();
	formData.append("file", file);

	var xhr = new XMLHttpRequest();
	xhr.open('POST', '', true);
	xhr.upload.addEventListener('progress', updateProgress, false)
	xhr.onload = function() {
		console.log(this.responseText);
	};
	xhr.onloadend = function() {
		result.innerText = "upload complete";
		console.log("upload complete");
	}

	xhr.send(formData);
}

function updateProgress(evt) {
	console.log("progress:", evt.loaded, "/", evt.total);
	progressBar.value = evt.loaded;
	progressBar.max = evt.total;
}
