Created
February 13, 2011 03:28
-
-
Save also/824406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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