Skip to content

Instantly share code, notes, and snippets.

@also
Created February 13, 2011 03:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save also/824406 to your computer and use it in GitHub Desktop.
Save also/824406 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Analyze</title>
<script src="nest.js" type="text/javascript"></script>
</head>
<body>
<h1>Analyze</h1>
<input type="file" id="fileInput" onchange="handleFiles(this.files)">
<div id="dropbox" style="width: 100px; height: 100px; background-color: #dddddd; margin-top: 1em; padding: .5em;">(drop here)</div>
<p id="text" style="font-family: monospace;"></p>
<script>
var nest = new Nest('API_KEY');
var dropbox = document.getElementById("dropbox");
var text = document.getElementById('text');
function no(e) {
e.stopPropagation();
e.preventDefault();
}
function drop(e) {
e.stopPropagation();
e.preventDefault();
var files = e.dataTransfer.files;
if (files.length > 0) {
handleFiles(files);
}
}
dropbox.addEventListener("dragenter", no, false);
dropbox.addEventListener("dragexit", no, false);
dropbox.addEventListener("dragover", no, false);
dropbox.addEventListener("drop", drop, false);
function handleFiles(files) {
file = files[0];
nest.analyzeFile(file, 'mp3', {onload: function (result) {
nest.loadAnalysis(result.response.track.audio_summary.analysis_url, {onload: function (analysis) {
text.innerHTML = JSON.stringify(analysis);
}})
}});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment