123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- /* jshint browser: true */
- /* global $ */
- function putPreview (arrayBuf) {
- var arrayBufView = new Uint8Array(arrayBuf)
- var blob = new Blob([arrayBufView.buffer], { type: "audio/ogg" })
- console.log(blob)
- var url = URL.createObjectURL(blob);
- var au = document.createElement('audio');
- //name of .wav file to use during upload and download (without extendion)
- var filename = new Date().toISOString();
- //add controls to the <audio> element
- au.controls = true;
- au.src = url;
- document.getElementById('preview').appendChild(au)
- }
- function upload(content) {
- // questa funzione non critta, ma si deve comunque chiamare così!
- $('#upload').on('click', function () {
- // TODO: fai questo alla conferma
- var submit = new XMLHttpRequest()
- submit.open('POST', "upload/" + $('body').data('site'),true)
- submit.onload = function (evt) {
- console.log('ok, caricato!')
- $('#bar').hide()
- $('#spiegazione1').hide()
- $('#status').text('Hai lasciato un messaggio in segreteria, grazie!')
- }
- submit.send(content)
- })
- }
- $(function guiFunctions() {
- $('#preview').hide()
- $('#stop_record').hide()
- $('#visualizer').hide()
- $('body').on('recording-start-ok', function() {
- $('#record_audio').hide()
- $('#stop_record').show()
- $('#visualizer').show()
- })
- $('body').on('recording-start-fail', function(evt, err) {
- $('#content').hide()
- $('#container').text('Errore! apri il microfono')
- })
- $('body').on('recording-stop-ready', function(evt, content) {
- $('#stop_record').hide()
- $('#visualizer').hide()
- $('#preview').show()
- putPreview(content)
- upload(content)
- })
- })
|